private WebElementCollection findElements(OpenQA.Selenium.By by, int timeoutms) { try { if (timeoutms < 1) return new WebElementCollection(this._wd, _webElement.FindElements(by)); return new WebElementCollection(this._wd, this._wd.WaitNotNullOrTrue(() => { var elts = _webElement.FindElements(by); return elts.Count == 0 ? null : elts; }, timeoutms)); } catch (Exception ex) { if (ex is NoSuchElementException || ex is TimeoutException) throw new Exception("Elements not found. " + "Method=" + by.ToString().ToLower().Substring(3).Replace(": ", ", value=")); throw; } }
private WebElement findElement(OpenQA.Selenium.By by, int timeoutms, bool raise) { try { if (timeoutms < 1) return new WebElement(this._wd,_webElement.FindElement(by)); return new WebElement(this._wd, this._wd.WaitNoException(() => _webElement.FindElement(by), timeoutms)); } catch (Exception ex) { if (ex is NoSuchElementException || ex is TimeoutException) { if(raise) throw new Exception("Element not found. " + "Method=" + by.ToString().ToLower().Substring(3).Replace(": ", ", value=")); return null; } throw; } }