Java – Input element not found in div, selenium java eclipse

Input element not found in div, selenium java eclipse… here is a solution to the problem.

Input element not found in div, selenium java eclipse

Attached is the HTML

I’m trying to find an input element with a value of “save and return”.

I’ve tried finding it using xpath of value literals like this :

driver.findElement(By.xpath("//input[contains(@value,'Save and Return']")).click();

Solution

You need

driver.findElement(By.cssSelector("input[value=\\"Save and Return\\"]"));

Please let me know if it doesn’t work. Provide more details about the error. I may have misunderstood the escape character \\ in the string.

Related Problems and Solutions