#UC works for clicking captcha where CDP doesn't in Linux container

1 messages · Page 1 of 1 (latest)

spiral plank
#

alright, i was finally able to get captcha clicking in a container working! thanks again for your previous help for suggesting that i try to get PyAutoGUI working in Docker.

I am now running into another issue related to what i posted earlier in #🐙-cdp-mode this morning. But seems like on Docker (specifically Linux seems like) trying to click captcha in CDP mode doesn't work when UC mode does.

I do have a suspicion that it might be related to my nest_asyncio.apply() call there, however i need it since i'm calling my seleniumbase script in an async context (my code basically does a GET request to a running webserver with uvicorn which then fires off this seleniumbase script)

my sample script i'm using where UC mode works but CDP mode doesn't (again happens in Linux on a container running an xvfb display)

nest_asyncio.apply()

async def test_selenium_webdriver():
    screenshots = []

    with SB(
        xvfb=True,
        uc=True,
    ) as sb:
        await do_test_1_uc_mode(sb)

    print("about to do cdp mode driver stuff")
    with SB(
        xvfb=True,
        uc=True,
    ) as sb:
        do_test_1_cdp_mode(sb)


async def do_test_1_uc_mode(sb):
    # Checks if we can click captcha in uc mode
    url = "https://seleniumbase.io/apps/turnstile"
    sb.uc_open_with_reconnect(url, reconnect_time=4)
    print("was able to open url in uc mode")
    sb.sleep(2)
    sb.uc_gui_click_captcha()
    sb.sleep(3)


def do_test_1_cdp_mode(sb):
    # Checks if we can click captcha in uc mode
    url = "https://seleniumbase.io/apps/turnstile"
    sb.activate_cdp_mode(url)
    print("was able to open url in cdp mode")
    sb.sleep(2)
    sb.uc_gui_click_captcha()
    sb.sleep(3)

I did see you put some stuff here: https://github.com/seleniumbase/SeleniumBase/blob/master/examples/cdp_mode/raw_async.py however i wasn't able to call uc_gui_click_captcha() using the raw CDP driver. Anything obvious that i'm doing wrong here?

#

if it helps, I can provide my Dockerfile and stuff. However I used yours in the seleniumbase repo as my source of inspiration so I don't think itll help too much.

Again the only difference I can think of is how im invoking myscript which is a GET request which asynchronously calls the seleniumbase script. I did see from your code that we use an event loop for CDP mode so unsure if thats whats interfering

past sigil