Skip to content
Advertisement

How to get Selenium to recognise a button and click it?

How would I get selenium python to recognise this button in HTML?

I’ve tried this and other tags to get it

JavaScript

This is the button snippet code

JavaScript

Advertisement

Answer

Your locator is wrong. The class is named cookie-monster__cta, not .cookie-monster. js-cookie-monster-accept seems to be unique class name. Use it for finding your element. Also, you should wait for elements before clicking them.

JavaScript

If this locator is not unique, add classes one by one to both wait and find_element_by_css_selector, like this:

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