Issue
The element to be clicked based ONLY on the text it contains (others):
<a class="blah" href="/some_page/"><span>15</span> others</a>
The item that fails:
driver.find_element(By.XPATH, "//*[contains(text(), ' others')]").click()
The error:
NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//*[contains(text(), 'others')]"}
Solution
An additional alternative from DebanjanB's answer using a different xpath inspired from XPath contains(text(),'some string') doesn't work when used with node with more than one Text subnode
"//*[text()[contains(.,' others')]]"
Answered By - FunkySayu
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.