Issue
Okay, so this may seem like a bad program but it is not. This website I am testing is of my own website and I am testing a program to see if my login page and database can handle it under stress of repeated bot accounts; this here is my old site without Google's Captcha code: https://matrixmodders.com/
Long story short, I can successfully "click on the Google Captcha but with a Extension known as Buster; it supposedly can bypass the Captcha, for which you can read on your own here: https://chrome.google.com/webstore/detail/buster-captcha-solver-for/mpbjkejclgfgadiemmefgebjfooflfhl?hl=en
Here is my code:
//Finding and inputting Email:
driver.FindElement(By.XPath("/html/body/div[1]/div[3]/div/div[1]/div/div/div/div/div/div[1]/div/form/div[1]/input")).SendKeys(email);
//Finding and inputting The Username:
driver.FindElement(By.XPath("/html/body/div[1]/div[3]/div/div[1]/div/div/div/div/div/div[1]/div/form/div[2]/input")).SendKeys(username);
//Finding and inputting The Password:
driver.FindElement(By.XPath("/html/body/div[1]/div[3]/div/div[1]/div/div/div/div/div/div[1]/div/form/div[3]/input")).SendKeys(password);
//Clicking the Checkboxes
driver.FindElement(By.XPath("/html/body/div[1]/div[3]/div/div[1]/div/div/div/div/div/div[1]/div/form/div[4]/div/input")).Click();
driver.FindElement(By.XPath("/html/body/div[1]/div[3]/div/div[1]/div/div/div/div/div/div[1]/div/form/div[5]/div/input")).Click();
//Attempting to Click and Bypass the Captcha
driver.FindElement(By.XPath("//iframe[@title='reCAPTCHA']")).Click();
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(59);
driver.SwitchTo().Frame("recaptcha challenge expires in two minutes");
driver.FindElement(By.Id("solver-button")).Click();
//Clicking on Submit button:
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(59);
driver.FindElement(By.XPath("/html/body/div[1]/div[3]/div/div[1]/div/div/div/div/div/div[1]/div/form/button")).Click();
As you can see, I have successfully pressed the Captcha but the button that Buster adds is within the iframe of the Captcha box, as you can see here:
I have tried many numerous times trying to find the correct path so that selenium browser can "click" on it and let the Buster extension do it's thing... Can someone help me by adding this extension and helping me locate the correct path?
Solution
I tested this Extension at https://www.google.com/recaptcha/api2/demo with Selenium.WebDriver version 4.5.1 and it works fine. Although sometimes this extension can't recognize the captcha and you will need to try again. You can also experiment with delays.
One of the possible solutions:
string reCaptcha = "iframe[title=\"reCAPTCHA\"]";
string recaptchaChallenge = "iframe[title=\"recaptcha challenge expires in two minutes\"]";
string solverButton = "div.button-holder.help-button-holder";
string submitButton = "recaptcha-demo-submit";
ChromeOptions options = new ChromeOptions();
options.AddExtension(@"O:\selenium\buster_captcha_solver_for_humans-1.3.2-chrome.crx");
IWebDriver driver = new ChromeDriver(@"O:\selenium\", options);
driver.Url = "https://www.google.com/recaptcha/api2/demo";
driver.SwitchTo().Frame(driver.FindElement(By.CssSelector(reCaptcha)));
driver.FindElement(By.Id("recaptcha-anchor")).Click();
driver.SwitchTo().DefaultContent();
Thread.Sleep(1000);
driver.SwitchTo().Frame(driver.FindElement(By.CssSelector(recaptchaChallenge)));
driver.FindElement(By.CssSelector(solverButton)).Click();
Thread.Sleep(2000);
driver.SwitchTo().DefaultContent();
driver.FindElement(By.Id(submitButton)).Click();
Thread.Sleep(2000);
driver.Quit();
Answered By - Brze
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.