0

I am having a problem with C# Selenium and CaptchaSharp Package.

The problem is the package use its own httpclient instead i want it to use the Chrome Web Driver as i am using it in Selenium. What i mean is i want it to solve the captcha and return the answer on the Chrome driver i am using.

How can i change the CaptchaSharp Package so it would use Chrome Web Driver as default? Here is my sample code which doesn't work. (The solution returns the captcha answer btw)

        WebDriver driver = new ChromeDriver();
        driver.Navigate().GoToUrl("https://www.google.com/recaptcha/api2/demo");
        CaptchaService service = new  TwoCaptchaService("Api Key");
        decimal balance = await service.GetBalanceAsync();
        StringResponse solution = await service.SolveRecaptchaV2Async("6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-", "https://www.google.com/recaptcha/api2/demo", false, null, default);
        Console.WriteLine($"The solution is {solution.Response}");
James
  • 13
  • 2

1 Answers1

0

Take the solution and type it in the browser via Selenium.

Let's assume that this is the Captch input field:

driver.findElementByCss("input[class='myCaptcha]").sendKeys(solution.Response);
Tal Angel
  • 1,301
  • 3
  • 29
  • 63
  • I tried it to send to "g-recaptcha-response" but it doesn't accept sendkeys. Even though it would work i think it wouldn't be the same captcha because browsers would be different. – James Jan 31 '22 at 17:37
  • @James Take the captcha data and send it into the Captcha object. You can click on the edit field and type not via sendKeys, but via robot class. The robot class mimic keyboard pressing with any relation to the UI. – Tal Angel Jan 31 '22 at 18:24