public void TearDownTest() { try { var status = TestContext.CurrentContext.Result.Outcome.Status; var stacktrace = TestContext.CurrentContext.Result.StackTrace; var errorMessage = "<pre>" + TestContext.CurrentContext.Result.Message + "</pre>"; switch (status) { case TestStatus.Failed: ExtentReportsHelper.GetExtentReportsHelper().SetTestStatusFail($"<br>{errorMessage}<br>Stack Trace: <br>{stacktrace}<br>"); break; case TestStatus.Skipped: ExtentReportsHelper.GetExtentReportsHelper().SetTestStatusSkipped(); break; default: ExtentReportsHelper.GetExtentReportsHelper().SetTestStatusPass(); break; } } catch (Exception exc) { throw (exc); } finally { _client.Dispose(); WebDriverFactory.CloseAllDrivers(); LogHelper.Info("Browser closed."); } }
public void OneTimeTearDownTest() { if (TestContext.CurrentContext.Result.Outcome != ResultState.Success) { Screenshot screenshot = ((ITakesScreenshot)WebDriverFactory.Driver).GetScreenshot(); string filePath = $"{Constants.screenshotdirectory}{DateTime.Now.ToString("yyyyMMdd_HHmm_")}_" + $"{TestContext.CurrentContext.Test.Name}.png"; screenshot.SaveAsFile(filePath, ScreenshotImageFormat.Png); logger.Error(TestContext.CurrentContext.Result.Message); TestContext.AddTestAttachment(filePath); } WebDriverFactory.CloseAllDrivers(); }
public void OneTimeTearDownTest() { WebDriverFactory.CloseAllDrivers(); }
public void TearDown() { WebDriverFactory.CloseAllDrivers(); }