Exemplo n.º 1
0
        /// <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}\""));
        }
Exemplo n.º 2
0
 /// <inheritdoc />
 public Task <IJSHandle> WaitForFunctionAsync(string pageFunction, WaitForFunctionOptions options = null, params object[] args) => throw new NotImplementedException();
Exemplo n.º 3
0
 /// <inheritdoc />
 public Task <IJSHandle> WaitForSelectorEvaluateAsync(
     string selector,
     string script,
     WaitForFunctionOptions options = null,
     params object[] args) => throw new NotImplementedException();
Exemplo n.º 4
0
        internal static Func <IFrameExecutionContext, Task <IJSHandle> > GetWaitForFunctionTask(string selector, string pageFunction, WaitForFunctionOptions options, params object[] args)
        {
            var    polling       = options?.Polling ?? WaitForFunctionPollingOption.Raf;
            string predicateBody = pageFunction.IsJavascriptFunction() ? $"return ({pageFunction})(...args)" : $"return ({pageFunction})";

            if (selector != null)
            {
                selector = NormalizeSelector(selector);
            }

            return(async context => await context.EvaluateHandleAsync(
                       @"(injected, selector, predicateBody, polling, timeout, ...args) => {
                    const innerPredicate = new Function('...args', predicateBody);
                    if (polling === 'raf')
                      return injected.pollRaf(selector, predicate, timeout);
                    if (polling === 'mutation')
                      return injected.pollMutation(selector, predicate, timeout);
                    return injected.pollInterval(selector, polling, predicate, timeout);
                    function predicate(element) {
                      if (selector === undefined)
                        return innerPredicate(...args);
                      return innerPredicate(element, ...args);
                    }
                  }",
                       args.Prepend(await context.GetInjectedAsync().ConfigureAwait(false), selector, predicateBody, polling)).ConfigureAwait(false));
        }
Exemplo n.º 5
0
        /// <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));
        }