How to automate captcha using Selenium Webdriver?

I am writing a script for the login page. But I have a code that I want to process.

+7
source share
3 answers

Selenium can't handle captcha.

While the website uses captcha for the same reason, so no one can automate their website with robots.

You can ask your developers to provide you with a special environment in which they bypass these captcha functions or set the captcha value in the DOM so that you can get the captcha value at runtime.

There are some third-party libraries that claim that they can also automate captcha, but I have never tried or heard that they are also inefficient.

Some links: - How to read text from an image (captcha) using Selenium WebDriver with Java

http://www.mythoughts.co.in/2012/11/automatingbreaking-captcha-using.html#.Vt5psdx94x8

+8
source

Most solvers are captcha paid. A few examples in captchas solutions:

  • DeathByCaptcha
  • 2Captcha
  • anticaptcha
  • Decaptcher

The tesseract library allows tesseract to solve several examples in captcha.

+1
source

Here, try my method (in c):

 public void GenerateSnapshot(string filePath) { IWebDriver driver = new ChromeDriver(); driver.Manage().Window.Maximize(); driver.Navigate().GoToUrl("your url here"); var remElement = driver.FindElement(By.Id("your Captcha Id here")); Point location = remElement.Location; var screenshot = (driver as ChromeDriver).GetScreenshot(); using(MemoryStream stream = new MemoryStream(screenshot.AsByteArray)) { using(Bitmap bitmap = new Bitmap(stream)) { RectangleF part = new RectangleF(location.X, location.Y, remElement.Size.Width, remElement.Size.Height); using(Bitmap bn = bitmap.Clone(part, bitmap.PixelFormat)) { bn.Save(filePath + "CaptchImage.png", System.Drawing.Imaging.ImageFormat.Png); } } } //reading text from images using(var engine = new TesseractEngine("tessdata path here", "eng", EngineMode.Default)) { Page ocrPage = engine.Process(Pix.LoadFromFile(filePath + "CaptchImage.png"), PageSegMode.AutoOnly); var captchatext = ocrPage.GetText(); } } 

source: https://thedotnetlight.wordpress.com/2018/02/16/read-captcha-image-in-selenium-c/

0
source

Source: https://habr.com/ru/post/1244632/


All Articles