public bool ClickChangesUrl(ByEx byEx) { string oldUrl = WrappedDriver.Url; Click(byEx); WrappedDriver.WaitForUrlToChange(oldUrl, _maxTimeoutMilliseconds); return oldUrl != WrappedDriver.Url; }
public static IWebElement FindElement(this ISearchContext iFind, ByEx byEx) { IWebElement e = null; int tryCount = 0; while ((tryCount < MAX_RETRIES) && e == null) { e = byEx.FilterElements(iFind.FindElements(byEx.By)).FirstOrDefault(); tryCount++; if (e == null) { Thread.Sleep(1000); } } if (e == null) // fail normally with built-in FindElement { if (byEx.GetType() == typeof(ByEx)) { e = iFind.FindElement(byEx.By); } else { // default FindElement(By) won't find it throw new NoSuchElementException(); } } return e; }
public static void WaitForElement(this IWebDriver driver, ByEx byEx) { const int MAX_TIME_MS = 10000; int time_current = 0; var e = driver.FindElementOrNull(byEx); while ((time_current < MAX_TIME_MS) && e == null) { Thread.Sleep(MAX_DELAY_MS); time_current += MAX_DELAY_MS; e = driver.FindElementOrNull(byEx); } int time_delta = Math.Max(0, MAX_TIME_MS - time_current); var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(time_delta)); wait.Until<IWebElement>((d) => { if (e.Displayed && e.Enabled) { return e; } else { return null; } } ); }
public void Clear(ByEx byEx) { TryAgain(() => { Find(byEx).Clear(); return true; }); }
public void ClickInvisible(ByEx byEx) { TryAgain(() => { ((IJavaScriptExecutor)WrappedDriver).ExecuteScript("arguments[0].Click()", Find(byEx)); return true; }); }
public void Click(ByEx byEx) { TryAgain(() => { Find(byEx).Click(); return true; }); WaitForPageLoad(); }
private static IEnumerable<IWebElement> FindAll(ISearchContext iFind, ByEx byEx, int retries, int milliseconds) { var elements = byEx.FilterElements(iFind.FindElements(byEx.By)); while ((retries > 0) && elements.Count() == 0) { Thread.Sleep(milliseconds); elements = byEx.FilterElements(iFind.FindElements(byEx.By)); retries--; } return elements; }
protected void SetFindMethods(ByEx byEx) { FindElementMethod = (ISearchContext context) => { return context.FindElement(byEx); }; FindElementsMethod = (ISearchContext context) => { return (ReadOnlyCollection<IWebElement>)context.FindElements(byEx); }; }
public static SelectElement FindSelect(this ISearchContext iFind, ByEx byEx) { int tryCount = 0; var e = new SelectElement(iFind.FindElement(byEx)); while ((tryCount < MAX_RETRIES) && e == null) { Thread.Sleep(MAX_DELAY_MS); e = new SelectElement(iFind.FindElement(byEx)); tryCount++; } return e; }
public static SelectElement FindSelect(this ISearchContext iFind, ByEx byEx) { int tryCount = 0; var e = new SelectElement(iFind.FindElement(byEx)); while ((tryCount < MAX_RETRIES) && e.Options.Count == 0) { Thread.Sleep(1000); e = new SelectElement(iFind.FindElement(byEx)); tryCount++; } return e; }
public void Select(ByEx byEx, string text) { TryAgain(() => { FindSelect(byEx).SelectByText(text); WaitForPageLoad(); return true; }); }
public static bool HasChild(this ISearchContext iFind, ByEx byEx) { return FindAll(iFind, byEx, 1, 0).Any(e => e.Displayed == true); }
public TableElement FindTable(ByEx byEx) { return WrappedDriver.FindTable(byEx); }
public SelectElement FindSelect(ByEx byEx) { return WrappedDriver.FindSelect(byEx); }
public IEnumerable<IWebElement> FindAll(ByEx byEx) { return WrappedDriver.FindElements(byEx); }
public IWebElement Find(ByEx byEx) { return WrappedDriver.FindElement(byEx); }
public static IEnumerable<IWebElement> FindElements(this ISearchContext iFind, ByEx byEx) { return FindAll(iFind, byEx, MAX_RETRIES, 2000); }
public IEnumerable<IWebElement> FindAll(ByEx byEx) { WrappedDriver.WaitForPageLoad(); return WrappedDriver.FindElements(byEx); }
public CheckListElement(ByEx id, IWebDriver driver) { _id = id; _driver = driver; }
public void Select(ByEx byEx) { TryAgain(() => { Find(byEx).Click(); WaitForPageLoad(); return Find(byEx).Selected; }); }
public bool Displayed(ByEx byEx) { return TryAgain(() => { return Find(byEx).Displayed; }); }
public static IWebElement FindElementOrNull(this ISearchContext iFind, ByEx byEx) { return FindElements(iFind, byEx).FirstOrDefault(); }
public static TableElement FindTable(this ISearchContext iFind, ByEx byEx) { return new TableElement(iFind.FindElement(byEx)); }
public bool Exists(ByEx byEx) { return WrappedDriver.HasChild(byEx); }
public void SendKeys(ByEx byEx, string text) { TryAgain(() => { Find(byEx).SendKeys(text); return true; }); }
public void GivenIGoToTheTestSelectNgOptionPage() { ((IWebDriver)d).Navigate().GoToUrl("file:///" + AppDomain.CurrentDomain.BaseDirectory.Replace("\\", "/") + "/html/slow_select/ngOption.html"); var selectPage = new TestSlowSelectPage(); selectByEx = selectPage.SelectNgOption; }
public void Type(ByEx byEx, string text) { TryAgain(() => { var cachedElement = Find(byEx); cachedElement.Click(); cachedElement.SendKeys(Convert.ToString(ctrlA)); cachedElement.SendKeys(text); return true; }); }
public void Set(ByEx byEx, string text) { switch (byEx.Input) { case Input.Click: Click(byEx); break; case Input.Select: FindSelect(byEx).SelectByText(text); break; case Input.SendKeys: case Input.Upload: SendKeys(byEx, text); break; case Input.Type: Type(byEx, text); break; } }
public IWebElement Find(ByEx byEx) { WrappedDriver.WaitForPageLoad(); return WrappedDriver.FindElement(byEx); }