Ejemplo n.º 1
0
 protected static bool IsElementVisible(PageElement pageElement, TimeSpan?maxWaitTime = null)
 {
     pageElement.GoToFrame();
     return(SeleniumUtility
            .WebDriverWait(ExpectedConditions.ElementIsVisible(pageElement.Locator), maxWaitTime ?? Default5Seconds)
            .Displayed);
 }
Ejemplo 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();
 }
Ejemplo 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();
        }
Ejemplo 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();
     }
 }
Ejemplo n.º 5
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));
        }
Ejemplo n.º 6
0
        private string WaitForElementToDisplay(int index, TimeSpan?maxWaitTime = null)
        {
            var locator = $"{this}{AddIndex(index)}";

            if (SeleniumUtility.WebDriverWait(driver => driver.ExecuteJavaScript <string>(locator).IsBlank(),
                                              maxWaitTime ?? Default5Seconds))
            {
                throw new NotFoundException($"Did not find element within {maxWaitTime ?? Default5Seconds}: {locator}");
            }

            return(locator);
        }
Ejemplo n.º 7
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}");
            }
        }
Ejemplo n.º 8
0
 protected static bool IsElementNotVisible(PageElement pageElement, TimeSpan?maxWaitTime = null)
 {
     pageElement.GoToFrame();
     return(SeleniumUtility.WebDriverWait(ExpectedConditions.InvisibilityOfElementLocated(pageElement.Locator),
                                          maxWaitTime ?? Default5Seconds));
 }
Ejemplo n.º 9
0
 public static IWebDriver SwitchToFrame(string name, TimeSpan?maxWaitTime)
 {
     return(SeleniumUtility.WebDriverWait(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(name), maxWaitTime));
 }