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();


You can't handle captcha in selenium being one of its major Con. Alternatives are listed as follows:

  1. 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.

  2. Getting the captcha disabled in test environment if you can.

  3. 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.

OCR will return "Input this code: Z X 7 Z"

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.