How To Get Past A Cookie Agreement Page Using Python And Selenium?
I am quite new to selenium and python. I am trying to navigate through a webpage (https://www.heise.de/download/) but can't get passed the cookiewall (cookie agreement page). It se
Solution 1:
The element Alles akzeptieren is within #shadow-root (open).
Solution
To click on Alles akzeptieren you have to use shadowRoot.querySelector()
and you can use the following Locator Strategy:
Code Block:
driver.get("https://www.heise.de/download/") time.sleep(5) element = driver.execute_script("""return document.querySelector('#usercentrics-root').shadowRoot.querySelector('footer div div div button[data-testid="uc-accept-all-button"]')""") element.click()
Browser Snapshot:
References
You can find a couple of relevant discussions in:
Post a Comment for "How To Get Past A Cookie Agreement Page Using Python And Selenium?"