Not sure what im doing here- I can print the token but im having issues sending it back to the server.
iframe = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.XPATH, '//iframe[@title="reCAPTCHA"]'))
)
driver.switch_to.frame(iframe)
print("Inside reCAPTCHA iframe...")
# Solve the captcha and capture the token (adjust this part according to your library's documentation)
captcha_solver = ReCaptcha(api_key="",
captcha_type="ReCaptchaV2Task",
websiteURL="",
websiteKey="",
proxy=proxy)
captcha_token = captcha_solver.captcha_handler() # Assuming this returns the token
print(captcha_token)
# Switch back to the main content if you were inside an iframe
driver.switch_to.default_content()
# Assuming captcha_token is an object and has a 'gRecaptchaResponse' attribute
token_string = captcha_token.gRecaptchaResponse
# Safely convert the token_string to a JavaScript string
import json
safe_captcha_token = json.dumps(token_string)
# Find the textarea element
textarea = driver.find_element(By.ID, "g-recaptcha-response")
# Execute the JavaScript code to insert the CAPTCHA token into the textarea
driver.execute_script(f"arguments[0].value = {safe_captcha_token};", textarea)
# Wait for the element with the specified XPath to have the attribute aria-checked="true"
wait.until(EC.presence_of_element_located((By.XPATH, '//*[@id="recaptcha-anchor" and @aria-checked="true"]')))
Not sure what im doing here- I can print the token but im having issues sending it back to the server.