简体   繁体   中英

Captcha Problem C# Selenium and CaptchaSharp Package

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}");

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM