1

I am using services of ImageTyperz for solving the captcha but unable to submit a response back to the website. There is no submit button but a callback is there which should be called. When i call this callback i get selenium.common.exceptions.TimeoutException: Message: script timeout exception. The function which is called looks like this

                    function solvedCaptcha(payload) {
                        const timeoutMs = 10000;
                        protectionSubmitCaptcha("recaptcha", payload, timeoutMs, "3:wi5qRb7c93CuT63y1uUslQ==:BXJXyJOzlEFA5FdRRQw7hUgzO5M4FIz8DegFPzs6fER0MRWYM+P2Vac+z3qKo5UxmDqMuThgGaT0hK+Tu6Zj0b5sprMSQI7P2Wv7fAj7aFUC20NO7VN6NtyyTehmQcxscyQBUqvlXbyTct2rUi81hPRk9fp7Vt32kGZspgx0v4tbTmDK2xMG1mj5nOVN9TL5zs88iYQDfSa2lKcdLrhYl5VcEDh5rAAte8d6rvead+5oY0a8B7fennPu2+36wZboyg4JJ1yMSpMmZ8Nk47/R/Q==:BwSP9POMwcERVjmiYuOpMZkDQmQS1ksQSij5jk8Fs8A=").then(function() {
                            window.location.reload(true);
                        });
                    }
                

I am running the following command

driver.execute_async_script("var payload = " + str(recaptcha_response) + ";" + "solvedCaptcha(payload);")

Here recaptcha_response is the response dict got from ImageTyperz api.

3
  • You want regular execute_script here. Otherwise it times out waiting for a callback. Commented Feb 8, 2021 at 1:02
  • @pguardiario It worked, Thanks alot. Now the problem is that the website is still not opened and it looks like nothing happened in the backend. The selenium webdriver is still at captcha page. Shouldn't it move forward and go to the main page instead of captcha page? Commented Feb 8, 2021 at 21:21
  • I can't tell from that. Usually there's a textarea that you fill with the captcha data Commented Feb 9, 2021 at 0:55

1 Answer 1

6

I solved the problem

I've finally managed to resolve this myself. In case anyone else is struggling with a similar issue, here was my solution:

  • Open the console and execute the following cmd: ___grecaptcha_cfg.clients
  • Find the path which has the callback function, in my case it's ___grecaptcha_cfg.clients[0].O.O
  • Use the following code: driver.execute_script(f"___grecaptcha_cfg.clients[0].O.O.callback('{new_token}')") (Remember to change the path accordingly)

This Article will help you to find the ___grecaptcha_cfg.clients of your recaptcha site

driver.execute_script('document.getElementById("g-recaptcha-response").innerHTML = "{}";'.format(g_response))   
driver.execute_script(f"___grecaptcha_cfg.clients[0].O.O.callback('{g_response}')")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.