Reputation: 3547
I get the following error:
com.thoughtworks.selenium.SeleniumException: ERROR: Invalid xpath [2]: //input[@value='Accedi']
at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:112)
at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:106)
at com.thoughtworks.selenium.DefaultSelenium.click(DefaultSelenium.java:193)
The XML part of the file is:
<p>
<div><input class="login button" type="submit" value="Accedi" /></div>
</p>
My Java code is:
selenium.click("//input[@value='Accedi']");
I have tried to change single quotes into double quotes, changed xpath to:
/html/body/div[3]/div[2]/form/p[4]/div/input[@value="Accedi"]
Which I got from a tool.
Why are all the XPaths that I have tried wrong?
Upvotes: 2
Views: 2381
Reputation: 962
Can you make sure few things:
Can you make sure the Xpath evaluation is returning just a single object which you want to click.
If you are able to identify your object uniquely, then can you try clicking using below suggestions?
Can you try this Xpath : //input[contains(@class,'login button')] or //input[contains(@value,'Accedi')]
If you still facing the issue, can you please post the Selenium Version and the browser you are using. If you are using chrome or IE, also specify the driver version for the same.
Upvotes: 2