Skip to content

[Bug]: Auto solve from expect_and_bypass_cloudflare_captcha() doesnt seem to solve Cloudflare captcha #424

@caseSwift

Description

@caseSwift

Checklist before reporting

  • I have searched for similar issues and didn't find a duplicate.
  • I have updated to the latest version of pydoll to verify the issue still exists.

pydoll Version

2.14.0

Python Version

3.12.13

Operating System

Linux

Bug Description

Tab.expect_and_bypass_cloudflare_captcha() (and enable_auto_solve_cloudflare_captcha()) do nothing on Cloudflare's full-page "managed challenge" interstitial (the standalone
"Just a moment… / Verify you are human" page). The context manager returns immediately without attempting a click, and the page stays on the challenge.

The built-in bypass only works for pages that embed
a Turnstile widget (where a .cf-turnstile element exists in the light DOM, e.g. the planetminecraft.com/account/sign_in/
page used in the docs example). On the managed interstitial the widget lives inside Cloudflare's own challenge iframe / closed shadow roo, so the selector-based lookup finds
nothing.

Steps to Reproduce

import asyncio
import pydoll

use expect_and_bypass_cloudflare_captcha(): on link https://www.scrapingcourse.com/cloudflare-challenge

see if it passes

Code Example

import asyncio
from pydoll.browser.chromium import Chrome

# Public test page that always serves Cloudflare's *managed challenge* interstitial
# ("Just a moment..." / "Verify you are human").
URL = "https://www.scrapingcourse.com/cloudflare-challenge"


async def js(tab, expr):
    resp = await tab.execute_script(f"(() => ({expr}))()", return_by_value=True)
    return resp["result"]["result"]["value"]


async def main():
    browser = Chrome()  # add ChromiumOptions(binary_location=...) if not system Chrome
    tab = await browser.start()
    try:
        async with tab.expect_and_bypass_cloudflare_captcha():
            await tab.go_to(URL)
        await asyncio.sleep(3)  # let any solve settle

        print("title:", await js(tab, "document.title"))
        print(
            ".cf-turnstile in light DOM:",
            await js(tab, "document.querySelectorAll('.cf-turnstile').length"),
        )
    finally:
        await browser.stop()


asyncio.run(main())

Expected Behavior

I would expect cloudflare to be clicked and autosolved

Actual Behavior

It stays on the cloudflare page without attempting to solve it

Relevant Log Output

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions