SeleniumBase icon indicating copy to clipboard operation
SeleniumBase copied to clipboard

CF Turnstile fails when using xvfb, passes when not

Open kolgie opened this issue 4 months ago • 2 comments

I am using SeleniumBase on my Arch Hyprland Setup Bare Metal and on my Raspberry Pi in Docker. Originally I used only the Pi but when it started to not pass Turnstile anymore, I inspected with the Arch Setup. I'm also using UC and CDP modes. It seems that when I use xvfb (which I need because I want it to run headless), Turnstile fails (which I can see in the screenshots and in the debug print VALUE:), using the same code without xvfb in headed mode, it works without a problem. On Arch I tested with and without xvfb, on the Pi I couldn't, since it can't handle headed.

Here is the test code which also includes the website it's being tested on:

from seleniumbase import SB

import time
import sys
import os

def do_captcha():
    chrome_binary_path = "./chrome-linux/chrome"
    

    print("Starting browser...", flush=True)

    with SB(uc=True, binary_location=chrome_binary_path, chromium_arg="--ozone-platform=x11") as sb:
    #with SB(uc=True, binary_location=chrome_binary_path) as sb:
        print("Starting browser...", flush=True)

        url = "https://serienstream.to/serie/bugs-bunny-mein-name-ist-hase/staffel-1/episode-1"
        sb.activate_cdp_mode(url)
        sb.sleep(10)
        print("Opened browser", flush=True)
        sb.solve_captcha()
        sb.wait_for_attribute('[name="cf-turnstile-response"]', "value", timeout=10)
        print("cf turnstile pressed successfully")
        sb.sleep(3)
        element = sb.get_attribute(
            '[name="cf-turnstile-response"]',
            "value"
        )
        print(f'VALUE: {element}')
        sb.save_screenshot("ss_cf.png")

do_captcha()

Greatly appreciate all the work put into the project and also the support, which I used through answers given in issue reports prior :)

kolgie avatar Jul 15 '26 14:07 kolgie

I ran a script for the same site in an ARM64 GitHub Actions job: https://github.com/mdmintz/undetected-testing/actions/runs/29460111353/job/87501613949#step:16:29

Inside the uploaded artifacts for that, screenshots show that the Cloudflare Turnstile was bypassed successfully: https://github.com/mdmintz/undetected-testing/actions/runs/29460111353/artifacts/8360859965

This shows that you can bypass Cloudflare's Turnstile in a Linux environment with Xvfb. You might need to improve your configuration. Use this YML Workflow file to help you: https://github.com/mdmintz/undetected-testing/actions/runs/29460111353/workflow

Image

mdmintz avatar Jul 16 '26 00:07 mdmintz

Hey, just to clarify (without reopening), it was a VPN problem. It seems that CF Turnstile just got more picky and thorough because it worked a few months ago. It is still strange that it worked without xvfb, my guess is that the combination of xvfb + suspicious VPN server (at least to Turnstile) was just too obvious. Now choosing another server it works fine, even with xvfb. Maybe that's a trend we should keep an eye on.

kolgie avatar Jul 16 '26 13:07 kolgie