D
D
Dessstiny2022-04-02 14:32:54
Python
Dessstiny, 2022-04-02 14:32:54

How to improve code with click click through get_element_by_class_name with same classes of two elements?

624833c59d470910482289.png
If I write driver.execute_script("document.getElementByClassName('buttonDecline_3T_Jh')[0].click();") there is a click on the first button, but I need to recreate the click on the second button, but when writing driver.execute_script("document. getElementByClassName('button_306O5')[0].click();") the second button is not clicked.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2022-04-02
@Dessstiny

But is there getElementByClassName?
If you are looking for multiple elements with the same class, your button will be at least second in the list, so

document.getElementsByClassName('button_306O5')[1].click();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question