Beispiel #1
0
 public void ExtentFlush()
 {
     try
     {
         test = extent.CreateTest(TestContext.CurrentContext.Test.Name).Info("Test Started");
         var error = TestContext.CurrentContext.Result.Message;
         if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Failed)
         {
             log.Error(TestContext.CurrentContext.Test.Name + "Failed");
             test.Log(Status.Info, error);
             string path = Screenshot.Capture(driver, TestContext.CurrentContext.Test.Name + "   " + "Failed");
             test.AddScreenCaptureFromPath(path);
             test.Fail(MarkupHelper.CreateLabel(TestContext.CurrentContext.Test.Name, ExtentColor.Red));
             test.Log(Status.Fail, "Test Failed");
             log.Error("Test Failed");
             SendEmailMain.SendEmail(error, TestContext.CurrentContext.Result.StackTrace);
         }
         else if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Passed)
         {
             log.Info(TestContext.CurrentContext.Test.Name + "Passed");
             test.Pass(MarkupHelper.CreateLabel(TestContext.CurrentContext.Test.Name, ExtentColor.Green));
             test.Log(Status.Pass, "Test pass");
             log.Info(TestContext.CurrentContext.Test.Name + "Test Completed");
         }
         extent.Flush();
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
Beispiel #2
0
        public void ExtentFlush()
        {
            test = extent.CreateTest(TestContext.CurrentContext.Test.Name).Info("Test Started");
            var error = TestContext.CurrentContext.Result.Message;

            if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Failed)
            {
                test.Log(Status.Info, error);
                string path = Screenshot.Capture(driver, TestContext.CurrentContext.Test.Name + "   " + "Failed");
                test.AddScreenCaptureFromPath(path);
                test.Fail(MarkupHelper.CreateLabel(TestContext.CurrentContext.Test.Name, ExtentColor.Red));
                test.Log(Status.Fail, "Test Failed");
                log.Error("Test Failed");
                SendEmailMain.SendEmail(error, TestContext.CurrentContext.Result.StackTrace);
            }
            else if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Passed)
            {
                string path = Screenshot.Capture(driver, TestContext.CurrentContext.Test.Name);
                test.AddScreenCaptureFromPath(path);
                test.Pass(MarkupHelper.CreateLabel(TestContext.CurrentContext.Test.Name, ExtentColor.Green));
                test.Log(Status.Pass, "Test pass");
            }
            driver.Navigate().Refresh(); // every test must refresh the webpage ..use in negative test
            extent.Flush();
        }