예제 #1
0
        public void Teardown()
        {
            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("Failed", $"<br>{errorMessage}<br>Stack Trace: <br>{stacktrace}<br>");
                    break;

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

                default:
                    extent.SetTestStatusPass();
                    break;
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
            finally
            {
                Session.CloseBrowser();
                extent.SetStepStatusPass("Successfully closed browser");
            }
        }
예제 #2
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();
            }
        }
        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();
            }
        }
예제 #4
0
        public void ThenTestableOutcome1()
        {   //test data has to be parametersied
            //string expectedTitle="Scottish Widows | Pensions | Life insurance | Investments1";
            //have to think something about test data record & steps mapping class
            string expectedTitle = json.GetTestDataValue(1, "ExpectedPageTitle");
            bool   result1       = webutil.ValidatePageTitle(expectedTitle);

            if (result1 == true)
            {
                extent1.SetStepStatusPass("THEN the guest user should be able to see the Scottish Widows Home Page");
                extent1.SetTestStatusPass();
            }
            else
            {
                extent1.SetStepStatusFail("THEN the guest user should be able to see the Scottish Widows Home Page");
                extent1.SetTestStatusFail("The actual page title: '" + webutil.GetPageTitle() + "' is not same as the expected page title:'" + expectedTitle + "' ");
            }
            extent1.Close();
        }
예제 #5
0
 public void ThenTestableOutcome2()
 {
     try
     {
         string expectedTitle = json.GetTestDataValue(1, "ExpectedPageTitle");
         bool   result1       = webutil.ValidatePageTitle(expectedTitle);
         if (result1 == true)
         {
             extent1.SetStepStatusPass("THEN user should be able to see the order confirmation");
             extent1.SetTestStatusPass();
         }
         else
         {
             extent1.SetStepStatusFail("THEN user should be able to see the order confirmation");
         }
         extent1.Close();
     }
     catch (Exception e)
     {
         Console.WriteLine("The exception handled -" + e.ToString());
     }
 }
예제 #6
0
        public void ThenTestableOutcome1()
        {
            bool bRes = false;

            //please update the search text here accoding to api under test
            //we will have to discuss to check how to approach asserts & test passing and failing decision , I personally go with the boolean approach
            //keeping the variable failed as long as we have not done the final validations to make it true
            bRes = p1.ValidatePresenceOfText("Welcome to my rest assured project");
            //extent1.CreateTest(TestContext.CurrentContext.Test.Name);
            if (bRes == true)
            {
                extent1.SetStepStatusPass("Then the user should get desired response");
                extent1.SetTestStatusPass();
            }
            else
            {
                extent1.SetStepStatusFail("Then the user should get desired response");
                extent1.SetTestStatusFail("The searched text is not present in the response body");
            }

            extent1.Close();//to flush and close the extent report
        }
예제 #7
0
        public void SetUpResults(string Status)
        {
            try
            {
                switch (Status)
                {
                case "Failed":
                    extent.SetTestStatusFail();
                    break;

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

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