public void AfterTest() { 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: extent.SetTestStatusFail($"<br>{errorMessage}<br>Stack Trace: <br>{stacktrace}<br>"); TakeScreenshot.Take(driver); break; case TestStatus.Skipped: extent.SetTestStatusSkipped(); break; default: extent.SetTestStatusPass(); TakeScreenshot.Take(driver); break; } } catch (Exception e) { throw (e); } finally { driver.Quit(); } }