Coder555
Coder555

Reputation: 11

Python Selenium .click method doesn't work

I am trying to click a button with the .click method, but if I type .cl, my IDE doesn’t even suggest the .click function. The Chrome window opens but then after that, Python throws an error. I added two pictures - in the first, you can see my code, and in the second, you can see the error that is thrown:

the two windows

Upvotes: 0

Views: 167

Answers (1)

Xiddoc
Xiddoc

Reputation: 3619

As you can see from the error, Python tries to access the Click attribute for a list object. This is happening because the .find_elements_by_xpath() method returns a list.

Therefore, the solution for your problem would be to pull an item from that list and use the click method on it, rather than on the list itself.

sb[0].click()

Upvotes: 1

Related Questions