Example #1
0
        public void GivenPrecondition2()
        {
            extent1.CreateTest("To validate Tshirt purchase scenario end to end");
            webutil.LaunchApp(ConfigurationManager.AppSettings["BaseUrl"]);
            webutil.login("*****@*****.**", "PRACTICE");

            extent1.SetStepStatusPass("GIVEN user is loggged in to the Shopping Portal");
        }
Example #2
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");
            }
        }
        public static bool ControlDisplayed(this IWebElement element, IWebDriver driver, ExtentReportsHelper extentReportsHelper, string elementName, bool displayed = true, uint timeoutInSeconds = 60)
        {
            var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeoutInSeconds));

            wait.IgnoreExceptionTypes(typeof(Exception));
            return(wait.Until(drv =>
            {
                if (!displayed && !element.Displayed || displayed && element.Displayed)
                {
                    extentReportsHelper.SetStepStatusPass($"[{elementName}] is displayed on the page.");
                    return true;
                }
                extentReportsHelper.SetStepStatusPass($"[{elementName}] is displayed on the page.");
                return false;
            }));
        }
Example #4
0
 public void StartUp()
 {
     extent = new ExtentReportsHelper();
     extent.CreateTest(TestContext.CurrentContext.Test.Name);
     ResolveDependency.RegisterAndResolveDependencies();
     Session.StartBrowser();
     extent.SetStepStatusPass("Successfully opened browser session");
 }
 public static void ClickWrapper(this IWebElement element, IWebDriver driver, ExtentReportsHelper extentReportsHelper, string elementName)
 {
     if (element.ElementlIsClickable(driver, extentReportsHelper, elementName))
     {
         element.Click();
         extentReportsHelper.SetStepStatusPass($"Clicked on the element [{elementName}].");
     }
     else
     {
         throw new Exception($"Element [{elementName}] is not displayed");
     }
 }
 public static void ClearWrapper(this IWebElement element, ExtentReportsHelper extentReportsHelper, string elementName)
 {
     element.Clear();
     if (element.Text.Equals(string.Empty))
     {
         extentReportsHelper.SetStepStatusPass($"Cleared element [{elementName}] content.");
     }
     else
     {
         extentReportsHelper.SetStepStatusWarning($"Element [{elementName}] content is not cleared. Element value is [{element.Text}]");
     }
 }
Example #7
0
        public void Init()
        {
            baseURL = ConfigurationManager.AppSettings["url"];
            browser = ConfigurationManager.AppSettings["browser"];
            switch (browser)
            {
            case "Chrome":
                webDriver = new ChromeDriver();
                break;

            case "Firefox":
                webDriver = new FirefoxDriver();
                break;

            default:
                webDriver = new ChromeDriver();
                break;
            }
            extentReportsHelper.SetStepStatusPass("Browser started.");
            webDriver.Manage().Window.Maximize();
            extentReportsHelper.SetStepStatusPass("Browser maximized.");
            Goto(baseURL);
        }
        public static bool ValidatePageTitle(this IWebDriver driver, ExtentReportsHelper extentReportsHelper, string title, uint timeoutInSeconds = 300)
        {
            bool result = false;
            var  wait   = new WebDriverWait(driver, TimeSpan.FromSeconds(timeoutInSeconds));

            wait.IgnoreExceptionTypes(typeof(Exception));
            return(result = wait.Until(drv =>
            {
                if (drv.Title.Contains(title))
                {
                    extentReportsHelper.SetStepStatusPass($"Page title [{drv.Title}] contains [{title}].");
                    return true;
                }
                extentReportsHelper.SetStepStatusWarning($"Page title [{drv.Title}] does not contain [{title}].");
                return false;
            }));
        }
 public static bool ElementlIsClickable(this IWebElement element, IWebDriver driver, ExtentReportsHelper extentReportsHelper, string elementName, uint timeoutInSeconds = 60, bool displayed = true)
 {
     try
     {
         WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeoutInSeconds));
         return(wait.Until(drv =>
         {
             if (WaitHelpers.ExpectedConditions.ElementToBeClickable(element) != null)
             {
                 extentReportsHelper.SetStepStatusPass($"Element [{elementName}] is clickable.");
                 return true;
             }
             extentReportsHelper.SetStepStatusWarning($"Element [{elementName}] is not clickable.");
             return false;
         }));
     }
     catch
     {
         return(false);
     }
 }
 public static void SendKeysWrapper(this IWebElement element, ExtentReportsHelper extentReportsHelper, string value, string elementName)
 {
     element.SendKeys(value);
     extentReportsHelper.SetStepStatusPass($"SendKeys value [{value}] to  element [{elementName}].");
 }
 public static void SetPass(ExtentReportsHelper extentReportsHelper)
 {
     extentReportsHelper.SetStepStatusPass("Hanuman");
 }
Example #12
0
 public void GivenPrecondition1()
 {
     extent1.CreateTest("Validate launch of Scottish Widows Home Page");
     extent1.SetStepStatusPass("GIVEN the guest user knows the url details of Scottish Widows");
 }
Example #13
0
 public void GivenPrecondition1()
 {
     extent1.CreateTest("Validate API response");
     extent1.SetStepStatusPass("Given the user know the api details");
 }