Skip to content
Advertisement

How can i click an button inside 2 divs in selenium python?

I’m trying to make selenium click Button1 but for some reasons, I get the following error:

selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: Button1

I believe the error is happening because it is inside a div/ul/li tag but I can’t either figure out how to do it, I’m stuck.

HTML:

JavaScript

Python Code:

JavaScript

Edit: I found out that the html is generated through javascript. my bad.

Advertisement

Answer

You can try the following methods

JavaScript

Or try like you said, to locate the element inside div/ul/li

JavaScript

And if that doesn’t work for some reason, try with ActionChains

For that, you need to import the module

JavaScript

Then use it to click on the element,
this has been a life savior for me in some situations

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