Beispiel #1
0
        public ILocatedWebElement WaitFor(string selector, string textToContain = "", int seconds = -1)
        {
            if (seconds < 0)
            {
                seconds = WaitSeconds;
            }


            try
            {
                var wait = new WebDriverWait(_instance, new TimeSpan(0, 0, seconds));
                var by   = ElementLocator.HowToGetElement(selector);
                var elem = wait.Until(ExpectedConditions.ElementIsVisible(by));
                if (string.IsNullOrEmpty(textToContain) || elem.Text.Contains(textToContain))
                {
                    return(LocatedWebElement.CreateLocatedWebElement(elem, Locator, Logger, WaitSeconds));
                }
                return(null);
            }
            catch (TimeoutException)
            {
                Trace.TraceWarning("Couldn't find element with selector '{0}' within timeout-span .", selector);
                return(null);
            }
        }
Beispiel #2
0
        public ILocatedWebElement WaitForTextChange(string selector, string message = null, int seconds = -1)
        {
            var wait    = new WebDriverWait(_instance, new TimeSpan(0, 0, seconds));
            var by      = ElementLocator.HowToGetElement(selector);
            var elem    = wait.Until(ExpectedConditions.ElementIsVisible(by));
            var text    = elem.Text;
            var oldText = text;
            var waitSum = 0;

            while (oldText == text && waitSum < WaitSeconds * 1000)
            {
                Thread.Sleep(100);
                waitSum += 100;
                elem     = wait.Until(ExpectedConditions.ElementIsVisible(by));
                text     = elem.Text;
            }
            return(LocatedWebElement.CreateLocatedWebElement(elem, Locator, Logger, WaitSeconds));
        }
Beispiel #3
0
 public LocatedWebElement CreateLocatedWebElement(IWebElement element)
 {
     return(LocatedWebElement.CreateLocatedWebElement(element, Locator, Logger, WaitSeconds));
 }