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(); } }