/// <summary> /// Returns a web element matching the given method and value /// </summary> private void WaitAnyElementNotPresent(By byAny, int timeout) { RemoteSession session = this.session; string uri = this.uri + "/element"; DateTime endTime = session.GetEndTime(timeout); foreach (By by in (By[])byAny.Value) { if (by == null) { break; } try { string method = By.FormatStrategy(by.Strategy); string value = by.Value.ToString(); session.Send(RequestMethod.POST, uri, "using", method, "value", value); while (true) { if (DateTime.UtcNow > endTime) { throw new Errors.ElementPresentError(byAny); } SysWaiter.Wait(); session.SendAgain(); } } catch (Errors.NoSuchElementError) { } } }
internal static Alert SwitchToAlert(RemoteSession session, int timeout) { string text; try { text = (string)session.Send(RequestMethod.GET, "/alert_text"); } catch (Errors.NoAlertPresentError) { if (timeout == 0) { throw; } DateTime endTime = session.GetEndTime(timeout); while (true) { SysWaiter.Wait(); try { text = (string)session.SendAgain(); break; } catch (Errors.NoAlertPresentError) { if (DateTime.UtcNow > endTime) { throw; } } } } return(new Alert(session, text)); }
private WebElements FindAnyElements(By byAny, int minimum, int timeout) { RemoteSession session = this.session; string uri = this.uri + "/elements"; WebElements webelements = new WebElements(); DateTime endTime = session.GetEndTime(timeout); while (true) { foreach (By by in (By[])byAny.Value) { if (by == null) { break; } var method = By.FormatStrategy(by.Strategy); var value = (string)by.Value; List elements = (List)session.Send(RequestMethod.POST, uri, "using", method, "value", value); webelements.Add(session, elements); } if (webelements.Count >= minimum) { return(webelements); } if (DateTime.UtcNow > endTime) { throw new Errors.NoSuchElementError(byAny); } SysWaiter.Wait(); } }
private WebElement FindAnyElement(By byAny, int timeout) { RemoteSession session = this.session; string relativeUri = this.uri + "/element"; Dictionary element; DateTime endTime = session.GetEndTime(timeout); while (true) { foreach (By by in (By[])byAny.Value) { if (by == null) { break; } try { string method = By.FormatStrategy(by.Strategy); string value = by.Value.ToString(); element = (Dictionary)session.Send(RequestMethod.POST, relativeUri, "using", method, "value", value); return(new WebElement(session, element)); } catch (Errors.NoSuchElementError) { } } if (DateTime.UtcNow > endTime) { throw new Errors.NoSuchElementError(byAny); } SysWaiter.Wait(); } }
/// <summary> /// Returns a web element matching the given method and value or null if no element found /// </summary> private WebElement FindFirstElement(Strategy strategy, string value, int timeout) { RemoteSession session = this.session; string relativeUri = this.uri + "/element"; Dictionary element; try { string method = By.FormatStrategy(strategy); element = (Dictionary)session.Send(RequestMethod.POST, relativeUri, "using", method, "value", value); } catch (Errors.NoSuchElementError) { if (timeout == 0) { throw; } var endTime = session.GetEndTime(timeout); while (true) { SysWaiter.Wait(); try { element = (Dictionary)session.SendAgain(); break; } catch (Errors.NoSuchElementError) { if (DateTime.UtcNow > endTime) { throw; } } } } return(new WebElement(session, element)); }
/// <summary> /// Returns a web element matching the given method and value /// </summary> private void WaitElementNotPresent(Strategy strategy, string value, int timeout) { RemoteSession session = this.session; string uri = this.uri + "/element"; string method = By.FormatStrategy(strategy); DateTime endTime = session.GetEndTime(timeout); try { session.Send(RequestMethod.POST, uri, "using", method, "value", value); while (true) { SysWaiter.Wait(); session.SendAgain(); if (DateTime.UtcNow > endTime) { throw new Errors.ElementPresentError(strategy, value); } } } catch (Errors.NoSuchElementError) { } }
internal static Alert SwitchToAlert(RemoteSession session, int timeout) { string text; try { text = (string)session.Send(RequestMethod.GET, "/alert_text"); } catch (Errors.NoAlertPresentError) { if (timeout == 0) throw; DateTime endTime = session.GetEndTime(timeout); while (true) { SysWaiter.Wait(); try { text = (string)session.SendAgain(); break; } catch (Errors.NoAlertPresentError) { if (DateTime.UtcNow > endTime) throw; } } } return new Alert(session, text); }