Esempio n. 1
0
 protected static bool IsElementVisible(PageElement pageElement, TimeSpan?maxWaitTime = null)
 {
     pageElement.GoToFrame();
     return(SeleniumUtility
            .WebDriverWait(ExpectedConditions.ElementIsVisible(pageElement.Locator), maxWaitTime ?? Default5Seconds)
            .Displayed);
 }
Esempio n. 2
0
 protected static void Click(PageElement pageElement, TimeSpan?maxWaitTime = null)
 {
     pageElement.GoToFrame();
     SeleniumUtility
     .WebDriverWait(
         ExpectedConditions.ElementToBeClickable(SeleniumDriver.Driver.FindElement(pageElement.Locator)),
         maxWaitTime).Click();
 }
Esempio n. 3
0
        protected static void RightClick(PageElement pageElement, TimeSpan?maxWaitTime = null)
        {
            pageElement.GoToFrame();
            var actions =
                new OpenQA.Selenium.Interactions.Actions(SeleniumDriver.Driver);

            actions.ContextClick(SeleniumUtility.WebDriverWait(ExpectedConditions.ElementIsVisible(pageElement.Locator),
                                                               maxWaitTime ?? Default5Seconds)).Build().Perform();
        }
Esempio n. 4
0
 protected static void ClickMultipleElements(PageElement pageElement)
 {
     pageElement.GoToFrame();
     foreach (var element in SeleniumDriver.Driver.FindElements(pageElement.Locator))
     {
         SeleniumUtility.WebDriverWait(ExpectedConditions.ElementToBeClickable(element), Default5Seconds)
         .Click();
     }
 }
Esempio n. 5
0
 protected static void DoubleClick(PageElement pageElement, TimeSpan?maxWaitTime = null)
 {
     if (IsElementVisible(pageElement, maxWaitTime ?? Default5Seconds))
     {
         pageElement.GoToFrame();
         new OpenQA.Selenium.Interactions.Actions(SeleniumDriver.Driver)
         .DoubleClick(SeleniumDriver.Driver.FindElement(pageElement.Locator)).Build()
         .Perform();
     }
 }
Esempio n. 6
0
        protected static void ClickAndHold(PageElement pageElement, TimeSpan?maxWaitTime = null)
        {
            pageElement.GoToFrame();
            var actions =
                new OpenQA.Selenium.Interactions.Actions(SeleniumDriver.Driver);
            var onElement = SeleniumDriver.Driver.FindElement(pageElement.Locator);

            actions.ClickAndHold(onElement).Build().Perform();
            Thread.Sleep(maxWaitTime ?? Default5Seconds);
            actions.Release(onElement).Build().Perform();
        }
Esempio n. 7
0
        protected static void Type(PageElement pageElement, string input)
        {
            pageElement.GoToFrame();
            var element =
                SeleniumUtility.WebDriverWait(ExpectedConditions.ElementToBeClickable(pageElement.Locator));

            element.Clear();
            element.SendKeys(input);//

            Assert.AreEqual(input, ExtractText(pageElement, Default5Seconds));
        }
Esempio n. 8
0
        protected static void SendKeys(PageElement pageElement, params string[] keys)
        {
            var actions =
                new OpenQA.Selenium.Interactions.Actions(SeleniumDriver.Driver);

            foreach (var key in keys)
            {
                pageElement.GoToFrame();
                actions.SendKeys(SeleniumDriver.Driver.FindElement(pageElement.Locator), key).Build().Perform();
                Thread.Sleep(1000);
            }
        }
Esempio n. 9
0
        protected static void SelectDropDownByValue(PageElement pageElement, string value)
        {
            pageElement.GoToFrame();
            var dropdown = new SelectElement(SeleniumDriver.Driver.FindElement(pageElement.Locator));

            dropdown.SelectByValue(value);

            var dropdownValue = dropdown.AllSelectedOptions.First(e => e.Selected).GetAttribute("value");

            if (!dropdownValue.Equals(value, StringComparison.CurrentCultureIgnoreCase))
            {
                throw new ValueNotSelectedException($"Dropdown was not set to value: {dropdownValue}");
            }
        }
Esempio n. 10
0
        protected static void SelectDropDownByVisibleText(PageElement pageElement, string visibleText)
        {
            pageElement.GoToFrame();
            var dropdown = new SelectElement(SeleniumDriver.Driver.FindElement(pageElement.Locator));

            dropdown.SelectByText(visibleText);

            var dropdownText = dropdown.AllSelectedOptions.First(e => e.Selected).Text;

            if (!dropdownText.Equals(visibleText))
            {
                throw new ValueNotSelectedException($"Dropdown was not set to value: {dropdownText}");
            }
        }
Esempio n. 11
0
        protected static string ExtractText(PageElement pageElement, TimeSpan?maxWaitTime)
        {
            try
            {
                pageElement.GoToFrame();
                var element = SeleniumUtility.WebDriverWait(
                    ExpectedConditions.ElementIsVisible(pageElement.Locator),
                    maxWaitTime ?? Default5Seconds);

                var text = GetTextByType(pageElement.ElementType, element);

                if (text == null)
                {
                    throw new NotFoundException($"{TextNotFound} Element: {pageElement}");
                }

                return(text);
            }
            catch (Exception e)
            {
                throw new NotFoundException($"Error getting value: {e.StackTrace}");
            }
        }
Esempio n. 12
0
 protected static bool IsElementNotVisible(PageElement pageElement, TimeSpan?maxWaitTime = null)
 {
     pageElement.GoToFrame();
     return(SeleniumUtility.WebDriverWait(ExpectedConditions.InvisibilityOfElementLocated(pageElement.Locator),
                                          maxWaitTime ?? Default5Seconds));
 }