seleniumbase / SeleniumBase

📊 Blazing fast Python framework for web crawling, scraping, testing, and reporting. Supports pytest. Stealth abilities: UC Mode and CDP Mode.
https://seleniumbase.io
MIT License
5.47k stars 988 forks source link

'BaseCase' object has no attribute 'uc_gui_handle_cf' #2923

Closed RoseGoli closed 4 months ago

RoseGoli commented 4 months ago

i want to bypass cloudflare captcha (Verify you are human)

from seleniumbase import SB

with SB(uc=True, test=True) as sb:
    url = "https://seleniumbase.io/apps/turnstile"
    sb.uc_open_with_reconnect(url, reconnect_time=2)
    sb.uc_gui_handle_cf()
    sb.assert_element("img#captcha-success", timeout=3)
    sb.set_messenger_theme(location="top_left")
    sb.post_message("SeleniumBase wasn't detected", duration=3)

and this is my error :

Traceback (most recent call last): File "C:\Users\digicup\AppData\Local\Programs\Python\Python311\Lib\site-packages\seleniumbase\plugins\sb_manager.py", line 944, in SB yield sb File "C:\Users\digicup\Desktop\sb\app.py", line 6, in sb.uc_gui_handle_cf() ^^^^^^^^^^^^^^^^^^^ AttributeError: 'BaseCase' object has no attribute 'uc_gui_handle_cf'

mdmintz commented 4 months ago

You may have an older version of seleniumbase installed. Use:

from seleniumbase import __version__
print(__version__)

and make sure your version is 4.28.5 or newer.

wwangyu2 commented 4 months ago

The website https://seleniumbase.io/apps/turnstile displays as passing, but https://core.particle.network/cloudflare.html shows failure."

from seleniumbase import SB

with SB(uc=True, test=True) as sb:
    url = "https://core.particle.network/cloudflare.html"
    sb.uc_open_with_reconnect(url, reconnect_time=10)
    sb.uc_gui_handle_cf()
    sb.assert_element("img#captcha-success", timeout=3)
    sb.set_messenger_theme(location="top_left")
    sb.post_message("SeleniumBase wasn't detected", duration=3)
mdmintz commented 4 months ago

@wwangyu2 because the asserts were for that specific page. You used a different one.

Try this for yours:

from seleniumbase import SB

with SB(uc=True, test=True) as sb:
    url = "https://core.particle.network/cloudflare.html"
    sb.uc_open_with_reconnect(url)
    sb.uc_gui_click_captcha()
wwangyu2 commented 4 months ago

@mdmintz don't work,Can't click on checkbox