/// <inheritdoc cref="IFrame.WaitForFunctionAsync(string, WaitForFunctionOptions, object[])"/> public Task <IJSHandle> WaitForFunctionAsync(string pageFunction, WaitForFunctionOptions options = null, params object[] args) { options ??= new WaitForFunctionOptions { Timeout = Page.DefaultTimeout }; var task = Dom.GetWaitForFunctionTask(null, pageFunction, options, args); return(ScheduleRerunnableTaskAsync(task, ContextType.Main, options.Timeout, $"Function \"{pageFunction}\"")); }
/// <inheritdoc cref="IFrame.WaitForSelectorEvaluateAsync(string, string, WaitForFunctionOptions, object[])"/> public async Task <IJSHandle> WaitForSelectorEvaluateAsync(string selector, string pageFunction, WaitForFunctionOptions options = null, params object[] args) { options ??= new WaitForFunctionOptions { Timeout = Page.DefaultTimeout }; var task = Dom.GetWaitForFunctionTask(selector, pageFunction, options, args); return(await ScheduleRerunnableTaskAsync(task, ContextType.Main, options.Timeout).ConfigureAwait(false)); }
private async Task <ElementHandle> WaitForSelectorInUtilityContextAsync(string selector, WaitForOption waitFor, int?timeout) { var task = Dom.GetWaitForSelectorFunction(selector, waitFor, timeout); var result = await ScheduleRerunnableTaskAsync(task, ContextType.Utility, timeout, $"selector \"{SelectorToString(selector, waitFor)}\"").ConfigureAwait(false); if (!(result is ElementHandle)) { await result.DisposeAsync().ConfigureAwait(false); return(null); } return(result as ElementHandle); }
public async Task <IElementHandle> QuerySelectorAsync(string selector, IElementHandle scope = null) { var handle = await EvaluateHandleAsync( "(injected, selector, scope) => injected.querySelector(selector, scope || document)", await GetInjectedAsync().ConfigureAwait(false), Dom.NormalizeSelector(selector), scope).ConfigureAwait(false); if (!(handle is ElementHandle)) { await handle.DisposeAsync().ConfigureAwait(false); } return(handle as ElementHandle); }
internal async Task <JSHandle> QuerySelectorArrayAsync(string selector, ElementHandle scope = null) => await EvaluateHandleAsync( "(injected, selector, scope) => injected.querySelectorAll(selector, scope || document)", await GetInjectedAsync().ConfigureAwait(false), Dom.NormalizeSelector(selector), scope).ConfigureAwait(false);