SolveHub

Playwright Integration for Authorized CAPTCHA QA

Connect the REST client to a controlled test fixture using an explicit test hook. Keep service credentials in the test runner.

For authorized QA automation and browser integration. Use only on websites and workflows you have permission to test.

Scope: your own application test hook

This example connects Playwright to an explicit setCaptchaResponseForTest hook in a controlled HTML fixture. It demonstrates passing a response from a server-side REST client into your own test application. It is not a generic mechanism for third-party pages and does not validate a CAPTCHA token.

Verify the fixture first

Download playwright-example.mjs, its linked client and test-fixture.html into the same directory. Start the local fixture server:

python3 -m http.server 8000 --bind 127.0.0.1

In a second terminal, install the test runner and use a local-only placeholder:

npm install playwright
npx playwright install chromium
# In another terminal, from the downloaded examples directory:
FIXTURE_TOKEN='local-fixture-only' node playwright-example.mjs

The test fills the hidden response through the fixture's test hook, submits the form and asserts the fixture reports submitted. A browser and its driver must be available in your environment. Keep the fixture and hook confined to your test environment.

Connect a paid task only when needed

Remove FIXTURE_TOKEN and follow the nodejs setup to set your private API Key, stable idempotency key and task JSON. Replace the example site with an authorized test application and configure TEST_PAGE_URL. The test hook must exist in that application. Keep the Key in the runner, never in page scripts.

The fixture itself is not a Turnstile challenge. If the application verifies Turnstile server-side, test that verification separately using its documented flow or official test keys. Client-side fixture submission is not proof of server-side verification.

Match the browser context

For cookie-based tests, use the same proxy/IP and returned useragent before starting the browser context, following the session consistency guide. The downloadable example handles a Turnstile-style response, not every cookie result type. See Turnstile fields and safe polling.

Developer downloads

python-client.py v1.0.0 — standard library only; behaviour and error codes are documented on this page.

Related documentation

Start with cURL Create account

Last updated: