I'm trying to click on an accept cookies button while navigating a webpage using Selenium and Python.
I've used inspect element to find the class name of the button, and then .click()
in Python to click on it. It isn't a link, but if it were working the accept cookies pop-up would disappear, and it isn't.
Instead, I'm getting this error:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".SubmitButton CookiePopup-button"}
Here is the code I am running:
cookie_button = driver.find_element("class name", "SubmitButton CookiePopup-button").click()
Thanks for your responses!
You may try this, see if it works
cookie_button = driver.find_element(By.CSS_SELECTOR, "button.SubmitButton.CookiePopup-button").click()