Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 16743

Can't click a button that is inside a shadow DOM using Selenium

$
0
0

Using selenium in Python I want to target this button that is inside a DOM element. The button is to accept cookies. I have tried many options and none of the are working. Here is the last version that I tried. The button I am trying to click is under the name "accept_cookies".

The site I am trying to enter is: https://www.immobilienscout24.de/

parent_element = driver.find_element(By.ID, "usercentrics-root")shadow_root_script = "return arguments[0].shadowRoot || arguments[0].webkitShadowRoot;"shadow_root = driver.execute_script(shadow_root_script, parent_element)accept_cookies = shadow_root.find_element(By.CLASS_NAME, 'sc-dcJsrY ezjNCe')accept_cookies.click()

enter image description here


Viewing all articles
Browse latest Browse all 16743

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>