public async Task <JToken> FindElement(string strategy, string expr, string startNode = null, Session session = null, CancellationToken cancellationToken = new CancellationToken()) { var func = atoms.FIND_ELEMENT; var frameId = session == null ? "" : session.GetCurrentFrameId(); var res = await webView.CallFunction(func, $"{{\"{strategy}\":\"{expr}\"}}"); return(res?.Result?.Value as JToken); }
public async Task <JToken> FindElement(string strategy, string expr, string startNode = null, CancellationToken cancellationToken = new CancellationToken()) { var func = atoms.FIND_ELEMENT; var frameId = _session == null ? "" : _session.GetCurrentFrameId(); expr = Regex.Replace(expr, @"(['""\\#.:;,!?+<>=~*^$|%&@`{}\-/\[\]\(\)])", @"\$1"); var args = $"{{\"{strategy}\":\"{expr}\"}}"; if (startNode != null) { args += $", {{\"{_session.GetElementKey()}\":\"{startNode}\"}}"; } var res = await _webView.CallFunction(func, args, frameId, true, false, cancellationToken).ConfigureAwait(false); var value = res?.Result?.Value as JToken; var exception = ResultValueConverter.ToWebBrowserException(value); if (exception != null) { throw exception; } return(value); }
public async Task <WebPoint> GetElementLocation(string elementId) { var res = await webView.CallFunction(atoms.GET_LOCATION, $"{{\"{GetElementKey()}\":\"{elementId}\"}}"); return(ResultValueConverter.ToWebPoint(res?.Result?.Value)); }
public async Task <WebPoint> GetElementLocation(string elementId, CancellationToken cancellationToken = default(CancellationToken)) { var res = await _webView.CallFunction(atoms.GET_LOCATION, $"{{\"{Session.GetElementKey()}\":\"{elementId}\"}}", _asyncChromeDriver.Session.GetCurrentFrameId(), cancellationToken : cancellationToken).ConfigureAwait(false); return(ResultValueConverter.ToWebPoint(res?.Result?.Value)); }