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); }
public WebElementWrapper(WebElementWrapper parentElementWrapper, By by) { this._driver = parentElementWrapper.Driver; this.SearchContext = parentElementWrapper; this.by = by; }
public SelectElementWrapper(IWebElement parentElement, By by) { this._element = new WebElementWrapper(parentElement, by); this.by = by; }
public SelectElementWrapper(DriverWrapper driver, By by) { this._element = new WebElementWrapper(driver, by); this.by = by; }