Anti-Captcha - Error " Wrong Captcha"

I run into the following problem:

  • when submitting a form, after solving a captcha, the following error is returned: wrong captcha

I am using the following API

Code Used:


check_key = self.driver.find_element_by_class_name('g-recaptcha')
site_key = check_key.get_attribute("data-sitekey")
url_key = self.driver.find_element_by_xpath("//iframe[contains(@src,'https://www.google.com/recaptcha/api2/anchor?ar=1&k=" + site_key + "')]")
url = url_key.get_attribute("src")

 ANTICAPTCHA_KEY = api_key
                    PAGE_URL = url
                    SITE_KEY = site_key

                    result = NoCaptchaTaskProxyless.NoCaptchaTaskProxyless(anticaptcha_key = ANTICAPTCHA_KEY)\
                    .captcha_handler(websiteURL=PAGE_URL,
                                 websiteKey=SITE_KEY)
                    captcha_answer = result.get("solution").get("gRecaptchaResponse")
                    if captcha_answer != "":
                        print(captcha_answer)
                        self.driver.execute_script("document.getElementById('g-recaptcha-response').focus();")
                        time.sleep(2)
                        self.driver.execute_script("document.getElementById('g-recaptcha-response').style.display = 'block';")
                        time.sleep(2)
                        self.driver.execute_script("document.getElementById('g-recaptcha-response').innerHTML='%s'" % captcha_answer)
                        time.sleep(2)
                        nextBtn = self.driver.find_element_by_xpath("//input[@value='Avançar']")
                        nextBtn.click()

I have the key from the API and the values of the fields url and site_key are being correctly passed.

The value of the field textarea is pre-entered, however, the error is returned (after clicking the button). May the returned token be wrong ?

Thank you.

Author: Adriano Maia, 2019-11-21