Esempio n. 1
0
        public IWebElement FindElement(By by)
        {
            Stopwatch watch = new Stopwatch();

            watch.Start();
            IWebElement result;;

            var element = WrappedElement;

            while (element is IWrapsElement)
            {
                element = ((IWrapsElement)element).WrappedElement;
            }
            RetryingElementLocator retryElementLocator = new RetryingElementLocator(element, ElementWaitTimeout, PollingInterval);
            List <By> locators = new List <By> {
                by
            };

            try
            {
                result = new WebElementWrapper(retryElementLocator.LocateElement(locators));
            }
            catch (StaleElementReferenceException e)
            {
                if (Driver != null && by != null)
                {
                    Logger.Info("Caught exception {0}. Attempting to re-initialize element", e.Message);
                    InitializeElement();
                    retryElementLocator = new RetryingElementLocator(WrappedElement, ElementWaitTimeout, PollingInterval);
                    result = new WebElementWrapper(retryElementLocator.LocateElement(locators));
                }
                else
                {
                    throw;
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
                throw;
            }
            watch.Stop();
            Logger.Info("Found element using the locator {0} in webelement {1}. Time Taken - {2} milliseconds ", by, this, watch.ElapsedMilliseconds);
            return(result);
        }
Esempio n. 2
0
 public WebElementWrapper(WebElementWrapper parentElementWrapper, By by)
 {
     this._driver       = parentElementWrapper.Driver;
     this.SearchContext = parentElementWrapper;
     this.by            = by;
 }
Esempio n. 3
0
 public SelectElementWrapper(IWebElement parentElement, By by)
 {
     this._element = new WebElementWrapper(parentElement, by);
     this.by       = by;
 }
Esempio n. 4
0
 public SelectElementWrapper(DriverWrapper driver, By by)
 {
     this._element = new WebElementWrapper(driver, by);
     this.by       = by;
 }