Selenium Python : How to click on first occurrence of an element?

50 views
Skip to first unread message

Satish

unread,
Nov 18, 2018, 9:08:43 PM11/18/18
to Selenium Users
Hello,

I have a close button with same title appearing 10 times on the same page. I want to click on it's first occurrence. I tried storing it in the list but it did not work.

Please refer the attachment for HTML code.

Thanks in advance!

xpath.PNG

Venu G

unread,
Nov 19, 2018, 3:22:52 AM11/19/18
to Selenium Users
Hi you can use (driver.findelements) will fetch you all the child objects then you can close the first child 

or

you can use style to identify the element, for example say all the close button were hidden only one is showing then the style will be unique for the one which is shown.
Reply all
Reply to author
Forward
0 new messages