public void SolveCaptchaPartOneTest() { CaptchaSolver solver = new CaptchaSolver("91212129"); int solution = solver.SolveCaptcha(1); Assert.AreEqual(9, solution); }
public void SolveCaptchaPartTwoTest() { CaptchaSolver solver = new CaptchaSolver("12131415"); int solution = solver.SolveCaptcha(4); Assert.AreEqual(4, solution); }
private void GoToAccountParcelSummaryPage() { _driver.Navigate().GoToUrl("http://info.kingcounty.gov/finance/treasury/propertytax/RealProperty.aspx?Parcel=" + _parcelNumber); bool captchaExists = false; try { captchaExists = _searchFramework.CapatchaTextField().Displayed(); } catch (Exception e) { }; if (captchaExists) { //recaptcha_challenge_image var arrScreen = _driver.GetScreenshot().AsByteArray; using (var msScreen = new MemoryStream(arrScreen)) { var bmpScreen = new Bitmap(msScreen); var cap = _driver.FindElementById("recaptcha_challenge_image"); var rcCrop = new Rectangle(cap.Location, cap.Size); Image imgCap = bmpScreen.Clone(rcCrop, bmpScreen.PixelFormat); using (var msCaptcha = new MemoryStream()) { imgCap.Save(msCaptcha, ImageFormat.Png); string captchaText = _captchaSolver.SolveCaptcha(msCaptcha); _captchaBalance = _captchaSolver.Balance; _searchFramework.CapatchaTextField().Type(captchaText); } } } while (!_searchFramework.ParcelNumberTextField().Displayed()) { Thread.Sleep(1000); } while (!_searchFramework.SearchButton().Displayed() || !_searchFramework.SearchButton().Enabled()) { Thread.Sleep(1000); } //_searchFramework.ParcelNumberTextField().Type(_parcelNumber); _searchFramework.SearchButton().Click(); if (captchaExists) { try { _searchFramework.SearchButton().Click(); } catch (Exception ex) { Console.WriteLine("Cannot Click Search Button!"); } } }