how to handle captcha in selenium webdriver: I am using this code but it gives error"Error communicating with the remote browser. It may have died." code is below: driver.findElement(By.xpath(".recaptcha-checkbox-checkmark")).click();
-
1this question is already answered in the following link: sqa.stackexchange.com/questions/17022/…– the_coderFeb 21, 2017 at 5:50
-
Hi This error is different. It is not related to captcha. Captcha should not be automated.Read reasons here. [ quora.com/Whats-the-purpose-of-CAPTCHA ]. I advice you to check configurations for selenium webdriver.– Sagar007Feb 21, 2017 at 5:52
2 Answers
You can't handle captcha in selenium being one of its major Con. Alternatives are listed as follows:
Using Deathbycapthca API: By using this external service you would be able to send the captcha to them to which in reverse you would be getting text to which you have to enter in the box and submit.
Getting the captcha disabled in test environment if you can.
You can use image recolonization software like Sikuli (http://www.sikuli.org/), it’s an intelligent tool for recognizing the image. It’s an open source tool. But less chance to work for read CAPTCHA but it work good for verify you image ,color and etc.
Reference: https://www.linkedin.com/pulse/how-solve-captcha-image-selenium-chetna-soni
For simple CAPTCHAs like the one below you can first extract the image with Selenium and then send it to the free OCR.space OCR API for processing. This will return the text inside the (Captcha) image.
Another option for solving simple Captchas (and running image/video-related tests in general) is to use the Kantu Browser (like Sikuli, but for the web browser). It has built-in OCR features.