Issue
Below is what HTML has. If I click using below XPATH, it's working fine. But data-qtip value keep changing and also there are other class with same name as above in HTML.
How can I click on whatever the value that appears @data-qtip
?
HTML:
<a href="javascript:void(0)">
<span class="item-context-link" data-qtip="3711672330">3711672330</span>
</a>
Code:
driver.find_element_by_xpath("//span[contains(@data-qtip, '3711672330')]").click()
Solution
based on OP response, there are 9 data-qtip
and due to lack of HTML, I will proide you solution using xpath indexing.
(//span[@data-qtip])[1]
should represent the first 1 element
, [2]
should represent the second element.
(//span[@data-qtip])[2]
and so on..
PS : Please check in the dev tools
(Google chrome) if we have unique entry in HTML DOM
or not.
Steps to check:
Press F12 in Chrome
-> go to element
section -> do a CTRL + F
-> then paste the xpath
and see, if your desired element
is getting highlighted with 1/1
matching node.
You can try to increase the index to have a unique matching node in HTMLDOM.
Code trial 1 :
time.sleep(5)
driver.find_element_by_xpath("(//span[@data-qtip])[1]").click()
Answered By - cruisepandey
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.