Skip to content
Advertisement

Select a button with selenium with same XPATH but no tag or id

I would like to select a button with selenium on the net, here’s the HTML code of the button:

JavaScript

They are 1 to 5 and have all the same XPATH : //html/body/div[2]/div/section/section/div[1]/div/div[2]/div[1]/div[2]/div[2]/div/div[2]/div/div[1]/div/button[1]

How can I select the third or second button with no tag in the HTML code?

Advertisement

Answer

JavaScript

You can use find_elements instead of find_element. Then you can get the 2. index of the result.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement