public async Task <JToken> FindElement(string strategy, string expr, string startNode, string notElementId, TimeSpan timeout, CancellationToken cancellationToken = default(CancellationToken)) { try { JToken res = null; var waitEnd = default(DateTime); var nowTime = DateTime.Now; while (true) { res = await FindElementNotWait(strategy, expr, startNode, cancellationToken).ConfigureAwait(false); if (!ResultValueConverter.ValueIsNull(res)) { if (notElementId == null) { break; } else { var elId = GetElementFromResponse(res); if (elId != notElementId) { break; } } } if (waitEnd == default(DateTime)) { var implicitWait = timeout; if (implicitWait == default(TimeSpan)) { implicitWait = await asyncFirefoxDriver.Options.Timeouts.GetImplicitWait().ConfigureAwait(false); } if (implicitWait == default(TimeSpan)) { break; } waitEnd = nowTime + implicitWait; } if (DateTime.Now > waitEnd) { break; } await Task.Delay(50).ConfigureAwait(false); } if (ResultValueConverter.ValueIsNull(res)) { throw new WebBrowserException($"Element not found by {strategy} = {expr}", "no such element"); } return(res); } catch { throw; } }
public async Task <WebSize> GetSize(CancellationToken cancellationToken = default(CancellationToken)) { await asyncFirefoxDriver.CheckConnected(cancellationToken).ConfigureAwait(false); if (asyncFirefoxDriver.ClientMarionette == null) { throw new Exception("error: no clientMarionette"); } var comm1 = new GetWindowSizeCommand(); await asyncFirefoxDriver.ClientMarionette.SendRequestAsync(comm1, cancellationToken).ConfigureAwait(false); if (comm1.Error != null) { throw new WebBrowserException(comm1.Error); } return(ResultValueConverter.ToWebSize(comm1.Result)); }
public async Task <bool> IsElementSelected(string elementId, CancellationToken cancellationToken = default(CancellationToken)) { await asyncFirefoxDriver.CheckConnected(cancellationToken).ConfigureAwait(false); if (asyncFirefoxDriver.ClientMarionette == null) { throw new Exception("error: no clientMarionette"); } var comm1 = new IsElementSelectedCommand(elementId); await asyncFirefoxDriver.ClientMarionette.SendRequestAsync(comm1, cancellationToken).ConfigureAwait(false); if (comm1.Error != null) { throw new WebBrowserException(comm1.Error); } return(ResultValueConverter.ToBool(comm1.Result)); }