"""pip install selenium. Run ONLY against your own fixture with this explicit test hook.""" import importlib.util import json import os from pathlib import Path from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait spec = importlib.util.spec_from_file_location('solvehub_client', Path(__file__).with_name('python-client.py')) client = importlib.util.module_from_spec(spec) spec.loader.exec_module(client) options = webdriver.ChromeOptions() options.add_argument('--headless=new') driver = webdriver.Chrome(options=options) try: driver.get(os.environ.get('TEST_PAGE_URL', 'http://127.0.0.1:8000/test-fixture.html')) WebDriverWait(driver, 10).until(lambda d: d.execute_script('return typeof window.setCaptchaResponseForTest === "function"')) token = os.environ.get('FIXTURE_TOKEN') if not token: with open(os.environ['SOLVEHUB_TASK_FILE'], encoding='utf-8') as source: token = client.run_task(json.load(source)).get('value') if not isinstance(token, str) or not token: raise ValueError('Expected a Turnstile response in solution.value') driver.execute_script('window.setCaptchaResponseForTest(arguments[0])', token) driver.find_element(By.CSS_SELECTOR, 'button').click() WebDriverWait(driver, 10).until(lambda d: d.find_element(By.ID, 'result').text == 'submitted') print('Controlled fixture submitted; application-side verification is a separate assertion.') finally: driver.quit()