1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] how to reach element inside nested closed shadow roots selenium/python

Discussão em 'Python' iniciado por Stack, Setembro 9, 2025.

  1. Stack

    Stack Membro Participativo

    im trying to click the checkbox which is in a cloudflare turnstile widget. I can inject the token that i take from 2captcha but after that i cant click the checkbox. I think the check box is right there: Page DOM ├─ Closed shadow root ├─ Iframe ├─ Closed shadow root ├─ Checkbox still i could not figure it out how to click it with selenium and i do not know it is possible. I tried with this in a demo test site and it was successfull. But in my target site i can not do it.. I need your help.. try: self._log(" trying Host click ..")

    host_selectors = [
    '.cf-turnstile', # Cloudflare Turnstile wrapper
    '[class*="turnstile"]', # Turnstile class'ı olan elementler
    '[class*="cf-"]', # Cloudflare class'ı olan elementler
    '[data-sitekey]', # Sitekey attribute'u olan elementler
    'turnstile-widget', # Turnstile widget
    'div[class*="captcha"]', # Captcha class'ı olan elementler
    'div[class*="challenge"]', # Challenge class'ı olan elementler
    ]

    for selector in host_selectors:
    try:
    hosts = self.driver.find_elements(By.CSS_SELECTOR, selector)
    if hosts:
    host = hosts[0]
    self._log(f" found host: {selector}")


    try:
    self._log("trying to click with Host...")
    host.click()
    self._log(" success!")
    self._micro_pause(1, 2)

    # Çözüm kontrolü
    if self.check_turnstile_solved():
    self._log("solved after click!")
    return True
    return True

    except Exception as e:
    self._log(f" error: {e}")

    #public api host
    try:
    self._log("trying Host APIs...")
    api_script = """
    const host = arguments[0];

    Continue reading...

Compartilhe esta Página