Beispiel #1
0
        /// <summary>
        /// Get the page header text.
        /// </summary>
        /// <returns>
        /// The page header text with leading and trailing whitespace removed.
        /// </returns>
        public string GetHeaderText()
        {
            SeleniumTestUtils.WaitForPresenceOfElement(driver, elementTimeout, By.XPath("//h1"));
            SeleniumTestUtils.HighlightElement(driver, h1);

            return(h1.Text.Trim());
        }
Beispiel #2
0
        public void MenuElementPresenceTest(string menuName)
        {
            try
            {
                // Only navigate to page if necessary.
                if (!String.Equals(WebDriver.Url, Args.AppURL))
                {
                    WebDriver.Navigate().GoToUrl(Args.AppURL);
                }

                SeleniumTestUtils.WaitForPageToLoad(WebDriver, Args.PageTimeout);

                string menuXPath = "//*[@class='cgh-link-tag' and descendant-or-self::text()[normalize-space(.)='" +
                                   menuName + "']]";

                var         wait = new WebDriverWait(WebDriver, Args.ElementTimeout);
                IWebElement menu = wait.Until(
                    SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.XPath(menuXPath)));

                Actions actions = new Actions(WebDriver);
                actions.MoveToElement(menu).Perform();

                SeleniumTestUtils.HighlightElement(WebDriver, menu);

                if (Args.DelayMillis > 0)
                {
                    Thread.Sleep(Args.DelayMillis);
                }
            }
            catch (Exception e)
            {
                Assert.Fail($"Could not find toolbar menu '{menuName}'; reason: '{e.Message}'");
            }
        }
Beispiel #3
0
        /// <summary>
        /// Get the zip code field value.
        /// </summary>
        /// <returns>
        /// A zip code.
        /// </returns>
        public string GetZipCode()
        {
            SeleniumTestUtils.WaitForPresenceOfElement(driver, elementTimeout, By.XPath("//input[@name='zip']"));
            SeleniumTestUtils.HighlightElement(driver, zipCodeInput);

            return(zipCodeInput.GetAttribute("value").Trim());
        }
Beispiel #4
0
        /// <summary>
        /// Select a car model.
        /// </summary>
        /// <param name="model">
        /// The name of the model to select.
        /// </param>
        public void Select_Model(string model)
        {
            var selector = new SelectElement(modelSelector);

            SeleniumTestUtils.HighlightElement(driver, modelSelector);

            selector.SelectByValue(model);
        }
Beispiel #5
0
        /// <summary>
        /// Get the selected car model.
        /// </summary>
        /// <returns>
        /// The name of a car model.
        /// </returns>
        public string GetSelectedModel()
        {
            SeleniumTestUtils.WaitForPresenceOfElement(driver, elementTimeout, By.XPath("//select[@name='model']"));
            SeleniumTestUtils.HighlightElement(driver, modelSelector);

            var selector = new SelectElement(modelSelector);

            return(selector.SelectedOption.Text.Trim());
        }
Beispiel #6
0
        /// <summary>
        /// Type a zip code into the zip code input field.
        /// </summary>
        /// <param name="zip">
        /// The zip code to type.
        /// </param>
        public void Type_ZipCode(string zip)
        {
            SeleniumTestUtils.HighlightElement(driver, zipCodeInput);

            zipCodeInput.Click();

            // clear any previous input
            zipCodeInput.SendKeys(Keys.Control + "a");
            zipCodeInput.SendKeys(Keys.Delete);

            zipCodeInput.SendKeys(zip);
        }
Beispiel #7
0
        /// <summary>
        /// Select a car make.
        /// </summary>
        /// <param name="make">
        /// The name of the make to select.
        /// </param>
        public void Select_Make(string make)
        {
            var selector = new SelectElement(makeSelector);

            SeleniumTestUtils.HighlightElement(driver, makeSelector);

            // work round for selection issues when selecting same make
            selector.SelectByIndex(1);
            selector.SelectByIndex(selector.Options.Count - 1);

            selector.SelectByValue(make);
        }