Exemplo n.º 1
0
        /// <inheritdoc cref="IFrame.WaitForSelectorAsync(string, WaitForSelectorOptions)"/>
        public async Task <IElementHandle> WaitForSelectorAsync(string selector, WaitForSelectorOptions options = null)
        {
            int timeout    = options?.Timeout ?? Page.DefaultTimeout;
            var visibility = options?.WaitFor ?? WaitForOption.Any;
            var handle     = await WaitForSelectorInUtilityContextAsync(selector, visibility, timeout).ConfigureAwait(false);

            var mainContext = await GetMainContextAsync().ConfigureAwait(false);

            if (handle != null && handle.Context != mainContext)
            {
                var adopted = await Page.Delegate.AdoptElementHandleAsync(handle, mainContext).ConfigureAwait(false);

                await handle.DisposeAsync().ConfigureAwait(false);

                return(adopted);
            }

            return(handle);
        }
Exemplo n.º 2
0
 /// <inheritdoc />
 public Task <IElementHandle> WaitForSelectorAsync(string selector, WaitForSelectorOptions options = null) => throw new NotImplementedException();
Exemplo n.º 3
0
 /// <inheritdoc />
 public Task FillAsync(string selector, string text, WaitForSelectorOptions options = null) => throw new NotImplementedException();
Exemplo n.º 4
0
 /// <inheritdoc />
 public Task <string[]> SelectAsync(string selector, IElementHandle[] values, WaitForSelectorOptions options) => throw new NotImplementedException();
Exemplo n.º 5
0
 /// <inheritdoc />
 public Task <string[]> SelectAsync(string selector, SelectOption value, WaitForSelectorOptions options = null) => throw new NotImplementedException();
Exemplo n.º 6
0
 /// <inheritdoc />
 public Task FocusAsync(string selector, WaitForSelectorOptions options) => throw new NotImplementedException();
Exemplo n.º 7
0
        private async Task <IElementHandle> OptionallyWaitForSelectorInUtilityContextAsync(string selector, WaitForSelectorOptions options)
        {
            var waitFor = options?.WaitFor ?? WaitForOption.Visible;
            int timeout = options?.Timeout ?? Page.DefaultTimeout;

            IElementHandle handle;

            if (waitFor != WaitForOption.NoWait)
            {
                var maybeHandle = await WaitForSelectorInUtilityContextAsync(selector, waitFor, timeout)
                                  .ConfigureAwait(false);

                handle = maybeHandle ?? throw new SelectorException($"No node found for selector", SelectorToString(selector, options.WaitFor));
            }
            else
            {
                var context = await GetContextAsync(ContextType.Utility).ConfigureAwait(false);

                var maybeHandle = await context.QuerySelectorAsync(selector).ConfigureAwait(false);

                if (maybeHandle == null)
                {
                    throw new SelectorException($"No node found for selector", selector);
                }

                handle = maybeHandle !;
            }

            return(handle);
        }
Exemplo n.º 8
0
        private async Task <string[]> SelectInternalAsync(string selector, IEnumerable <object> values, WaitForSelectorOptions options)
        {
            var handle = await OptionallyWaitForSelectorInUtilityContextAsync(selector, options).ConfigureAwait(false) as ElementHandle;

            var result = await handle.SelectInternalAsync(values).ConfigureAwait(false);

            await handle.DisposeAsync().ConfigureAwait(false);

            return(result);
        }
Exemplo n.º 9
0
 /// <inheritdoc />
 public Task <string[]> SelectAsync(string selector, SelectOption[] values, WaitForSelectorOptions options)
 => SelectInternalAsync(selector, values, options);
Exemplo n.º 10
0
 /// <inheritdoc />
 public Task <string[]> SelectAsync(string selector, IElementHandle[] values, WaitForSelectorOptions options)
 => SelectInternalAsync(selector, values, options);
Exemplo n.º 11
0
 /// <inheritdoc />
 public Task <string[]> SelectAsync(string selector, string[] values, WaitForSelectorOptions options)
 => SelectInternalAsync(selector, values.Select(v => new SelectOption {
     Value = v
 }).ToArray(), options);
Exemplo n.º 12
0
 /// <inheritdoc />
 public Task <string[]> SelectAsync(string selector, IElementHandle value, WaitForSelectorOptions options = null)
 => SelectAsync(selector, new[] { value }, options);
Exemplo n.º 13
0
 /// <inheritdoc/>
 public Task <string[]> SelectAsync(string selector, SelectOption value, WaitForSelectorOptions options = null)
 => SelectAsync(selector, new[] { value }, options);
Exemplo n.º 14
0
 /// <inheritdoc />
 public Task <string[]> SelectAsync(string selector, WaitForSelectorOptions options = null)
 => SelectInternalAsync(selector, null, options);
Exemplo n.º 15
0
 /// <inheritdoc cref="IPage.WaitForSelectorEvaluateAsync(string, string, WaitForSelectorOptions, object[])"/>
 public Task <IElementHandle> WaitForSelectorEvaluateAsync(string selector, string script, WaitForSelectorOptions options = null, params object[] args)
 {
     throw new NotImplementedException();
 }