Skip to content
solvepass

Selenium + Solvepass

Create a task from Python, poll it, and pass the token into the page with execute_script.

PythonCross-browser test suites and Java/Python automation stacks.
solvepass-selenium.pypython
import os
import time
import requests
from selenium import webdriver

key = os.environ["SOLVEPASS_KEY"]
headers = {"Authorization": f"Bearer {key}"}

driver = webdriver.Chrome()
driver.get("https://example.com/login")

task = requests.post(
    "https://api.solvepass.com/v1/tasks",
    headers=headers,
    json={
        "type": "hcaptcha",
        "sitekey": "10000000-ffff-ffff-ffff-000000000001",
        "pageurl": driver.current_url,
    },
    timeout=30,
).json()

while True:
    data = requests.get(
        f"https://api.solvepass.com/v1/tasks/{task['id']}",
        headers=headers,
        timeout=30,
    ).json()

    if data["status"] == "completed":
        token = data["solution"]["token"]
        break
    if data["status"] == "failed":
        raise RuntimeError(data["error"]["code"])
    time.sleep(1)

driver.execute_script(
    "document.querySelector('[name=h-captcha-response]').value = arguments[0]",
    token,
)
driver.quit()

What to check

  • Use the current URL after navigation; single-page apps can change it.
  • Set the token in the field the target expects, or call the page callback.
  • For Cloudflare Challenge, apply the returned cookies to the driver instead of a form field.

The same three steps

  1. 01Create a task with the type, sitekey, and page URL.
  2. 02Poll the task or wait for a signed webhook.
  3. 03Use the token, or apply the clearance cookies with the same proxy and user agent.

Other integrations