public static void AfterScenario() { Console.WriteLine("AfterScenario Hook"); if (ScenarioContext.Current.TestError != null) { string name = ScenarioContext.Current.ScenarioInfo.Title + ".jpeg"; TakeScreenShots.CaptureScreenshoots(name); Console.WriteLine(ScenarioContext.Current.TestError.Message); Console.WriteLine(ScenarioContext.Current.TestError.StackTrace); } }
public void GivenTheAdminIsAtEligibilityDataScreen() { Thread.Sleep(5000); LinkHelper.ClickLink(By.XPath("//span[@class='route-title animate__animated animate__slideInDown ng-tns-c155-1'][contains(text(),'Eligibility')]")); Thread.Sleep(5000); LinkHelper.ClickLink(By.XPath("//span[@class='sub-route route-title animate__animated animate__slideInDown ng-tns-c155-1'][contains(text(),'Add')]")); Thread.Sleep(5000); IJavaScriptExecutor jse = (IJavaScriptExecutor)ObjectRepository.Driver; //jse.ExecuteScript("scroll(0, 250)"); Thread.Sleep(5000); //LinkHelper.ClickLink(By.XPath("//h5[contains(text(),'Employment Details')]")); JavaScriptExecutor.ScrollToAndClick(By.XPath("//h5[contains(text(),'Employment Details')]")); // Actions action = new Actions(ObjectRepository.Driver); IWebElement element = ObjectRepository.Driver.FindElement(By.XPath("//*[@id='mat-select-3']")); ObjectRepository.Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(15); //action.MoveToElement(element).Click().Build().Perform(); jse.ExecuteScript("arguments[0].click(); ", element); Thread.Sleep(5000); TakeScreenShots.CaptureScreenshoots("Test"); //LinkHelper.ClickLink(By.XPath("//span[text()=' 101 - T-Mobile ']")); JavaScriptExecutor.ScrollToAndClick(By.XPath("//span[text()=' 101 - T-Mobile ']")); Thread.Sleep(5000); TextBoxHelper.TypeInTexBox(By.XPath("//input[@formcontrolname='employeeDepartmentName']"), "sdgfjsjdsgh"); IWebElement element2 = ObjectRepository.Driver.FindElement(By.XPath("//mat-slide-toggle[@formcontrolname='isUnionEmployee']//input")); Boolean status = CheckBoxHelper.IsCheckBoxChecked(By.XPath("//mat-slide-toggle[@formcontrolname='isUnionEmployee']//input")); if (status == false) { jse.ExecuteScript("arguments[0].click(); ", element2); } //JavaScriptExecutor.ScrollToAndClick(By.XPath("//*[@id='mat-expansion-panel-header-2']")); IWebElement element1 = ObjectRepository.Driver.FindElement(By.XPath("//*[@id='mat-expansion-panel-header-2']")); jse.ExecuteScript("window.scrollBy(0,-250)", ""); jse.ExecuteScript("arguments[0].click(); ", element1); TextBoxHelper.TypeInTexBox(By.XPath("//input[@formcontrolname='employeePreviousEmployerName']"), "hgdsajas"); Thread.Sleep(10000); }
public void AfterEachStep() { ScenarioBlock scenarioBlock = _scenarioContext.CurrentScenarioBlock; TakeScreenShots ts = new TakeScreenShots(); switch (scenarioBlock) { case ScenarioBlock.Given: if (_scenarioContext.TestError != null) { var mediaEntity = ts.CaptureScreenshotsAndReturnModel(_scenarioContext.ScenarioInfo.Title.Trim()); scenario.CreateNode <Given>(_scenarioContext.StepContext.StepInfo.Text).Fail(_scenarioContext.TestError.Message + "\n" + _scenarioContext.TestError.StackTrace, mediaEntity); } else { scenario.CreateNode <Given>(_scenarioContext.StepContext.StepInfo.Text).Pass(""); } // CreateNode<Given>(); break; case ScenarioBlock.When: if (_scenarioContext.TestError != null) { var mediaEntity = ts.CaptureScreenshotsAndReturnModel(_scenarioContext.ScenarioInfo.Title.Trim()); scenario.CreateNode <When>(_scenarioContext.StepContext.StepInfo.Text).Fail(_scenarioContext.TestError.Message + "\n" + _scenarioContext.TestError.StackTrace, mediaEntity); } else { scenario.CreateNode <When>(_scenarioContext.StepContext.StepInfo.Text).Pass(""); } // CreateNode<When>(); break; case ScenarioBlock.Then: if (_scenarioContext.TestError != null) { var mediaEntity = ts.CaptureScreenshotsAndReturnModel(_scenarioContext.ScenarioInfo.Title.Trim()); scenario.CreateNode <Then>(_scenarioContext.StepContext.StepInfo.Text).Fail(_scenarioContext.TestError.Message + "\n" + _scenarioContext.TestError.StackTrace, mediaEntity); } else { scenario.CreateNode <Then>(_scenarioContext.StepContext.StepInfo.Text).Pass(""); } //CreateNode<Then>(); break; default: if (_scenarioContext.TestError != null) { var mediaEntity = ts.CaptureScreenshotsAndReturnModel(_scenarioContext.ScenarioInfo.Title.Trim()); scenario.CreateNode <And>(_scenarioContext.StepContext.StepInfo.Text).Fail(_scenarioContext.TestError.Message + "\n" + _scenarioContext.TestError.StackTrace, mediaEntity); } else { scenario.CreateNode <And>(_scenarioContext.StepContext.StepInfo.Text).Pass(""); } // CreateNode<And>(); break; } }