Cloudflare Turnstile solver · Selenium
Solve Cloudflare Turnstile in Selenium
In a Selenium script on a site you are allowed to automate, a Turnstile widget takes one call to ZeroCaptcha: read the site key, action and cData, solve, set the token in the form and submit. The sample uses the Python client, which is coming to PyPI; until then, the Python page makes the same calls with requests. The same steps work in any Selenium binding.
Plain HTTP today; the official Python client is coming
The steps in Selenium
Get an API key
Sign up with an email and a password, create your key in the dashboard and add funds in crypto, from $10.
Read the widget's site key, action and cData
Open the page in Selenium and read data-sitekey, data-action and data-cdata from the Turnstile element, or the sitekey, action and cData options of its turnstile.render() call.
Solve it with ZeroCaptcha
Send the page's URL, the site key, and the action and cData when the widget sets them, to ZeroCaptcha and wait for the token. Many sites check both when they verify it.
Put the token in the form
Set the cf-turnstile-response field to the token, then submit the form as a person would, within 300 seconds.
New to the API? The quickstart walks through sign-up, the key and the first task.
Good to know
Solve right before you submit: the token works once, within 300 seconds.
In Java, C# or JavaScript bindings, call the API as the language pages show, then set the field with executeScript.
Some pages read the token from the widget's callback rather than the form field. On those, call the page's own callback with the token.
Read next
- Cloudflare TurnstileSubmit a Cloudflare Turnstile Token: Form Fields and CallbacksWhere a solved Turnstile token goes: the cf-turnstile-response field, the widget's callback, or a JSON body. With examples for forms, fetch and browsers.
- Cloudflare TurnstileHow to Find a Cloudflare Turnstile Sitekey on Any PageFind a Cloudflare Turnstile sitekey in data-sitekey, in turnstile.render() or in the network log, and check you have the right one before you send a task.
- Cloudflare TurnstileCloudflare Turnstile Token Expired? Lifetime and Reuse ExplainedCloudflare Turnstile tokens last 300 seconds and work once. Why tokens expire, what timeout-or-duplicate means, and how to use each token before it runs out.
Selenium questions
Does it work with Selenium in Java or C#?
Yes. Create the task over HTTP as the Java and C# pages show, then set cf-turnstile-response with executeScript before you submit.
How long does a Cloudflare Turnstile token last?
A Cloudflare Turnstile token works once and expires 300 seconds after it is issued, so solve right before you submit. Every result tells you when its token expires.
What does a failed task cost?
Nothing. The price is held when you create a task and released at once if it fails or expires, and a refused task holds nothing; you pay only when a token is ready.