How to "submit" injected reCaptcha v2 solution when no button identified? (Selenium - Python)

68 Views Asked by At

Below is what I have so far, but it doesn't work.. I found a textarea marked g-recaptcha-response and injected into it a TwoCaptcha-generated solution. But I have no way to "Submit" it. Cannot locate any button and focusing on it and pressing Enter doesn't seem to work unless I'm doing something wrong.

Any solutions are welcome.. The site generating the reCaptcha v2 prompts the challenge upon clicking "submit" on my search request. No "Submit" inside the reCaptcha area was found, just "Verify".

        # Solve the reCAPTCHA
        result = solver.recaptcha(sitekey, driver.current_url)

        # Inject the result into the hidden textarea
        driver.execute_script('document.getElementById("g-recaptcha-response").innerHTML = "%s"' % result['code'])

        # Make the g-recaptcha-response textarea visible for interaction
        recaptcha_response_area = driver.find_element(By.ID, "g-recaptcha-response")
        driver.execute_script("arguments[0].style.display = 'block';", recaptcha_response_area)

        # Create an ActionChain to perform keyboard actions
        actions = ActionChains(driver)

        # Move to the textarea, focus on it, and simulate the Enter key press
        actions.move_to_element(recaptcha_response_area).click().send_keys(Keys.ENTER).perform()

0

There are 0 best solutions below