Beispiel #1
0
        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>");
                    extent.AddTestFailureScreenshot(browser.getDriver.ScreenCaptureAsBase64String());
                    break;

                case TestStatus.Skipped:
                    extent.SetTestStatusSkipped();
                    break;

                default:
                    extent.SetTestStatusPass();
                    break;
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
            finally
            {
                browser.Close();
            }
        }