public void TearDown() { try { if (TestContext.CurrentContext.Result.Outcome == ResultState.Failure) { extentReport.AddTestLog(Status.Fail, "Test case failed, please check logs or screenshots for failure reason"); string testcaseExecutionStartTime = DateUtils.GetCurrentDateAndTime(); string screenshotFile = $"{currentWorkingDirectory}/screenshots/test-{testcaseExecutionStartTime}.jpeg"; screenshotUtils.CaptureAndSaveScreenshot(screenshotFile); extentReport.AddScreenshotInReport(screenshotFile); } extentReport.AddTestLog(Status.Info, "Closing all Browsers"); } catch (Exception ex) { extentReport.AddTestLog(Status.Error, ex.StackTrace); } finally { cmnDriver.CloseAllBrowsers(); } }
public void TearDown() { string currentExecutionTime = DateTime.Now.ToString("yyyy'-'MM'-'dd'T'HH'-'mm'-'ss"); string screenshotFileName = $"{currentProjectDirectory}/screenshots/test-{currentExecutionTime}.jpeg"; if (TestContext.CurrentContext.Result.Outcome == ResultState.Failure) { extentReportUtils.addTestLog(Status.Fail, "One or more step failed"); screenshot.CaptureAndSaveScreenshot(screenshotFileName); extentReportUtils.addScreenshot(screenshotFileName); } CmdDriver.CloseAllBrowser(); }