Reputation: 1
When recorded in Selenium IDE, the result is this:
click //span[@id='some_text']/table/tbody/tr/td/table/tbody/tr[2]/th/hd/font/span/acronym
Here is my entry in Eclipse using WebDriver(Java)
driver.findElement(By.xpath("//span[@id='some_text']/table/tbody/tr/td/table/tbody/tr[2]/th/h2/font/span/acronym")).click();
Here is the error I receive:
no such element: Unable to locate element: {"method":"xpath","selector":"//span[@id='some_text']/table/tbody/tr/td/table/tbody/tr[2]/th/h2/font/span/acronym"},
HTML
<span onclick="change_site"('SITES');" style="cursor:pointer; color:#12345; text-decoration:underline;">
<acronym title=Site ID:">DEFAULTSITE</acronym>
</span>
Upvotes: 0
Views: 2937
Reputation: 96
If none of the above Xpath has worked for you ,please try the following Xpath
//span[@id='some_text']/table/tbody/tr/td/table/tbody/tr[2]/th/hd/font/span/*[name()=acronym]
Please let me know if this has helped you or not.
Upvotes: 0
Reputation: 3235
Try any of the below xpath
driver.findElement(By.xpath("//acronym[text()='DEFAULTSITE']");
driver.findElement(By.xpath("//span/acronym[text()='DEFAULTSITE']");
Or this css
driver.findElement(By.css("acronym[title='Site']");
Upvotes: 0
Reputation: 1668
Try with below xPath :
driver.findElement(By.xpath("//acronym[contains(text(),'DEFAULTSITE')]").click();
Upvotes: 0
Reputation: 4666
As per the HTML provided you can directly access the acronym element
driver.findElement(By.xpath("//span/acronym[@title='Site Id:']")).click();
Upvotes: 1