How to use FrameSetContentOptions method of Microsoft.Playwright.FrameSetContentOptions class

Best Playwright-dotnet code snippet using Microsoft.Playwright.FrameSetContentOptions.FrameSetContentOptions

Run Playwright-dotnet automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

FrameSetContentOptions.cs

Source: FrameSetContentOptions.cs Github

copy
1/*
2 * MIT License
3 *
4 * Copyright (c) Microsoft Corporation.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
25using System;
26using System.Collections.Generic;
27using System.ComponentModel.DataAnnotations;
28using System.Drawing;
29using System.Globalization;
30using System.IO;
31using System.Runtime.Serialization;
32using System.Text.Json;
33using System.Text.Json.Serialization;
34using System.Text.RegularExpressions;
35using System.Threading;
36using System.Threading.Tasks;
37
38#nullable enable
39
40namespace Microsoft.Playwright
41{
42    public class FrameSetContentOptions
43    {
44        public FrameSetContentOptions() { }
45
46        public FrameSetContentOptions(FrameSetContentOptions clone)
47        {
48            if (clone == null)
49            {
50                return;
51            }
52
53            Timeout = clone.Timeout;
54            WaitUntil = clone.WaitUntil;
55        }
56
57        /// <summary>
58        /// <para>
59        /// Maximum operation time in milliseconds, defaults to 30 seconds, pass <c>0</c> to
60        /// disable timeout. The default value can be changed by using the <see cref="IBrowserContext.SetDefaultNavigationTimeout"/>,
61        /// <see cref="IBrowserContext.SetDefaultTimeout"/>, <see cref="IPage.SetDefaultNavigationTimeout"/>
62        /// or <see cref="IPage.SetDefaultTimeout"/> methods.
63        /// </para>
64        /// </summary>
65        [JsonPropertyName("timeout")]
66        public float? Timeout { get; set; }
67
68        /// <summary>
69        /// <para>When to consider operation succeeded, defaults to <c>load</c>. Events can be either:</para>
70        /// <list type="bullet">
71        /// <item><description>
72        /// <c>'domcontentloaded'</c> - consider operation to be finished when the <c>DOMContentLoaded</c>
73        /// event is fired.
74        /// </description></item>
75        /// <item><description>
76        /// <c>'load'</c> - consider operation to be finished when the <c>load</c> event is
77        /// fired.
78        /// </description></item>
79        /// <item><description>
80        /// <c>'networkidle'</c> - consider operation to be finished when there are no network
81        /// connections for at least <c>500</c> ms.
82        /// </description></item>
83        /// <item><description>
84        /// <c>'commit'</c> - consider operation to be finished when network response is received
85        /// and the document started loading.
86        /// </description></item>
87        /// </list>
88        /// </summary>
89        [JsonPropertyName("waitUntil")]
90        public WaitUntilState? WaitUntil { get; set; }
91    }
92}
93
94#nullable disable
95
Full Screen

Frame.cs

Source: Frame.cs Github

copy
1/*
2 * MIT License
3 *
4 * Copyright (c) 2020 Darío Kondratiuk
5 * Copyright (c) 2020 Meir Blachman
6 * Modifications copyright (c) Microsoft Corporation.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in all
16 * copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 * SOFTWARE.
25 */
26using System;
27using System.Collections.Generic;
28using System.IO;
29using System.Linq;
30using System.Text.Json;
31using System.Text.RegularExpressions;
32using System.Threading.Tasks;
33using Microsoft.Playwright.Helpers;
34using Microsoft.Playwright.Transport;
35using Microsoft.Playwright.Transport.Channels;
36using Microsoft.Playwright.Transport.Protocol;
37
38namespace Microsoft.Playwright.Core
39{
40    internal class Frame : ChannelOwnerBase, IChannelOwner<Frame>, IFrame
41    {
42        internal readonly FrameChannel _channel;
43        private readonly List<WaitUntilState> _loadStates = new();
44
45        internal Frame(IChannelOwner parent, string guid, FrameInitializer initializer) : base(parent, guid)
46        {
47            _channel = new(guid, parent.Connection, this);
48            Url = initializer.Url;
49            Name = initializer.Name;
50            ParentFrame = initializer.ParentFrame;
51            _loadStates = initializer.LoadStates;
52
53            _channel.LoadState += (_, e) =>
54            {
55                lock (_loadStates)
56                {
57                    if (e.Add.HasValue)
58                    {
59                        _loadStates.Add(e.Add.Value);
60                        LoadState?.Invoke(this, e.Add.Value);
61                    }
62
63                    if (e.Remove.HasValue)
64                    {
65                        _loadStates.Remove(e.Remove.Value);
66                    }
67                }
68            };
69
70            _channel.Navigated += (_, e) =>
71            {
72                Url = e.Url;
73                Name = e.Name;
74                Navigated?.Invoke(this, e);
75
76                if (string.IsNullOrEmpty(e.Error))
77                {
78                    ((Page)Page)?.OnFrameNavigated(this);
79                }
80            };
81        }
82
83        /// <summary>
84        /// Raised when a navigation is received.
85        /// </summary>
86        public event EventHandler<FrameNavigatedEventArgs> Navigated;
87
88        /// <summary>
89        /// Raised when a new LoadState was added.
90        /// </summary>
91        public event EventHandler<WaitUntilState> LoadState;
92
93        ChannelBase IChannelOwner.Channel => _channel;
94
95        IChannel<Frame> IChannelOwner<Frame>.Channel => _channel;
96
97        public IReadOnlyList<IFrame> ChildFrames => ChildFramesList;
98
99        public string Name { get; internal set; }
100
101        public string Url { get; internal set; }
102
103        IFrame IFrame.ParentFrame => ParentFrame;
104
105        public Frame ParentFrame { get; }
106
107        public IPage Page { get; internal set; }
108
109        public bool IsDetached { get; internal set; }
110
111        internal List<Frame> ChildFramesList { get; } = new();
112
113        public async Task<IElementHandle> FrameElementAsync()
114            => (await _channel.FrameElementAsync().ConfigureAwait(false)).Object;
115
116        public IFrameLocator FrameLocator(string selector)
117            => new FrameLocator(this, selector);
118
119        public Task<string> TitleAsync() => _channel.TitleAsync();
120
121        public Task WaitForTimeoutAsync(float timeout)
122            => _channel.WaitForTimeoutAsync(timeout);
123
124        public Task<IReadOnlyList<string>> SelectOptionAsync(string selector, string values, FrameSelectOptionOptions options = default)
125            => SelectOptionAsync(selector, new[] { values }, options);
126
127        public Task<IReadOnlyList<string>> SelectOptionAsync(string selector, IEnumerable<string> values, FrameSelectOptionOptions options = default)
128            => SelectOptionAsync(selector, values.Select(x => new SelectOptionValue() { Value = x }), options);
129
130        public Task<IReadOnlyList<string>> SelectOptionAsync(string selector, IElementHandle values, FrameSelectOptionOptions options = default)
131            => SelectOptionAsync(selector, new[] { values }, options);
132
133        public async Task<IReadOnlyList<string>> SelectOptionAsync(string selector, IEnumerable<IElementHandle> values, FrameSelectOptionOptions options = default)
134            => (await _channel.SelectOptionAsync(
135                selector,
136                values.Select(x => x as ElementHandle),
137                noWaitAfter: options?.NoWaitAfter,
138                strict: options?.Strict,
139                force: options?.Force,
140                timeout: options?.Timeout).ConfigureAwait(false)).ToList().AsReadOnly();
141
142        public Task<IReadOnlyList<string>> SelectOptionAsync(string selector, SelectOptionValue values, FrameSelectOptionOptions options = default)
143            => SelectOptionAsync(selector, new[] { values }, options);
144
145        public async Task<IReadOnlyList<string>> SelectOptionAsync(string selector, IEnumerable<SelectOptionValue> values, FrameSelectOptionOptions options = default)
146            => (await _channel.SelectOptionAsync(
147                selector,
148                values,
149                noWaitAfter: options?.NoWaitAfter,
150                strict: options?.Strict,
151                force: options?.Force,
152                timeout: options?.Timeout).ConfigureAwait(false)).ToList().AsReadOnly();
153
154        public async Task WaitForLoadStateAsync(LoadState? state = default, FrameWaitForLoadStateOptions options = default)
155        {
156            Task<WaitUntilState> task;
157            Waiter waiter = null;
158            WaitUntilState loadState = Microsoft.Playwright.WaitUntilState.Load;
159            switch (state)
160            {
161                case Microsoft.Playwright.LoadState.Load:
162                    loadState = Microsoft.Playwright.WaitUntilState.Load;
163                    break;
164                case Microsoft.Playwright.LoadState.DOMContentLoaded:
165                    loadState = Microsoft.Playwright.WaitUntilState.DOMContentLoaded;
166                    break;
167                case Microsoft.Playwright.LoadState.NetworkIdle:
168                    loadState = Microsoft.Playwright.WaitUntilState.NetworkIdle;
169                    break;
170            }
171            try
172            {
173                lock (_loadStates)
174                {
175                    if (_loadStates.Contains(loadState))
176                    {
177                        return;
178                    }
179
180                    waiter = SetupNavigationWaiter("frame.WaitForLoadStateAsync", options?.Timeout);
181                    task = waiter.WaitForEventAsync<WaitUntilState>(this, "LoadState", s =>
182                    {
183                        waiter.Log($"  \"{s}\" event fired");
184                        return s == loadState;
185                    });
186                }
187
188                await task.ConfigureAwait(false);
189            }
190            finally
191            {
192                waiter?.Dispose();
193            }
194        }
195
196        public async Task<IResponse> WaitForNavigationAsync(FrameWaitForNavigationOptions options = default)
197        {
198            WaitUntilState waitUntil2 = options?.WaitUntil ?? WaitUntilState.Load;
199            using var waiter = SetupNavigationWaiter("frame.WaitForNavigationAsync", options?.Timeout);
200            string toUrl = !string.IsNullOrEmpty(options?.UrlString) ? $" to \"{options?.UrlString}\"" : string.Empty;
201
202            waiter.Log($"waiting for navigation{toUrl} until \"{waitUntil2}\"");
203
204            var navigatedEventTask = waiter.WaitForEventAsync<FrameNavigatedEventArgs>(
205                this,
206                "Navigated",
207                e =>
208                {
209                    // Any failed navigation results in a rejection.
210                    if (e.Error != null)
211                    {
212                        return true;
213                    }
214
215                    waiter.Log($"  navigated to \"{e.Url}\"");
216                    return UrlMatches(e.Url, options?.UrlString, options?.UrlRegex, options?.UrlFunc);
217                });
218
219            var navigatedEvent = await navigatedEventTask.ConfigureAwait(false);
220
221            if (navigatedEvent.Error != null)
222            {
223                var ex = new PlaywrightException(navigatedEvent.Error);
224                await waiter.WaitForPromiseAsync(Task.FromException<object>(ex)).ConfigureAwait(false);
225            }
226
227            if (!_loadStates.Select(s => s.ToValueString()).Contains(waitUntil2.ToValueString()))
228            {
229                await waiter.WaitForEventAsync<WaitUntilState>(
230                    this,
231                    "LoadState",
232                    e =>
233                    {
234                        waiter.Log($"  \"{e}\" event fired");
235                        return e.ToValueString() == waitUntil2.ToValueString();
236                    }).ConfigureAwait(false);
237            }
238
239            var request = navigatedEvent.NewDocument?.Request?.Object;
240            var response = request != null
241                ? await waiter.WaitForPromiseAsync(request.FinalRequest.ResponseAsync()).ConfigureAwait(false)
242                : null;
243
244            return response;
245        }
246
247        public async Task<IResponse> RunAndWaitForNavigationAsync(Func<Task> action, FrameRunAndWaitForNavigationOptions options = default)
248        {
249            var result = WaitForNavigationAsync(new()
250            {
251                UrlString = options?.UrlString,
252                UrlRegex = options?.UrlRegex,
253                UrlFunc = options?.UrlFunc,
254                WaitUntil = options?.WaitUntil,
255                Timeout = options?.Timeout,
256            });
257            if (action != null)
258            {
259                await WrapApiBoundaryAsync(() => Task.WhenAll(result, action())).ConfigureAwait(false);
260            }
261
262            return await result.ConfigureAwait(false);
263        }
264
265        public Task TapAsync(string selector, FrameTapOptions options = default)
266            => _channel.TapAsync(
267                selector,
268                modifiers: options?.Modifiers,
269                position: options?.Position,
270                timeout: options?.Timeout,
271                force: options?.Force,
272                noWaitAfter: options?.NoWaitAfter,
273                trial: options?.Trial,
274                strict: options?.Strict);
275
276        internal Task<int> QueryCountAsync(string selector)
277            => _channel.QueryCountAsync(selector);
278
279        public Task<string> ContentAsync() => _channel.ContentAsync();
280
281        public Task FocusAsync(string selector, FrameFocusOptions options = default)
282            => _channel.FocusAsync(selector, options?.Timeout, options?.Strict);
283
284        public Task TypeAsync(string selector, string text, FrameTypeOptions options = default)
285            => _channel.TypeAsync(
286                selector,
287                text,
288                delay: options?.Delay,
289                timeout: options?.Timeout,
290                noWaitAfter: options?.NoWaitAfter,
291                strict: options?.Strict);
292
293        public Task<string> GetAttributeAsync(string selector, string name, FrameGetAttributeOptions options = default)
294            => _channel.GetAttributeAsync(selector, name, options?.Timeout, options?.Strict);
295
296        public Task<string> InnerHTMLAsync(string selector, FrameInnerHTMLOptions options = default)
297            => _channel.InnerHTMLAsync(selector, options?.Timeout, options?.Strict);
298
299        public Task<string> InnerTextAsync(string selector, FrameInnerTextOptions options = default)
300            => _channel.InnerTextAsync(selector, options?.Timeout, options?.Strict);
301
302        public Task<string> TextContentAsync(string selector, FrameTextContentOptions options = default)
303            => _channel.TextContentAsync(selector, options?.Timeout, options?.Strict);
304
305        public Task HoverAsync(string selector, FrameHoverOptions options = default)
306            => _channel.HoverAsync(
307                selector,
308                position: options?.Position,
309                modifiers: options?.Modifiers,
310                force: options?.Force,
311                timeout: options?.Timeout,
312                trial: options?.Trial,
313                strict: options?.Strict);
314
315        public Task PressAsync(string selector, string key, FramePressOptions options = default)
316            => _channel.PressAsync(
317                selector,
318                key,
319                delay: options?.Delay,
320                timeout: options?.Timeout,
321                noWaitAfter: options?.NoWaitAfter,
322                strict: options?.Strict);
323
324        public Task DispatchEventAsync(string selector, string type, object eventInit = default, FrameDispatchEventOptions options = default)
325            => _channel.DispatchEventAsync(
326                    selector,
327                    type,
328                    ScriptsHelper.SerializedArgument(eventInit),
329                    options?.Timeout,
330                    options?.Strict);
331
332        public Task FillAsync(string selector, string value, FrameFillOptions options = default)
333            => _channel.FillAsync(selector, value, force: options?.Force, timeout: options?.Timeout, noWaitAfter: options?.NoWaitAfter, options?.Strict);
334
335        public async Task<IElementHandle> AddScriptTagAsync(FrameAddScriptTagOptions options = default)
336        {
337            var content = options?.Content;
338            if (!string.IsNullOrEmpty(options?.Path))
339            {
340                content = File.ReadAllText(options.Path);
341                content += "//# sourceURL=" + options.Path.Replace("\n", string.Empty);
342            }
343
344            return (await _channel.AddScriptTagAsync(options?.Url, options?.Path, content, options?.Type).ConfigureAwait(false)).Object;
345        }
346
347        public async Task<IElementHandle> AddStyleTagAsync(FrameAddStyleTagOptions options = default)
348        {
349            var content = options?.Content;
350            if (!string.IsNullOrEmpty(options?.Path))
351            {
352                content = File.ReadAllText(options.Path);
353                content += "//# sourceURL=" + options.Path.Replace("\n", string.Empty);
354            }
355
356            return (await _channel.AddStyleTagAsync(options?.Url, options?.Path, content).ConfigureAwait(false)).Object;
357        }
358
359        public Task SetInputFilesAsync(string selector, string files, FrameSetInputFilesOptions options = default)
360            => SetInputFilesAsync(selector, new[] { files }, options);
361
362        public async Task SetInputFilesAsync(string selector, IEnumerable<string> files, FrameSetInputFilesOptions options = default)
363        {
364            var converted = await SetInputFilesHelpers.ConvertInputFilesAsync(files, (BrowserContext)Page.Context).ConfigureAwait(false);
365            if (converted.Files != null)
366            {
367                await _channel.SetInputFilesAsync(selector, converted.Files, options?.NoWaitAfter, options?.Timeout, options?.Strict).ConfigureAwait(false);
368            }
369            else
370            {
371                await _channel.SetInputFilePathsAsync(selector, converted?.LocalPaths, converted?.Streams, options?.NoWaitAfter, options?.Timeout, options?.Strict).ConfigureAwait(false);
372            }
373        }
374
375        public Task SetInputFilesAsync(string selector, FilePayload files, FrameSetInputFilesOptions options = default)
376            => SetInputFilesAsync(selector, new[] { files }, options);
377
378        public async Task SetInputFilesAsync(string selector, IEnumerable<FilePayload> files, FrameSetInputFilesOptions options = default)
379        {
380            var converted = SetInputFilesHelpers.ConvertInputFiles(files);
381            await _channel.SetInputFilesAsync(selector, converted.Files, noWaitAfter: options?.NoWaitAfter, timeout: options?.Timeout, options?.Strict).ConfigureAwait(false);
382        }
383
384        public Task ClickAsync(string selector, FrameClickOptions options = default)
385            => _channel.ClickAsync(
386                selector,
387                delay: options?.Delay,
388                button: options?.Button,
389                clickCount: options?.ClickCount,
390                modifiers: options?.Modifiers,
391                position: options?.Position,
392                timeout: options?.Timeout,
393                force: options?.Force,
394                noWaitAfter: options?.NoWaitAfter,
395                trial: options?.Trial,
396                strict: options?.Strict);
397
398        public Task DblClickAsync(string selector, FrameDblClickOptions options = default)
399            => _channel.DblClickAsync(
400                selector,
401                delay: options?.Delay,
402                button: options?.Button,
403                position: options?.Position,
404                modifiers: options?.Modifiers,
405                timeout: options?.Timeout,
406                force: options?.Force,
407                noWaitAfter: options?.NoWaitAfter,
408                trial: options?.Trial,
409                strict: options?.Strict);
410
411        public Task CheckAsync(string selector, FrameCheckOptions options = default)
412            => _channel.CheckAsync(
413                selector,
414                position: options?.Position,
415                timeout: options?.Timeout,
416                force: options?.Force,
417                noWaitAfter: options?.NoWaitAfter,
418                trial: options?.Trial,
419                strict: options?.Strict);
420
421        public Task UncheckAsync(string selector, FrameUncheckOptions options = default)
422            => _channel.UncheckAsync(
423                selector,
424                position: options?.Position,
425                timeout: options?.Timeout,
426                force: options?.Force,
427                noWaitAfter: options?.NoWaitAfter,
428                trial: options?.Trial,
429                strict: options?.Strict);
430
431        public Task SetCheckedAsync(string selector, bool checkedState, FrameSetCheckedOptions options = null)
432            => checkedState ?
433            _channel.CheckAsync(
434                selector,
435                position: options?.Position,
436                timeout: options?.Timeout,
437                force: options?.Force,
438                noWaitAfter: options?.NoWaitAfter,
439                trial: options?.Trial,
440                strict: options?.Strict)
441            : _channel.UncheckAsync(
442                selector,
443                position: options?.Position,
444                timeout: options?.Timeout,
445                force: options?.Force,
446                noWaitAfter: options?.NoWaitAfter,
447                trial: options?.Trial,
448                strict: options?.Strict);
449
450        public Task SetContentAsync(string html, FrameSetContentOptions options = default)
451            => _channel.SetContentAsync(html, timeout: options?.Timeout, waitUntil: options?.WaitUntil);
452
453        public Task<string> InputValueAsync(string selector, FrameInputValueOptions options = null)
454            => _channel.InputValueAsync(selector, options?.Timeout, options?.Strict);
455
456        public async Task<IElementHandle> QuerySelectorAsync(string selector)
457            => (await _channel.QuerySelectorAsync(selector).ConfigureAwait(false))?.Object;
458
459        public async Task<IReadOnlyList<IElementHandle>> QuerySelectorAllAsync(string selector)
460            => (await _channel.QuerySelectorAllAsync(selector).ConfigureAwait(false)).Select(c => ((ElementHandleChannel)c).Object).ToList().AsReadOnly();
461
462        public async Task<IJSHandle> WaitForFunctionAsync(string expression, object arg = default, FrameWaitForFunctionOptions options = default)
463             => (await _channel.WaitForFunctionAsync(
464                expression: expression,
465                arg: ScriptsHelper.SerializedArgument(arg),
466                timeout: options?.Timeout,
467                polling: options?.PollingInterval).ConfigureAwait(false)).Object;
468
469        public async Task<IElementHandle> WaitForSelectorAsync(string selector, FrameWaitForSelectorOptions options = default)
470            => (await _channel.WaitForSelectorAsync(
471                selector: selector,
472                state: options?.State,
473                timeout: options?.Timeout,
474                strict: options?.Strict,
475                omitReturnValue: false).ConfigureAwait(false))?.Object;
476
477        public async Task<IElementHandle> LocatorWaitForAsync(string selector, LocatorWaitForOptions options = default)
478            => (await _channel.WaitForSelectorAsync(
479                selector: selector,
480                state: options?.State,
481                timeout: options?.Timeout,
482                strict: true,
483                omitReturnValue: true).ConfigureAwait(false))?.Object;
484
485        public async Task<IJSHandle> EvaluateHandleAsync(string script, object args = null)
486            => (await _channel.EvaluateExpressionHandleAsync(
487                script,
488                arg: ScriptsHelper.SerializedArgument(args)).ConfigureAwait(false))?.Object;
489
490        public async Task<JsonElement?> EvaluateAsync(string script, object arg = null)
491            => ScriptsHelper.ParseEvaluateResult<JsonElement?>(await _channel.EvaluateExpressionAsync(
492                script,
493                arg: ScriptsHelper.SerializedArgument(arg)).ConfigureAwait(false));
494
495        public async Task<T> EvaluateAsync<T>(string script, object arg = null)
496            => ScriptsHelper.ParseEvaluateResult<T>(await _channel.EvaluateExpressionAsync(
497                script,
498                arg: ScriptsHelper.SerializedArgument(arg)).ConfigureAwait(false));
499
500        public async Task<JsonElement?> EvalOnSelectorAsync(string selector, string script, object arg = null)
501            => ScriptsHelper.ParseEvaluateResult<JsonElement?>(await _channel.EvalOnSelectorAsync(
502                selector: selector,
503                script,
504                arg: ScriptsHelper.SerializedArgument(arg),
505                strict: null).ConfigureAwait(false));
506
507        public async Task<T> EvalOnSelectorAsync<T>(string selector, string script, object arg = null)
508            => ScriptsHelper.ParseEvaluateResult<T>(await _channel.EvalOnSelectorAsync(
509                selector: selector,
510                script,
511                arg: ScriptsHelper.SerializedArgument(arg),
512                strict: null).ConfigureAwait(false));
513
514        public async Task<T> EvalOnSelectorAsync<T>(string selector, string expression, object arg = null, FrameEvalOnSelectorOptions options = null)
515            => ScriptsHelper.ParseEvaluateResult<T>(await _channel.EvalOnSelectorAsync(
516                selector: selector,
517                expression,
518                arg: ScriptsHelper.SerializedArgument(arg),
519                strict: options?.Strict).ConfigureAwait(false));
520
521        public async Task<JsonElement?> EvalOnSelectorAllAsync(string selector, string script, object arg = null)
522            => ScriptsHelper.ParseEvaluateResult<JsonElement?>(await _channel.EvalOnSelectorAllAsync(
523                selector: selector,
524                script,
525                arg: ScriptsHelper.SerializedArgument(arg)).ConfigureAwait(false));
526
527        public async Task<T> EvalOnSelectorAllAsync<T>(string selector, string script, object arg = null)
528            => ScriptsHelper.ParseEvaluateResult<T>(await _channel.EvalOnSelectorAllAsync(
529                selector: selector,
530                script,
531                arg: ScriptsHelper.SerializedArgument(arg)).ConfigureAwait(false));
532
533        public ILocator Locator(string selector, FrameLocatorOptions options = null) => new Locator(this, selector, new() { HasTextRegex = options?.HasTextRegex, HasTextString = options?.HasTextString, Has = options?.Has });
534
535        public async Task<IElementHandle> QuerySelectorAsync(string selector, FrameQuerySelectorOptions options = null)
536            => (await _channel.QuerySelectorAsync(selector, options?.Strict).ConfigureAwait(false))?.Object;
537
538        public async Task<IResponse> GotoAsync(string url, FrameGotoOptions options = default)
539            => (await _channel.GotoAsync(
540                url,
541                timeout: options?.Timeout,
542                waitUntil: options?.WaitUntil,
543                referer: options?.Referer).ConfigureAwait(false))?.Object;
544
545        public Task<bool> IsCheckedAsync(string selector, FrameIsCheckedOptions options = default)
546            => _channel.IsCheckedAsync(selector, timeout: options?.Timeout, options?.Strict);
547
548        public Task<bool> IsDisabledAsync(string selector, FrameIsDisabledOptions options = default)
549            => _channel.IsDisabledAsync(selector, timeout: options?.Timeout, options?.Strict);
550
551        public Task<bool> IsEditableAsync(string selector, FrameIsEditableOptions options = default)
552            => _channel.IsEditableAsync(selector, timeout: options?.Timeout, options?.Strict);
553
554        public Task<bool> IsEnabledAsync(string selector, FrameIsEnabledOptions options = default)
555            => _channel.IsEnabledAsync(selector, timeout: options?.Timeout, options?.Strict);
556
557#pragma warning disable CS0612 // Type or member is obsolete
558        public Task<bool> IsHiddenAsync(string selector, FrameIsHiddenOptions options = default)
559            => _channel.IsHiddenAsync(selector, timeout: options?.Timeout, options?.Strict);
560
561        public Task<bool> IsVisibleAsync(string selector, FrameIsVisibleOptions options = default)
562            => _channel.IsVisibleAsync(selector, timeout: options?.Timeout, options?.Strict);
563#pragma warning restore CS0612 // Type or member is obsolete
564
565        public Task WaitForURLAsync(string url, FrameWaitForURLOptions options = default)
566            => WaitForURLAsync(url, null, null, options);
567
568        public Task WaitForURLAsync(Regex url, FrameWaitForURLOptions options = default)
569            => WaitForURLAsync(null, url, null, options);
570
571        public Task WaitForURLAsync(Func<string, bool> url, FrameWaitForURLOptions options = default)
572            => WaitForURLAsync(null, null, url, options);
573
574        public Task DragAndDropAsync(string source, string target, FrameDragAndDropOptions options = null)
575            => _channel.DragAndDropAsync(source, target, options?.Force, options?.NoWaitAfter, options?.Timeout, options?.Trial, options?.Strict);
576
577        internal Task<FrameExpectResult> ExpectAsync(string selector, string expression, FrameExpectOptions options = null) =>
578            _channel.ExpectAsync(selector, expression, expressionArg: options?.ExpressionArg, expectedText: options?.ExpectedText, expectedNumber: options?.ExpectedNumber, expectedValue: options?.ExpectedValue, useInnerText: options?.UseInnerText, isNot: options?.IsNot, timeout: options?.Timeout);
579
580        private Task WaitForURLAsync(string urlString, Regex urlRegex, Func<string, bool> urlFunc, FrameWaitForURLOptions options = default)
581        {
582            if (UrlMatches(Url, urlString, urlRegex, urlFunc))
583            {
584                return WaitForLoadStateAsync(ToLoadState(options?.WaitUntil), new() { Timeout = options?.Timeout });
585            }
586
587            return WaitForNavigationAsync(
588                new()
589                {
590                    UrlString = urlString,
591                    UrlRegex = urlRegex,
592                    UrlFunc = urlFunc,
593                    Timeout = options?.Timeout,
594                    WaitUntil = options?.WaitUntil,
595                });
596        }
597
598        private LoadState? ToLoadState(WaitUntilState? waitUntilState)
599        {
600            if (waitUntilState == null)
601            {
602                return null;
603            }
604
605            return waitUntilState switch
606            {
607                WaitUntilState.Load => Microsoft.Playwright.LoadState.Load,
608                WaitUntilState.DOMContentLoaded => Microsoft.Playwright.LoadState.DOMContentLoaded,
609                WaitUntilState.NetworkIdle => Microsoft.Playwright.LoadState.NetworkIdle,
610                _ => null,
611            };
612        }
613
614        private Waiter SetupNavigationWaiter(string @event, float? timeout)
615        {
616            var waiter = new Waiter(this.Page as Page, @event);
617            if (this.Page.IsClosed)
618            {
619                waiter.RejectImmediately(new PlaywrightException("Navigation failed because page was closed!"));
620            }
621            waiter.RejectOnEvent<IPage>(Page, PageEvent.Close.Name, new("Navigation failed because page was closed!"));
622            waiter.RejectOnEvent<IPage>(Page, PageEvent.Crash.Name, new("Navigation failed because page was crashed!"));
623            waiter.RejectOnEvent<IFrame>(
624                Page,
625                "FrameDetached",
626                new("Navigating frame was detached!"),
627                e => e == this);
628            timeout ??= (Page as Page)?.DefaultNavigationTimeout ?? PlaywrightImpl.DefaultTimeout;
629            waiter.RejectOnTimeout(Convert.ToInt32(timeout), $"Timeout {timeout}ms exceeded.");
630
631            return waiter;
632        }
633
634        private bool UrlMatches(string url, string matchUrl, Regex regex, Func<string, bool> match)
635        {
636            matchUrl = (Page.Context as BrowserContext)?.CombineUrlWithBase(matchUrl);
637
638            if (matchUrl == null && regex == null && match == null)
639            {
640                return true;
641            }
642
643            if (!string.IsNullOrEmpty(matchUrl))
644            {
645                regex = new(matchUrl.GlobToRegex());
646            }
647
648            if (matchUrl != null && url == matchUrl)
649            {
650                return true;
651            }
652
653            if (regex != null)
654            {
655                return regex.IsMatch(url);
656            }
657
658            return match(url);
659        }
660
661        internal Task HighlightAsync(string selector)
662            => _channel.HighlightAsync(selector);
663    }
664}
665
Full Screen

IFrame.cs

Source: IFrame.cs Github

copy
1/*
2 * MIT License
3 *
4 * Copyright (c) Microsoft Corporation.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
25using System;
26using System.Collections.Generic;
27using System.ComponentModel.DataAnnotations;
28using System.Drawing;
29using System.Globalization;
30using System.IO;
31using System.Runtime.Serialization;
32using System.Text.Json;
33using System.Text.Json.Serialization;
34using System.Text.RegularExpressions;
35using System.Threading;
36using System.Threading.Tasks;
37
38#nullable enable
39
40namespace Microsoft.Playwright
41{
42    /// <summary>
43    /// <para>
44    /// At every point of time, page exposes its current frame tree via the <see cref="IPage.MainFrame"/>
45    /// and <see cref="IFrame.ChildFrames"/> methods.
46    /// </para>
47    /// <para>
48    /// <see cref="IFrame"/> object's lifecycle is controlled by three events, dispatched
49    /// on the page object:
50    /// </para>
51    /// <list type="bullet">
52    /// <item><description>
53    /// <see cref="IPage.FrameAttached"/> - fired when the frame gets attached to the page.
54    /// A Frame can be attached to the page only once.
55    /// </description></item>
56    /// <item><description>
57    /// <see cref="IPage.FrameNavigated"/> - fired when the frame commits navigation to
58    /// a different URL.
59    /// </description></item>
60    /// <item><description>
61    /// <see cref="IPage.FrameDetached"/> - fired when the frame gets detached from the
62    /// page.  A Frame can be detached from the page only once.
63    /// </description></item>
64    /// </list>
65    /// <para>An example of dumping frame tree:</para>
66    /// <code>
67    /// using Microsoft.Playwright;<br/>
68    /// using System;<br/>
69    /// using System.Threading.Tasks;<br/>
70    /// <br/>
71    /// class FrameExamples<br/>
72    /// {<br/>
73    ///     public static async Task Main()<br/>
74    ///     {<br/>
75    ///         using var playwright = await Playwright.CreateAsync();<br/>
76    ///         await using var browser = await playwright.Firefox.LaunchAsync();<br/>
77    ///         var page = await browser.NewPageAsync();<br/>
78    /// <br/>
79    ///         await page.GotoAsync("https://www.bing.com");<br/>
80    ///         DumpFrameTree(page.MainFrame, string.Empty);<br/>
81    ///     }<br/>
82    /// <br/>
83    ///     private static void DumpFrameTree(IFrame frame, string indent)<br/>
84    ///     {<br/>
85    ///         Console.WriteLine($"{indent}{frame.Url}");<br/>
86    ///         foreach (var child in frame.ChildFrames)<br/>
87    ///             DumpFrameTree(child, indent + " ");<br/>
88    ///     }<br/>
89    /// }
90    /// </code>
91    /// </summary>
92    public partial interface IFrame
93    {
94        /// <summary>
95        /// <para>
96        /// Returns the added tag when the script's onload fires or when the script content
97        /// was injected into frame.
98        /// </para>
99        /// <para>Adds a <c>&lt;script&gt;</c> tag into the page with the desired url or content.</para>
100        /// </summary>
101        /// <param name="options">Call options</param>
102        Task<IElementHandle> AddScriptTagAsync(FrameAddScriptTagOptions? options = default);
103
104        /// <summary>
105        /// <para>
106        /// Returns the added tag when the stylesheet's onload fires or when the CSS content
107        /// was injected into frame.
108        /// </para>
109        /// <para>
110        /// Adds a <c>&lt;link rel="stylesheet"&gt;</c> tag into the page with the desired url
111        /// or a <c>&lt;style type="text/css"&gt;</c> tag with the content.
112        /// </para>
113        /// </summary>
114        /// <param name="options">Call options</param>
115        Task<IElementHandle> AddStyleTagAsync(FrameAddStyleTagOptions? options = default);
116
117        /// <summary>
118        /// <para>
119        /// This method checks an element matching <paramref name="selector"/> by performing
120        /// the following steps:
121        /// </para>
122        /// <list type="ordinal">
123        /// <item><description>
124        /// Find an element matching <paramref name="selector"/>. If there is none, wait until
125        /// a matching element is attached to the DOM.
126        /// </description></item>
127        /// <item><description>
128        /// Ensure that matched element is a checkbox or a radio input. If not, this method
129        /// throws. If the element is already checked, this method returns immediately.
130        /// </description></item>
131        /// <item><description>
132        /// Wait for <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
133        /// checks on the matched element, unless <paramref name="force"/> option is set. If
134        /// the element is detached during the checks, the whole action is retried.
135        /// </description></item>
136        /// <item><description>Scroll the element into view if needed.</description></item>
137        /// <item><description>Use <see cref="IPage.Mouse"/> to click in the center of the element.</description></item>
138        /// <item><description>
139        /// Wait for initiated navigations to either succeed or fail, unless <paramref name="noWaitAfter"/>
140        /// option is set.
141        /// </description></item>
142        /// <item><description>Ensure that the element is now checked. If not, this method throws.</description></item>
143        /// </list>
144        /// <para>
145        /// When all steps combined have not finished during the specified <paramref name="timeout"/>,
146        /// this method throws a <see cref="TimeoutException"/>. Passing zero timeout disables
147        /// this.
148        /// </para>
149        /// </summary>
150        /// <param name="selector">
151        /// A selector to search for an element. If there are multiple elements satisfying the
152        /// selector, the first will be used. See <a href="https://playwright.dev/dotnet/docs/selectors">working
153        /// with selectors</a> for more details.
154        /// </param>
155        /// <param name="options">Call options</param>
156        Task CheckAsync(string selector, FrameCheckOptions? options = default);
157
158        IReadOnlyList<IFrame> ChildFrames { get; }
159
160        /// <summary>
161        /// <para>
162        /// This method clicks an element matching <paramref name="selector"/> by performing
163        /// the following steps:
164        /// </para>
165        /// <list type="ordinal">
166        /// <item><description>
167        /// Find an element matching <paramref name="selector"/>. If there is none, wait until
168        /// a matching element is attached to the DOM.
169        /// </description></item>
170        /// <item><description>
171        /// Wait for <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
172        /// checks on the matched element, unless <paramref name="force"/> option is set. If
173        /// the element is detached during the checks, the whole action is retried.
174        /// </description></item>
175        /// <item><description>Scroll the element into view if needed.</description></item>
176        /// <item><description>
177        /// Use <see cref="IPage.Mouse"/> to click in the center of the element, or the specified
178        /// <paramref name="position"/>.
179        /// </description></item>
180        /// <item><description>
181        /// Wait for initiated navigations to either succeed or fail, unless <paramref name="noWaitAfter"/>
182        /// option is set.
183        /// </description></item>
184        /// </list>
185        /// <para>
186        /// When all steps combined have not finished during the specified <paramref name="timeout"/>,
187        /// this method throws a <see cref="TimeoutException"/>. Passing zero timeout disables
188        /// this.
189        /// </para>
190        /// </summary>
191        /// <param name="selector">
192        /// A selector to search for an element. If there are multiple elements satisfying the
193        /// selector, the first will be used. See <a href="https://playwright.dev/dotnet/docs/selectors">working
194        /// with selectors</a> for more details.
195        /// </param>
196        /// <param name="options">Call options</param>
197        Task ClickAsync(string selector, FrameClickOptions? options = default);
198
199        /// <summary><para>Gets the full HTML contents of the frame, including the doctype.</para></summary>
200        Task<string> ContentAsync();
201
202        /// <summary>
203        /// <para>
204        /// This method double clicks an element matching <paramref name="selector"/> by performing
205        /// the following steps:
206        /// </para>
207        /// <list type="ordinal">
208        /// <item><description>
209        /// Find an element matching <paramref name="selector"/>. If there is none, wait until
210        /// a matching element is attached to the DOM.
211        /// </description></item>
212        /// <item><description>
213        /// Wait for <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
214        /// checks on the matched element, unless <paramref name="force"/> option is set. If
215        /// the element is detached during the checks, the whole action is retried.
216        /// </description></item>
217        /// <item><description>Scroll the element into view if needed.</description></item>
218        /// <item><description>
219        /// Use <see cref="IPage.Mouse"/> to double click in the center of the element, or the
220        /// specified <paramref name="position"/>.
221        /// </description></item>
222        /// <item><description>
223        /// Wait for initiated navigations to either succeed or fail, unless <paramref name="noWaitAfter"/>
224        /// option is set. Note that if the first click of the <c>dblclick()</c> triggers a
225        /// navigation event, this method will throw.
226        /// </description></item>
227        /// </list>
228        /// <para>
229        /// When all steps combined have not finished during the specified <paramref name="timeout"/>,
230        /// this method throws a <see cref="TimeoutException"/>. Passing zero timeout disables
231        /// this.
232        /// </para>
233        /// </summary>
234        /// <remarks>
235        /// <para>
236        /// <c>frame.dblclick()</c> dispatches two <c>click</c> events and a single <c>dblclick</c>
237        /// event.
238        /// </para>
239        /// </remarks>
240        /// <param name="selector">
241        /// A selector to search for an element. If there are multiple elements satisfying the
242        /// selector, the first will be used. See <a href="https://playwright.dev/dotnet/docs/selectors">working
243        /// with selectors</a> for more details.
244        /// </param>
245        /// <param name="options">Call options</param>
246        Task DblClickAsync(string selector, FrameDblClickOptions? options = default);
247
248        /// <summary>
249        /// <para>
250        /// The snippet below dispatches the <c>click</c> event on the element. Regardless of
251        /// the visibility state of the element, <c>click</c> is dispatched. This is equivalent
252        /// to calling <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click">element.click()</a>.
253        /// </para>
254        /// <code>await frame.DispatchEventAsync("button#submit", "click");</code>
255        /// <para>
256        /// Under the hood, it creates an instance of an event based on the given <paramref
257        /// name="type"/>, initializes it with <paramref name="eventInit"/> properties and dispatches
258        /// it on the element. Events are <c>composed</c>, <c>cancelable</c> and bubble by default.
259        /// </para>
260        /// <para>
261        /// Since <paramref name="eventInit"/> is event-specific, please refer to the events
262        /// documentation for the lists of initial properties:
263        /// </para>
264        /// <list type="bullet">
265        /// <item><description><a href="https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent">DragEvent</a></description></item>
266        /// <item><description><a href="https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent">FocusEvent</a></description></item>
267        /// <item><description><a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent">KeyboardEvent</a></description></item>
268        /// <item><description><a href="https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent">MouseEvent</a></description></item>
269        /// <item><description><a href="https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/PointerEvent">PointerEvent</a></description></item>
270        /// <item><description><a href="https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/TouchEvent">TouchEvent</a></description></item>
271        /// <item><description><a href="https://developer.mozilla.org/en-US/docs/Web/API/Event/Event">Event</a></description></item>
272        /// </list>
273        /// <para>
274        /// You can also specify <c>JSHandle</c> as the property value if you want live objects
275        /// to be passed into the event:
276        /// </para>
277        /// <code>
278        /// // Note you can only create DataTransfer in Chromium and Firefox<br/>
279        /// var dataTransfer = await frame.EvaluateHandleAsync("() =&gt; new DataTransfer()");<br/>
280        /// await frame.DispatchEventAsync("#source", "dragstart", new { dataTransfer });
281        /// </code>
282        /// </summary>
283        /// <param name="selector">
284        /// A selector to search for an element. If there are multiple elements satisfying the
285        /// selector, the first will be used. See <a href="https://playwright.dev/dotnet/docs/selectors">working
286        /// with selectors</a> for more details.
287        /// </param>
288        /// <param name="type">DOM event type: <c>"click"</c>, <c>"dragstart"</c>, etc.</param>
289        /// <param name="eventInit">Optional event-specific initialization properties.</param>
290        /// <param name="options">Call options</param>
291        Task DispatchEventAsync(string selector, string type, object? eventInit = default, FrameDispatchEventOptions? options = default);
292
293        /// <param name="source">
294        /// </param>
295        /// <param name="target">
296        /// </param>
297        /// <param name="options">Call options</param>
298        Task DragAndDropAsync(string source, string target, FrameDragAndDropOptions? options = default);
299
300        /// <summary>
301        /// <para>Returns the return value of <paramref name="expression"/>.</para>
302        /// <para>
303        /// The method finds an element matching the specified selector within the frame and
304        /// passes it as a first argument to <paramref name="expression"/>. See <a href="https://playwright.dev/dotnet/docs/selectors">Working
305        /// with selectors</a> for more details. If no elements match the selector, the method
306        /// throws an error.
307        /// </para>
308        /// <para>
309        /// If <paramref name="expression"/> returns a <see cref="Task"/>, then <see cref="IFrame.EvalOnSelectorAsync"/>
310        /// would wait for the promise to resolve and return its value.
311        /// </para>
312        /// <para>Examples:</para>
313        /// <code>
314        /// var searchValue = await frame.EvalOnSelectorAsync&lt;string&gt;("#search", "el =&gt; el.value");<br/>
315        /// var preloadHref = await frame.EvalOnSelectorAsync&lt;string&gt;("link[rel=preload]", "el =&gt; el.href");<br/>
316        /// var html = await frame.EvalOnSelectorAsync(".main-container", "(e, suffix) =&gt; e.outerHTML + suffix", "hello");
317        /// </code>
318        /// </summary>
319        /// <remarks>
320        /// <para>
321        /// This method does not wait for the element to pass actionability checks and therefore
322        /// can lead to the flaky tests. Use <see cref="ILocator.EvaluateAsync"/>, other <see
323        /// cref="ILocator"/> helper methods or web-first assertions instead.
324        /// </para>
325        /// </remarks>
326        /// <param name="selector">
327        /// A selector to query for. See <a href="https://playwright.dev/dotnet/docs/selectors">working
328        /// with selectors</a> for more details.
329        /// </param>
330        /// <param name="expression">
331        /// JavaScript expression to be evaluated in the browser context. If it looks like a
332        /// function declaration, it is interpreted as a function. Otherwise, evaluated as an
333        /// expression.
334        /// </param>
335        /// <param name="arg">Optional argument to pass to <paramref name="expression"/>.</param>
336        /// <param name="options">Call options</param>
337        Task<T> EvalOnSelectorAsync<T>(string selector, string expression, object? arg = default, FrameEvalOnSelectorOptions? options = default);
338
339        /// <summary>
340        /// <para>Returns the return value of <paramref name="expression"/>.</para>
341        /// <para>
342        /// The method finds all elements matching the specified selector within the frame and
343        /// passes an array of matched elements as a first argument to <paramref name="expression"/>.
344        /// See <a href="https://playwright.dev/dotnet/docs/selectors">Working with selectors</a>
345        /// for more details.
346        /// </para>
347        /// <para>
348        /// If <paramref name="expression"/> returns a <see cref="Task"/>, then <see cref="IFrame.EvalOnSelectorAllAsync"/>
349        /// would wait for the promise to resolve and return its value.
350        /// </para>
351        /// <para>Examples:</para>
352        /// <code>var divsCount = await frame.EvalOnSelectorAllAsync&lt;bool&gt;("div", "(divs, min) =&gt; divs.length &gt;= min", 10);</code>
353        /// </summary>
354        /// <remarks>
355        /// <para>
356        /// In most cases, <see cref="ILocator.EvaluateAllAsync"/>, other <see cref="ILocator"/>
357        /// helper methods and web-first assertions do a better job.
358        /// </para>
359        /// </remarks>
360        /// <param name="selector">
361        /// A selector to query for. See <a href="https://playwright.dev/dotnet/docs/selectors">working
362        /// with selectors</a> for more details.
363        /// </param>
364        /// <param name="expression">
365        /// JavaScript expression to be evaluated in the browser context. If it looks like a
366        /// function declaration, it is interpreted as a function. Otherwise, evaluated as an
367        /// expression.
368        /// </param>
369        /// <param name="arg">Optional argument to pass to <paramref name="expression"/>.</param>
370        Task<T> EvalOnSelectorAllAsync<T>(string selector, string expression, object? arg = default);
371
372        /// <summary>
373        /// <para>Returns the return value of <paramref name="expression"/>.</para>
374        /// <para>
375        /// If the function passed to the <see cref="IFrame.EvaluateAsync"/> returns a <see
376        /// cref="Task"/>, then <see cref="IFrame.EvaluateAsync"/> would wait for the promise
377        /// to resolve and return its value.
378        /// </para>
379        /// <para>
380        /// If the function passed to the <see cref="IFrame.EvaluateAsync"/> returns a non-<see
381        /// cref="Serializable"/> value, then <see cref="IFrame.EvaluateAsync"/> returns <c>undefined</c>.
382        /// Playwright also supports transferring some additional values that are not serializable
383        /// by <c>JSON</c>: <c>-0</c>, <c>NaN</c>, <c>Infinity</c>, <c>-Infinity</c>.
384        /// </para>
385        /// <code>
386        /// var result = await frame.EvaluateAsync&lt;int&gt;("([x, y]) =&gt; Promise.resolve(x * y)", new[] { 7, 8 });<br/>
387        /// Console.WriteLine(result);
388        /// </code>
389        /// <para>A string can also be passed in instead of a function.</para>
390        /// <code>Console.WriteLine(await frame.EvaluateAsync&lt;int&gt;("1 + 2")); // prints "3"</code>
391        /// <para>
392        /// <see cref="IElementHandle"/> instances can be passed as an argument to the <see
393        /// cref="IFrame.EvaluateAsync"/>:
394        /// </para>
395        /// <code>
396        /// var bodyHandle = await frame.EvaluateAsync("document.body");<br/>
397        /// var html = await frame.EvaluateAsync&lt;string&gt;("([body, suffix]) =&gt; body.innerHTML + suffix", new object [] { bodyHandle, "hello" });<br/>
398        /// await bodyHandle.DisposeAsync();
399        /// </code>
400        /// </summary>
401        /// <param name="expression">
402        /// JavaScript expression to be evaluated in the browser context. If it looks like a
403        /// function declaration, it is interpreted as a function. Otherwise, evaluated as an
404        /// expression.
405        /// </param>
406        /// <param name="arg">Optional argument to pass to <paramref name="expression"/>.</param>
407        Task<T> EvaluateAsync<T>(string expression, object? arg = default);
408
409        /// <summary>
410        /// <para>Returns the return value of <paramref name="expression"/> as a <see cref="IJSHandle"/>.</para>
411        /// <para>
412        /// The only difference between <see cref="IFrame.EvaluateAsync"/> and <see cref="IFrame.EvaluateHandleAsync"/>
413        /// is that <see cref="IFrame.EvaluateHandleAsync"/> returns <see cref="IJSHandle"/>.
414        /// </para>
415        /// <para>
416        /// If the function, passed to the <see cref="IFrame.EvaluateHandleAsync"/>, returns
417        /// a <see cref="Task"/>, then <see cref="IFrame.EvaluateHandleAsync"/> would wait for
418        /// the promise to resolve and return its value.
419        /// </para>
420        /// <code>
421        /// // Handle for the window object.<br/>
422        /// var aWindowHandle = await frame.EvaluateHandleAsync("() =&gt; Promise.resolve(window)");
423        /// </code>
424        /// <para>A string can also be passed in instead of a function.</para>
425        /// <code>var docHandle = await frame.EvaluateHandleAsync("document"); // Handle for the `document`</code>
426        /// <para><see cref="IJSHandle"/> instances can be passed as an argument to the <see cref="IFrame.EvaluateHandleAsync"/>:</para>
427        /// <code>
428        /// var handle = await frame.EvaluateHandleAsync("() =&gt; document.body");<br/>
429        /// var resultHandle = await frame.EvaluateHandleAsync("([body, suffix]) =&gt; body.innerHTML + suffix", new object[] { handle, "hello" });<br/>
430        /// Console.WriteLine(await resultHandle.JsonValueAsync&lt;string&gt;());<br/>
431        /// await resultHandle.DisposeAsync();
432        /// </code>
433        /// </summary>
434        /// <param name="expression">
435        /// JavaScript expression to be evaluated in the browser context. If it looks like a
436        /// function declaration, it is interpreted as a function. Otherwise, evaluated as an
437        /// expression.
438        /// </param>
439        /// <param name="arg">Optional argument to pass to <paramref name="expression"/>.</param>
440        Task<IJSHandle> EvaluateHandleAsync(string expression, object? arg = default);
441
442        /// <summary>
443        /// <para>
444        /// This method waits for an element matching <paramref name="selector"/>, waits for
445        /// <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a> checks,
446        /// focuses the element, fills it and triggers an <c>input</c> event after filling.
447        /// Note that you can pass an empty string to clear the input field.
448        /// </para>
449        /// <para>
450        /// If the target element is not an <c>&lt;input&gt;</c>, <c>&lt;textarea&gt;</c> or
451        /// <c>[contenteditable]</c> element, this method throws an error. However, if the element
452        /// is inside the <c>&lt;label&gt;</c> element that has an associated <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>,
453        /// the control will be filled instead.
454        /// </para>
455        /// <para>To send fine-grained keyboard events, use <see cref="IFrame.TypeAsync"/>.</para>
456        /// </summary>
457        /// <param name="selector">
458        /// A selector to search for an element. If there are multiple elements satisfying the
459        /// selector, the first will be used. See <a href="https://playwright.dev/dotnet/docs/selectors">working
460        /// with selectors</a> for more details.
461        /// </param>
462        /// <param name="value">
463        /// Value to fill for the <c>&lt;input&gt;</c>, <c>&lt;textarea&gt;</c> or <c>[contenteditable]</c>
464        /// element.
465        /// </param>
466        /// <param name="options">Call options</param>
467        Task FillAsync(string selector, string value, FrameFillOptions? options = default);
468
469        /// <summary>
470        /// <para>
471        /// This method fetches an element with <paramref name="selector"/> and focuses it.
472        /// If there's no element matching <paramref name="selector"/>, the method waits until
473        /// a matching element appears in the DOM.
474        /// </para>
475        /// </summary>
476        /// <param name="selector">
477        /// A selector to search for an element. If there are multiple elements satisfying the
478        /// selector, the first will be used. See <a href="https://playwright.dev/dotnet/docs/selectors">working
479        /// with selectors</a> for more details.
480        /// </param>
481        /// <param name="options">Call options</param>
482        Task FocusAsync(string selector, FrameFocusOptions? options = default);
483
484        /// <summary>
485        /// <para>
486        /// Returns the <c>frame</c> or <c>iframe</c> element handle which corresponds to this
487        /// frame.
488        /// </para>
489        /// <para>
490        /// This is an inverse of <see cref="IElementHandle.ContentFrameAsync"/>. Note that
491        /// returned handle actually belongs to the parent frame.
492        /// </para>
493        /// <para>
494        /// This method throws an error if the frame has been detached before <c>frameElement()</c>
495        /// returns.
496        /// </para>
497        /// <code>
498        /// var frameElement = await frame.FrameElementAsync();<br/>
499        /// var contentFrame = await frameElement.ContentFrameAsync();<br/>
500        /// Console.WriteLine(frame == contentFrame); // -&gt; True
501        /// </code>
502        /// </summary>
503        Task<IElementHandle> FrameElementAsync();
504
505        /// <summary>
506        /// <para>
507        /// When working with iframes, you can create a frame locator that will enter the iframe
508        /// and allow selecting elements in that iframe. Following snippet locates element with
509        /// text "Submit" in the iframe with id <c>my-frame</c>, like <c>&lt;iframe id="my-frame"&gt;</c>:
510        /// </para>
511        /// <code>
512        /// var locator = frame.FrameLocator("#my-iframe").Locator("text=Submit");<br/>
513        /// await locator.ClickAsync();
514        /// </code>
515        /// </summary>
516        /// <param name="selector">
517        /// A selector to use when resolving DOM element. See <a href="https://playwright.dev/dotnet/docs/selectors">working
518        /// with selectors</a> for more details.
519        /// </param>
520        IFrameLocator FrameLocator(string selector);
521
522        /// <summary><para>Returns element attribute value.</para></summary>
523        /// <param name="selector">
524        /// A selector to search for an element. If there are multiple elements satisfying the
525        /// selector, the first will be used. See <a href="https://playwright.dev/dotnet/docs/selectors">working
526        /// with selectors</a> for more details.
527        /// </param>
528        /// <param name="name">Attribute name to get the value for.</param>
529        /// <param name="options">Call options</param>
530        Task<string?> GetAttributeAsync(string selector, string name, FrameGetAttributeOptions? options = default);
531
532        /// <summary>
533        /// <para>
534        /// Returns the main resource response. In case of multiple redirects, the navigation
535        /// will resolve with the response of the last redirect.
536        /// </para>
537        /// <para>The method will throw an error if:</para>
538        /// <list type="bullet">
539        /// <item><description>there's an SSL error (e.g. in case of self-signed certificates).</description></item>
540        /// <item><description>target URL is invalid.</description></item>
541        /// <item><description>the <paramref name="timeout"/> is exceeded during navigation.</description></item>
542        /// <item><description>the remote server does not respond or is unreachable.</description></item>
543        /// <item><description>the main resource failed to load.</description></item>
544        /// </list>
545        /// <para>
546        /// The method will not throw an error when any valid HTTP status code is returned by
547        /// the remote server, including 404 "Not Found" and 500 "Internal Server Error".  The
548        /// status code for such responses can be retrieved by calling <see cref="IResponse.Status"/>.
549        /// </para>
550        /// </summary>
551        /// <remarks>
552        /// <para>
553        /// The method either throws an error or returns a main resource response. The only
554        /// exceptions are navigation to <c>about:blank</c> or navigation to the same URL with
555        /// a different hash, which would succeed and return <c>null</c>.
556        /// </para>
557        /// <para>
558        /// Headless mode doesn't support navigation to a PDF document. See the <a href="https://bugs.chromium.org/p/chromium/issues/detail?id=761295">upstream
559        /// issue</a>.
560        /// </para>
561        /// </remarks>
562        /// <param name="url">URL to navigate frame to. The url should include scheme, e.g. <c>https://</c>.</param>
563        /// <param name="options">Call options</param>
564        Task<IResponse?> GotoAsync(string url, FrameGotoOptions? options = default);
565
566        /// <summary>
567        /// <para>
568        /// This method hovers over an element matching <paramref name="selector"/> by performing
569        /// the following steps:
570        /// </para>
571        /// <list type="ordinal">
572        /// <item><description>
573        /// Find an element matching <paramref name="selector"/>. If there is none, wait until
574        /// a matching element is attached to the DOM.
575        /// </description></item>
576        /// <item><description>
577        /// Wait for <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
578        /// checks on the matched element, unless <paramref name="force"/> option is set. If
579        /// the element is detached during the checks, the whole action is retried.
580        /// </description></item>
581        /// <item><description>Scroll the element into view if needed.</description></item>
582        /// <item><description>
583        /// Use <see cref="IPage.Mouse"/> to hover over the center of the element, or the specified
584        /// <paramref name="position"/>.
585        /// </description></item>
586        /// <item><description>
587        /// Wait for initiated navigations to either succeed or fail, unless <c>noWaitAfter</c>
588        /// option is set.
589        /// </description></item>
590        /// </list>
591        /// <para>
592        /// When all steps combined have not finished during the specified <paramref name="timeout"/>,
593        /// this method throws a <see cref="TimeoutException"/>. Passing zero timeout disables
594        /// this.
595        /// </para>
596        /// </summary>
597        /// <param name="selector">
598        /// A selector to search for an element. If there are multiple elements satisfying the
599        /// selector, the first will be used. See <a href="https://playwright.dev/dotnet/docs/selectors">working
600        /// with selectors</a> for more details.
601        /// </param>
602        /// <param name="options">Call options</param>
603        Task HoverAsync(string selector, FrameHoverOptions? options = default);
604
605        /// <summary><para>Returns <c>element.innerHTML</c>.</para></summary>
606        /// <param name="selector">
607        /// A selector to search for an element. If there are multiple elements satisfying the
608        /// selector, the first will be used. See <a href="https://playwright.dev/dotnet/docs/selectors">working
609        /// with selectors</a> for more details.
610        /// </param>
611        /// <param name="options">Call options</param>
612        Task<string> InnerHTMLAsync(string selector, FrameInnerHTMLOptions? options = default);
613
614        /// <summary><para>Returns <c>element.innerText</c>.</para></summary>
615        /// <param name="selector">
616        /// A selector to search for an element. If there are multiple elements satisfying the
617        /// selector, the first will be used. See <a href="https://playwright.dev/dotnet/docs/selectors">working
618        /// with selectors</a> for more details.
619        /// </param>
620        /// <param name="options">Call options</param>
621        Task<string> InnerTextAsync(string selector, FrameInnerTextOptions? options = default);
622
623        /// <summary>
624        /// <para>
625        /// Returns <c>input.value</c> for the selected <c>&lt;input&gt;</c> or <c>&lt;textarea&gt;</c>
626        /// or <c>&lt;select&gt;</c> element. Throws for non-input elements.
627        /// </para>
628        /// </summary>
629        /// <param name="selector">
630        /// A selector to search for an element. If there are multiple elements satisfying the
631        /// selector, the first will be used. See <a href="https://playwright.dev/dotnet/docs/selectors">working
632        /// with selectors</a> for more details.
633        /// </param>
634        /// <param name="options">Call options</param>
635        Task<string> InputValueAsync(string selector, FrameInputValueOptions? options = default);
636
637        /// <summary>
638        /// <para>
639        /// Returns whether the element is checked. Throws if the element is not a checkbox
640        /// or radio input.
641        /// </para>
642        /// </summary>
643        /// <param name="selector">
644        /// A selector to search for an element. If there are multiple elements satisfying the
645        /// selector, the first will be used. See <a href="https://playwright.dev/dotnet/docs/selectors">working
646        /// with selectors</a> for more details.
647        /// </param>
648        /// <param name="options">Call options</param>
649        Task<bool> IsCheckedAsync(string selector, FrameIsCheckedOptions? options = default);
650
651        /// <summary><para>Returns <c>true</c> if the frame has been detached, or <c>false</c> otherwise.</para></summary>
652        bool IsDetached { get; }
653
654        /// <summary><para>Returns whether the element is disabled, the opposite of <a href="https://playwright.dev/dotnet/docs/actionability#enabled">enabled</a>.</para></summary>
655        /// <param name="selector">
656        /// A selector to search for an element. If there are multiple elements satisfying the
657        /// selector, the first will be used. See <a href="https://playwright.dev/dotnet/docs/selectors">working
658        /// with selectors</a> for more details.
659        /// </param>
660        /// <param name="options">Call options</param>
661        Task<bool> IsDisabledAsync(string selector, FrameIsDisabledOptions? options = default);
662
663        /// <summary><para>Returns whether the element is <a href="https://playwright.dev/dotnet/docs/actionability#editable">editable</a>.</para></summary>
664        /// <param name="selector">
665        /// A selector to search for an element. If there are multiple elements satisfying the
666        /// selector, the first will be used. See <a href="https://playwright.dev/dotnet/docs/selectors">working
667        /// with selectors</a> for more details.
668        /// </param>
669        /// <param name="options">Call options</param>
670        Task<bool> IsEditableAsync(string selector, FrameIsEditableOptions? options = default);
671
672        /// <summary><para>Returns whether the element is <a href="https://playwright.dev/dotnet/docs/actionability#enabled">enabled</a>.</para></summary>
673        /// <param name="selector">
674        /// A selector to search for an element. If there are multiple elements satisfying the
675        /// selector, the first will be used. See <a href="https://playwright.dev/dotnet/docs/selectors">working
676        /// with selectors</a> for more details.
677        /// </param>
678        /// <param name="options">Call options</param>
679        Task<bool> IsEnabledAsync(string selector, FrameIsEnabledOptions? options = default);
680
681        /// <summary>
682        /// <para>
683        /// Returns whether the element is hidden, the opposite of <a href="https://playwright.dev/dotnet/docs/actionability#visible">visible</a>.
684        /// <paramref name="selector"/> that does not match any elements is considered hidden.
685        /// </para>
686        /// </summary>
687        /// <param name="selector">
688        /// A selector to search for an element. If there are multiple elements satisfying the
689        /// selector, the first will be used. See <a href="https://playwright.dev/dotnet/docs/selectors">working
690        /// with selectors</a> for more details.
691        /// </param>
692        /// <param name="options">Call options</param>
693        Task<bool> IsHiddenAsync(string selector, FrameIsHiddenOptions? options = default);
694
695        /// <summary>
696        /// <para>
697        /// Returns whether the element is <a href="https://playwright.dev/dotnet/docs/actionability#visible">visible</a>.
698        /// <paramref name="selector"/> that does not match any elements is considered not visible.
699        /// </para>
700        /// </summary>
701        /// <param name="selector">
702        /// A selector to search for an element. If there are multiple elements satisfying the
703        /// selector, the first will be used. See <a href="https://playwright.dev/dotnet/docs/selectors">working
704        /// with selectors</a> for more details.
705        /// </param>
706        /// <param name="options">Call options</param>
707        Task<bool> IsVisibleAsync(string selector, FrameIsVisibleOptions? options = default);
708
709        /// <summary>
710        /// <para>
711        /// The method returns an element locator that can be used to perform actions in the
712        /// frame. Locator is resolved to the element immediately before performing an action,
713        /// so a series of actions on the same locator can in fact be performed on different
714        /// DOM elements. That would happen if the DOM structure between those actions has changed.
715        /// </para>
716        /// </summary>
717        /// <param name="selector">
718        /// A selector to use when resolving DOM element. See <a href="https://playwright.dev/dotnet/docs/selectors">working
719        /// with selectors</a> for more details.
720        /// </param>
721        /// <param name="options">Call options</param>
722        ILocator Locator(string selector, FrameLocatorOptions? options = default);
723
724        /// <summary>
725        /// <para>Returns frame's name attribute as specified in the tag.</para>
726        /// <para>If the name is empty, returns the id attribute instead.</para>
727        /// </summary>
728        /// <remarks>
729        /// <para>
730        /// This value is calculated once when the frame is created, and will not update if
731        /// the attribute is changed later.
732        /// </para>
733        /// </remarks>
734        string Name { get; }
735
736        /// <summary><para>Returns the page containing this frame.</para></summary>
737        IPage Page { get; }
738
739        /// <summary><para>Parent frame, if any. Detached frames and main frames return <c>null</c>.</para></summary>
740        IFrame? ParentFrame { get; }
741
742        /// <summary>
743        /// <para>
744        /// <paramref name="key"/> can specify the intended <a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key">keyboardEvent.key</a>
745        /// value or a single character to generate the text for. A superset of the <paramref
746        /// name="key"/> values can be found <a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values">here</a>.
747        /// Examples of the keys are:
748        /// </para>
749        /// <para>
750        /// <c>F1</c> - <c>F12</c>, <c>Digit0</c>- <c>Digit9</c>, <c>KeyA</c>- <c>KeyZ</c>,
751        /// <c>Backquote</c>, <c>Minus</c>, <c>Equal</c>, <c>Backslash</c>, <c>Backspace</c>,
752        /// <c>Tab</c>, <c>Delete</c>, <c>Escape</c>, <c>ArrowDown</c>, <c>End</c>, <c>Enter</c>,
753        /// <c>Home</c>, <c>Insert</c>, <c>PageDown</c>, <c>PageUp</c>, <c>ArrowRight</c>, <c>ArrowUp</c>,
754        /// etc.
755        /// </para>
756        /// <para>
757        /// Following modification shortcuts are also supported: <c>Shift</c>, <c>Control</c>,
758        /// <c>Alt</c>, <c>Meta</c>, <c>ShiftLeft</c>.
759        /// </para>
760        /// <para>
761        /// Holding down <c>Shift</c> will type the text that corresponds to the <paramref name="key"/>
762        /// in the upper case.
763        /// </para>
764        /// <para>
765        /// If <paramref name="key"/> is a single character, it is case-sensitive, so the values
766        /// <c>a</c> and <c>A</c> will generate different respective texts.
767        /// </para>
768        /// <para>
769        /// Shortcuts such as <c>key: "Control+o"</c> or <c>key: "Control+Shift+T"</c> are supported
770        /// as well. When specified with the modifier, modifier is pressed and being held while
771        /// the subsequent key is being pressed.
772        /// </para>
773        /// </summary>
774        /// <param name="selector">
775        /// A selector to search for an element. If there are multiple elements satisfying the
776        /// selector, the first will be used. See <a href="https://playwright.dev/dotnet/docs/selectors">working
777        /// with selectors</a> for more details.
778        /// </param>
779        /// <param name="key">
780        /// Name of the key to press or a character to generate, such as <c>ArrowLeft</c> or
781        /// <c>a</c>.
782        /// </param>
783        /// <param name="options">Call options</param>
784        Task PressAsync(string selector, string key, FramePressOptions? options = default);
785
786        /// <summary>
787        /// <para>Returns the ElementHandle pointing to the frame element.</para>
788        /// <para>
789        /// The method finds an element matching the specified selector within the frame. See
790        /// <a href="https://playwright.dev/dotnet/docs/selectors">Working with selectors</a>
791        /// for more details. If no elements match the selector, returns <c>null</c>.
792        /// </para>
793        /// </summary>
794        /// <remarks>
795        /// <para>
796        /// The use of <see cref="IElementHandle"/> is discouraged, use <see cref="ILocator"/>
797        /// objects and web-first assertions instead.
798        /// </para>
799        /// </remarks>
800        /// <param name="selector">
801        /// A selector to query for. See <a href="https://playwright.dev/dotnet/docs/selectors">working
802        /// with selectors</a> for more details.
803        /// </param>
804        /// <param name="options">Call options</param>
805        Task<IElementHandle?> QuerySelectorAsync(string selector, FrameQuerySelectorOptions? options = default);
806
807        /// <summary>
808        /// <para>Returns the ElementHandles pointing to the frame elements.</para>
809        /// <para>
810        /// The method finds all elements matching the specified selector within the frame.
811        /// See <a href="https://playwright.dev/dotnet/docs/selectors">Working with selectors</a>
812        /// for more details. If no elements match the selector, returns empty array.
813        /// </para>
814        /// </summary>
815        /// <remarks>
816        /// <para>
817        /// The use of <see cref="IElementHandle"/> is discouraged, use <see cref="ILocator"/>
818        /// objects instead.
819        /// </para>
820        /// </remarks>
821        /// <param name="selector">
822        /// A selector to query for. See <a href="https://playwright.dev/dotnet/docs/selectors">working
823        /// with selectors</a> for more details.
824        /// </param>
825        Task<IReadOnlyList<IElementHandle>> QuerySelectorAllAsync(string selector);
826
827        /// <summary>
828        /// <para>
829        /// This method waits for an element matching <paramref name="selector"/>, waits for
830        /// <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a> checks,
831        /// waits until all specified options are present in the <c>&lt;select&gt;</c> element
832        /// and selects these options.
833        /// </para>
834        /// <para>
835        /// If the target element is not a <c>&lt;select&gt;</c> element, this method throws
836        /// an error. However, if the element is inside the <c>&lt;label&gt;</c> element that
837        /// has an associated <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>,
838        /// the control will be used instead.
839        /// </para>
840        /// <para>Returns the array of option values that have been successfully selected.</para>
841        /// <para>
842        /// Triggers a <c>change</c> and <c>input</c> event once all the provided options have
843        /// been selected.
844        /// </para>
845        /// <code>
846        /// // single selection matching the value<br/>
847        /// await frame.SelectOptionAsync("select#colors", new[] { "blue" });<br/>
848        /// // single selection matching both the value and the label<br/>
849        /// await frame.SelectOptionAsync("select#colors", new[] { new SelectOptionValue() { Label = "blue" } });<br/>
850        /// // multiple selection<br/>
851        /// await frame.SelectOptionAsync("select#colors", new[] { "red", "green", "blue" });
852        /// </code>
853        /// </summary>
854        /// <param name="selector">
855        /// A selector to query for. See <a href="https://playwright.dev/dotnet/docs/selectors">working
856        /// with selectors</a> for more details.
857        /// </param>
858        /// <param name="values">
859        /// Options to select. If the <c>&lt;select&gt;</c> has the <c>multiple</c> attribute,
860        /// all matching options are selected, otherwise only the first option matching one
861        /// of the passed options is selected. String values are equivalent to <c>{value:'string'}</c>.
862        /// Option is considered matching if all specified properties match.
863        /// </param>
864        /// <param name="options">Call options</param>
865        Task<IReadOnlyList<string>> SelectOptionAsync(string selector, string values, FrameSelectOptionOptions? options = default);
866
867        /// <summary>
868        /// <para>
869        /// This method waits for an element matching <paramref name="selector"/>, waits for
870        /// <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a> checks,
871        /// waits until all specified options are present in the <c>&lt;select&gt;</c> element
872        /// and selects these options.
873        /// </para>
874        /// <para>
875        /// If the target element is not a <c>&lt;select&gt;</c> element, this method throws
876        /// an error. However, if the element is inside the <c>&lt;label&gt;</c> element that
877        /// has an associated <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>,
878        /// the control will be used instead.
879        /// </para>
880        /// <para>Returns the array of option values that have been successfully selected.</para>
881        /// <para>
882        /// Triggers a <c>change</c> and <c>input</c> event once all the provided options have
883        /// been selected.
884        /// </para>
885        /// <code>
886        /// // single selection matching the value<br/>
887        /// await frame.SelectOptionAsync("select#colors", new[] { "blue" });<br/>
888        /// // single selection matching both the value and the label<br/>
889        /// await frame.SelectOptionAsync("select#colors", new[] { new SelectOptionValue() { Label = "blue" } });<br/>
890        /// // multiple selection<br/>
891        /// await frame.SelectOptionAsync("select#colors", new[] { "red", "green", "blue" });
892        /// </code>
893        /// </summary>
894        /// <param name="selector">
895        /// A selector to query for. See <a href="https://playwright.dev/dotnet/docs/selectors">working
896        /// with selectors</a> for more details.
897        /// </param>
898        /// <param name="values">
899        /// Options to select. If the <c>&lt;select&gt;</c> has the <c>multiple</c> attribute,
900        /// all matching options are selected, otherwise only the first option matching one
901        /// of the passed options is selected. String values are equivalent to <c>{value:'string'}</c>.
902        /// Option is considered matching if all specified properties match.
903        /// </param>
904        /// <param name="options">Call options</param>
905        Task<IReadOnlyList<string>> SelectOptionAsync(string selector, IElementHandle values, FrameSelectOptionOptions? options = default);
906
907        /// <summary>
908        /// <para>
909        /// This method waits for an element matching <paramref name="selector"/>, waits for
910        /// <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a> checks,
911        /// waits until all specified options are present in the <c>&lt;select&gt;</c> element
912        /// and selects these options.
913        /// </para>
914        /// <para>
915        /// If the target element is not a <c>&lt;select&gt;</c> element, this method throws
916        /// an error. However, if the element is inside the <c>&lt;label&gt;</c> element that
917        /// has an associated <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>,
918        /// the control will be used instead.
919        /// </para>
920        /// <para>Returns the array of option values that have been successfully selected.</para>
921        /// <para>
922        /// Triggers a <c>change</c> and <c>input</c> event once all the provided options have
923        /// been selected.
924        /// </para>
925        /// <code>
926        /// // single selection matching the value<br/>
927        /// await frame.SelectOptionAsync("select#colors", new[] { "blue" });<br/>
928        /// // single selection matching both the value and the label<br/>
929        /// await frame.SelectOptionAsync("select#colors", new[] { new SelectOptionValue() { Label = "blue" } });<br/>
930        /// // multiple selection<br/>
931        /// await frame.SelectOptionAsync("select#colors", new[] { "red", "green", "blue" });
932        /// </code>
933        /// </summary>
934        /// <param name="selector">
935        /// A selector to query for. See <a href="https://playwright.dev/dotnet/docs/selectors">working
936        /// with selectors</a> for more details.
937        /// </param>
938        /// <param name="values">
939        /// Options to select. If the <c>&lt;select&gt;</c> has the <c>multiple</c> attribute,
940        /// all matching options are selected, otherwise only the first option matching one
941        /// of the passed options is selected. String values are equivalent to <c>{value:'string'}</c>.
942        /// Option is considered matching if all specified properties match.
943        /// </param>
944        /// <param name="options">Call options</param>
945        Task<IReadOnlyList<string>> SelectOptionAsync(string selector, IEnumerable<string> values, FrameSelectOptionOptions? options = default);
946
947        /// <summary>
948        /// <para>
949        /// This method waits for an element matching <paramref name="selector"/>, waits for
950        /// <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a> checks,
951        /// waits until all specified options are present in the <c>&lt;select&gt;</c> element
952        /// and selects these options.
953        /// </para>
954        /// <para>
955        /// If the target element is not a <c>&lt;select&gt;</c> element, this method throws
956        /// an error. However, if the element is inside the <c>&lt;label&gt;</c> element that
957        /// has an associated <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>,
958        /// the control will be used instead.
959        /// </para>
960        /// <para>Returns the array of option values that have been successfully selected.</para>
961        /// <para>
962        /// Triggers a <c>change</c> and <c>input</c> event once all the provided options have
963        /// been selected.
964        /// </para>
965        /// <code>
966        /// // single selection matching the value<br/>
967        /// await frame.SelectOptionAsync("select#colors", new[] { "blue" });<br/>
968        /// // single selection matching both the value and the label<br/>
969        /// await frame.SelectOptionAsync("select#colors", new[] { new SelectOptionValue() { Label = "blue" } });<br/>
970        /// // multiple selection<br/>
971        /// await frame.SelectOptionAsync("select#colors", new[] { "red", "green", "blue" });
972        /// </code>
973        /// </summary>
974        /// <param name="selector">
975        /// A selector to query for. See <a href="https://playwright.dev/dotnet/docs/selectors">working
976        /// with selectors</a> for more details.
977        /// </param>
978        /// <param name="values">
979        /// Options to select. If the <c>&lt;select&gt;</c> has the <c>multiple</c> attribute,
980        /// all matching options are selected, otherwise only the first option matching one
981        /// of the passed options is selected. String values are equivalent to <c>{value:'string'}</c>.
982        /// Option is considered matching if all specified properties match.
983        /// </param>
984        /// <param name="options">Call options</param>
985        Task<IReadOnlyList<string>> SelectOptionAsync(string selector, SelectOptionValue values, FrameSelectOptionOptions? options = default);
986
987        /// <summary>
988        /// <para>
989        /// This method waits for an element matching <paramref name="selector"/>, waits for
990        /// <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a> checks,
991        /// waits until all specified options are present in the <c>&lt;select&gt;</c> element
992        /// and selects these options.
993        /// </para>
994        /// <para>
995        /// If the target element is not a <c>&lt;select&gt;</c> element, this method throws
996        /// an error. However, if the element is inside the <c>&lt;label&gt;</c> element that
997        /// has an associated <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>,
998        /// the control will be used instead.
999        /// </para>
1000        /// <para>Returns the array of option values that have been successfully selected.</para>
1001        /// <para>
1002        /// Triggers a <c>change</c> and <c>input</c> event once all the provided options have
1003        /// been selected.
1004        /// </para>
1005        /// <code>
1006        /// // single selection matching the value<br/>
1007        /// await frame.SelectOptionAsync("select#colors", new[] { "blue" });<br/>
1008        /// // single selection matching both the value and the label<br/>
1009        /// await frame.SelectOptionAsync("select#colors", new[] { new SelectOptionValue() { Label = "blue" } });<br/>
1010        /// // multiple selection<br/>
1011        /// await frame.SelectOptionAsync("select#colors", new[] { "red", "green", "blue" });
1012        /// </code>
1013        /// </summary>
1014        /// <param name="selector">
1015        /// A selector to query for. See <a href="https://playwright.dev/dotnet/docs/selectors">working
1016        /// with selectors</a> for more details.
1017        /// </param>
1018        /// <param name="values">
1019        /// Options to select. If the <c>&lt;select&gt;</c> has the <c>multiple</c> attribute,
1020        /// all matching options are selected, otherwise only the first option matching one
1021        /// of the passed options is selected. String values are equivalent to <c>{value:'string'}</c>.
1022        /// Option is considered matching if all specified properties match.
1023        /// </param>
1024        /// <param name="options">Call options</param>
1025        Task<IReadOnlyList<string>> SelectOptionAsync(string selector, IEnumerable<IElementHandle> values, FrameSelectOptionOptions? options = default);
1026
1027        /// <summary>
1028        /// <para>
1029        /// This method waits for an element matching <paramref name="selector"/>, waits for
1030        /// <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a> checks,
1031        /// waits until all specified options are present in the <c>&lt;select&gt;</c> element
1032        /// and selects these options.
1033        /// </para>
1034        /// <para>
1035        /// If the target element is not a <c>&lt;select&gt;</c> element, this method throws
1036        /// an error. However, if the element is inside the <c>&lt;label&gt;</c> element that
1037        /// has an associated <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>,
1038        /// the control will be used instead.
1039        /// </para>
1040        /// <para>Returns the array of option values that have been successfully selected.</para>
1041        /// <para>
1042        /// Triggers a <c>change</c> and <c>input</c> event once all the provided options have
1043        /// been selected.
1044        /// </para>
1045        /// <code>
1046        /// // single selection matching the value<br/>
1047        /// await frame.SelectOptionAsync("select#colors", new[] { "blue" });<br/>
1048        /// // single selection matching both the value and the label<br/>
1049        /// await frame.SelectOptionAsync("select#colors", new[] { new SelectOptionValue() { Label = "blue" } });<br/>
1050        /// // multiple selection<br/>
1051        /// await frame.SelectOptionAsync("select#colors", new[] { "red", "green", "blue" });
1052        /// </code>
1053        /// </summary>
1054        /// <param name="selector">
1055        /// A selector to query for. See <a href="https://playwright.dev/dotnet/docs/selectors">working
1056        /// with selectors</a> for more details.
1057        /// </param>
1058        /// <param name="values">
1059        /// Options to select. If the <c>&lt;select&gt;</c> has the <c>multiple</c> attribute,
1060        /// all matching options are selected, otherwise only the first option matching one
1061        /// of the passed options is selected. String values are equivalent to <c>{value:'string'}</c>.
1062        /// Option is considered matching if all specified properties match.
1063        /// </param>
1064        /// <param name="options">Call options</param>
1065        Task<IReadOnlyList<string>> SelectOptionAsync(string selector, IEnumerable<SelectOptionValue> values, FrameSelectOptionOptions? options = default);
1066
1067        /// <summary>
1068        /// <para>
1069        /// This method checks or unchecks an element matching <paramref name="selector"/> by
1070        /// performing the following steps:
1071        /// </para>
1072        /// <list type="ordinal">
1073        /// <item><description>
1074        /// Find an element matching <paramref name="selector"/>. If there is none, wait until
1075        /// a matching element is attached to the DOM.
1076        /// </description></item>
1077        /// <item><description>
1078        /// Ensure that matched element is a checkbox or a radio input. If not, this method
1079        /// throws.
1080        /// </description></item>
1081        /// <item><description>If the element already has the right checked state, this method returns immediately.</description></item>
1082        /// <item><description>
1083        /// Wait for <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
1084        /// checks on the matched element, unless <paramref name="force"/> option is set. If
1085        /// the element is detached during the checks, the whole action is retried.
1086        /// </description></item>
1087        /// <item><description>Scroll the element into view if needed.</description></item>
1088        /// <item><description>Use <see cref="IPage.Mouse"/> to click in the center of the element.</description></item>
1089        /// <item><description>
1090        /// Wait for initiated navigations to either succeed or fail, unless <paramref name="noWaitAfter"/>
1091        /// option is set.
1092        /// </description></item>
1093        /// <item><description>Ensure that the element is now checked or unchecked. If not, this method throws.</description></item>
1094        /// </list>
1095        /// <para>
1096        /// When all steps combined have not finished during the specified <paramref name="timeout"/>,
1097        /// this method throws a <see cref="TimeoutException"/>. Passing zero timeout disables
1098        /// this.
1099        /// </para>
1100        /// </summary>
1101        /// <param name="selector">
1102        /// A selector to search for an element. If there are multiple elements satisfying the
1103        /// selector, the first will be used. See <a href="https://playwright.dev/dotnet/docs/selectors">working
1104        /// with selectors</a> for more details.
1105        /// </param>
1106        /// <param name="checkedState">Whether to check or uncheck the checkbox.</param>
1107        /// <param name="options">Call options</param>
1108        Task SetCheckedAsync(string selector, bool checkedState, FrameSetCheckedOptions? options = default);
1109
1110        /// <param name="html">HTML markup to assign to the page.</param>
1111        /// <param name="options">Call options</param>
1112        Task SetContentAsync(string html, FrameSetContentOptions? options = default);
1113
1114        /// <summary>
1115        /// <para>
1116        /// This method expects <paramref name="selector"/> to point to an <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">input
1117        /// element</a>.
1118        /// </para>
1119        /// <para>
1120        /// Sets the value of the file input to these file paths or files. If some of the <c>filePaths</c>
1121        /// are relative paths, then they are resolved relative to the the current working directory.
1122        /// For empty array, clears the selected files.
1123        /// </para>
1124        /// </summary>
1125        /// <param name="selector">
1126        /// A selector to search for an element. If there are multiple elements satisfying the
1127        /// selector, the first will be used. See <a href="https://playwright.dev/dotnet/docs/selectors">working
1128        /// with selectors</a> for more details.
1129        /// </param>
1130        /// <param name="files">
1131        /// </param>
1132        /// <param name="options">Call options</param>
1133        Task SetInputFilesAsync(string selector, string files, FrameSetInputFilesOptions? options = default);
1134
1135        /// <summary>
1136        /// <para>
1137        /// This method expects <paramref name="selector"/> to point to an <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">input
1138        /// element</a>.
1139        /// </para>
1140        /// <para>
1141        /// Sets the value of the file input to these file paths or files. If some of the <c>filePaths</c>
1142        /// are relative paths, then they are resolved relative to the the current working directory.
1143        /// For empty array, clears the selected files.
1144        /// </para>
1145        /// </summary>
1146        /// <param name="selector">
1147        /// A selector to search for an element. If there are multiple elements satisfying the
1148        /// selector, the first will be used. See <a href="https://playwright.dev/dotnet/docs/selectors">working
1149        /// with selectors</a> for more details.
1150        /// </param>
1151        /// <param name="files">
1152        /// </param>
1153        /// <param name="options">Call options</param>
1154        Task SetInputFilesAsync(string selector, IEnumerable<string> files, FrameSetInputFilesOptions? options = default);
1155
1156        /// <summary>
1157        /// <para>
1158        /// This method expects <paramref name="selector"/> to point to an <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">input
1159        /// element</a>.
1160        /// </para>
1161        /// <para>
1162        /// Sets the value of the file input to these file paths or files. If some of the <c>filePaths</c>
1163        /// are relative paths, then they are resolved relative to the the current working directory.
1164        /// For empty array, clears the selected files.
1165        /// </para>
1166        /// </summary>
1167        /// <param name="selector">
1168        /// A selector to search for an element. If there are multiple elements satisfying the
1169        /// selector, the first will be used. See <a href="https://playwright.dev/dotnet/docs/selectors">working
1170        /// with selectors</a> for more details.
1171        /// </param>
1172        /// <param name="files">
1173        /// </param>
1174        /// <param name="options">Call options</param>
1175        Task SetInputFilesAsync(string selector, FilePayload files, FrameSetInputFilesOptions? options = default);
1176
1177        /// <summary>
1178        /// <para>
1179        /// This method expects <paramref name="selector"/> to point to an <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">input
1180        /// element</a>.
1181        /// </para>
1182        /// <para>
1183        /// Sets the value of the file input to these file paths or files. If some of the <c>filePaths</c>
1184        /// are relative paths, then they are resolved relative to the the current working directory.
1185        /// For empty array, clears the selected files.
1186        /// </para>
1187        /// </summary>
1188        /// <param name="selector">
1189        /// A selector to search for an element. If there are multiple elements satisfying the
1190        /// selector, the first will be used. See <a href="https://playwright.dev/dotnet/docs/selectors">working
1191        /// with selectors</a> for more details.
1192        /// </param>
1193        /// <param name="files">
1194        /// </param>
1195        /// <param name="options">Call options</param>
1196        Task SetInputFilesAsync(string selector, IEnumerable<FilePayload> files, FrameSetInputFilesOptions? options = default);
1197
1198        /// <summary>
1199        /// <para>
1200        /// This method taps an element matching <paramref name="selector"/> by performing the
1201        /// following steps:
1202        /// </para>
1203        /// <list type="ordinal">
1204        /// <item><description>
1205        /// Find an element matching <paramref name="selector"/>. If there is none, wait until
1206        /// a matching element is attached to the DOM.
1207        /// </description></item>
1208        /// <item><description>
1209        /// Wait for <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
1210        /// checks on the matched element, unless <paramref name="force"/> option is set. If
1211        /// the element is detached during the checks, the whole action is retried.
1212        /// </description></item>
1213        /// <item><description>Scroll the element into view if needed.</description></item>
1214        /// <item><description>
1215        /// Use <see cref="IPage.Touchscreen"/> to tap the center of the element, or the specified
1216        /// <paramref name="position"/>.
1217        /// </description></item>
1218        /// <item><description>
1219        /// Wait for initiated navigations to either succeed or fail, unless <paramref name="noWaitAfter"/>
1220        /// option is set.
1221        /// </description></item>
1222        /// </list>
1223        /// <para>
1224        /// When all steps combined have not finished during the specified <paramref name="timeout"/>,
1225        /// this method throws a <see cref="TimeoutException"/>. Passing zero timeout disables
1226        /// this.
1227        /// </para>
1228        /// </summary>
1229        /// <remarks>
1230        /// <para>
1231        /// <c>frame.tap()</c> requires that the <c>hasTouch</c> option of the browser context
1232        /// be set to true.
1233        /// </para>
1234        /// </remarks>
1235        /// <param name="selector">
1236        /// A selector to search for an element. If there are multiple elements satisfying the
1237        /// selector, the first will be used. See <a href="https://playwright.dev/dotnet/docs/selectors">working
1238        /// with selectors</a> for more details.
1239        /// </param>
1240        /// <param name="options">Call options</param>
1241        Task TapAsync(string selector, FrameTapOptions? options = default);
1242
1243        /// <summary><para>Returns <c>element.textContent</c>.</para></summary>
1244        /// <param name="selector">
1245        /// A selector to search for an element. If there are multiple elements satisfying the
1246        /// selector, the first will be used. See <a href="https://playwright.dev/dotnet/docs/selectors">working
1247        /// with selectors</a> for more details.
1248        /// </param>
1249        /// <param name="options">Call options</param>
1250        Task<string?> TextContentAsync(string selector, FrameTextContentOptions? options = default);
1251
1252        /// <summary><para>Returns the page title.</para></summary>
1253        Task<string> TitleAsync();
1254
1255        /// <summary>
1256        /// <para>
1257        /// Sends a <c>keydown</c>, <c>keypress</c>/<c>input</c>, and <c>keyup</c> event for
1258        /// each character in the text. <c>frame.type</c> can be used to send fine-grained keyboard
1259        /// events. To fill values in form fields, use <see cref="IFrame.FillAsync"/>.
1260        /// </para>
1261        /// <para>To press a special key, like <c>Control</c> or <c>ArrowDown</c>, use <see cref="IKeyboard.PressAsync"/>.</para>
1262        /// <code>
1263        /// await frame.TypeAsync("#mytextarea", "hello"); // types instantly<br/>
1264        /// await frame.TypeAsync("#mytextarea", "world", delay: 100); // types slower, like a user
1265        /// </code>
1266        /// </summary>
1267        /// <param name="selector">
1268        /// A selector to search for an element. If there are multiple elements satisfying the
1269        /// selector, the first will be used. See <a href="https://playwright.dev/dotnet/docs/selectors">working
1270        /// with selectors</a> for more details.
1271        /// </param>
1272        /// <param name="text">A text to type into a focused element.</param>
1273        /// <param name="options">Call options</param>
1274        Task TypeAsync(string selector, string text, FrameTypeOptions? options = default);
1275
1276        /// <summary>
1277        /// <para>
1278        /// This method checks an element matching <paramref name="selector"/> by performing
1279        /// the following steps:
1280        /// </para>
1281        /// <list type="ordinal">
1282        /// <item><description>
1283        /// Find an element matching <paramref name="selector"/>. If there is none, wait until
1284        /// a matching element is attached to the DOM.
1285        /// </description></item>
1286        /// <item><description>
1287        /// Ensure that matched element is a checkbox or a radio input. If not, this method
1288        /// throws. If the element is already unchecked, this method returns immediately.
1289        /// </description></item>
1290        /// <item><description>
1291        /// Wait for <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
1292        /// checks on the matched element, unless <paramref name="force"/> option is set. If
1293        /// the element is detached during the checks, the whole action is retried.
1294        /// </description></item>
1295        /// <item><description>Scroll the element into view if needed.</description></item>
1296        /// <item><description>Use <see cref="IPage.Mouse"/> to click in the center of the element.</description></item>
1297        /// <item><description>
1298        /// Wait for initiated navigations to either succeed or fail, unless <paramref name="noWaitAfter"/>
1299        /// option is set.
1300        /// </description></item>
1301        /// <item><description>Ensure that the element is now unchecked. If not, this method throws.</description></item>
1302        /// </list>
1303        /// <para>
1304        /// When all steps combined have not finished during the specified <paramref name="timeout"/>,
1305        /// this method throws a <see cref="TimeoutException"/>. Passing zero timeout disables
1306        /// this.
1307        /// </para>
1308        /// </summary>
1309        /// <param name="selector">
1310        /// A selector to search for an element. If there are multiple elements satisfying the
1311        /// selector, the first will be used. See <a href="https://playwright.dev/dotnet/docs/selectors">working
1312        /// with selectors</a> for more details.
1313        /// </param>
1314        /// <param name="options">Call options</param>
1315        Task UncheckAsync(string selector, FrameUncheckOptions? options = default);
1316
1317        /// <summary><para>Returns frame's url.</para></summary>
1318        string Url { get; }
1319
1320        /// <summary>
1321        /// <para>
1322        /// Returns when the <paramref name="expression"/> returns a truthy value, returns that
1323        /// value.
1324        /// </para>
1325        /// <para>
1326        /// The <see cref="IFrame.WaitForFunctionAsync"/> can be used to observe viewport size
1327        /// change:
1328        /// </para>
1329        /// <code>
1330        /// using Microsoft.Playwright;<br/>
1331        /// using System.Threading.Tasks;<br/>
1332        /// <br/>
1333        /// class FrameExamples<br/>
1334        /// {<br/>
1335        ///     public static async Task Main()<br/>
1336        ///     {<br/>
1337        ///         using var playwright = await Playwright.CreateAsync();<br/>
1338        ///         await using var browser = await playwright.Firefox.LaunchAsync();<br/>
1339        ///         var page = await browser.NewPageAsync();<br/>
1340        ///         await page.SetViewportSizeAsync(50, 50);<br/>
1341        ///         await page.MainFrame.WaitForFunctionAsync("window.innerWidth &lt; 100");<br/>
1342        ///     }<br/>
1343        /// }
1344        /// </code>
1345        /// <para>To pass an argument to the predicate of <c>frame.waitForFunction</c> function:</para>
1346        /// <code>
1347        /// var selector = ".foo";<br/>
1348        /// await page.MainFrame.WaitForFunctionAsync("selector =&gt; !!document.querySelector(selector)", selector);
1349        /// </code>
1350        /// </summary>
1351        /// <param name="expression">
1352        /// JavaScript expression to be evaluated in the browser context. If it looks like a
1353        /// function declaration, it is interpreted as a function. Otherwise, evaluated as an
1354        /// expression.
1355        /// </param>
1356        /// <param name="arg">Optional argument to pass to <paramref name="expression"/>.</param>
1357        /// <param name="options">Call options</param>
1358        Task<IJSHandle> WaitForFunctionAsync(string expression, object? arg = default, FrameWaitForFunctionOptions? options = default);
1359
1360        /// <summary>
1361        /// <para>Waits for the required load state to be reached.</para>
1362        /// <para>
1363        /// This returns when the frame reaches a required load state, <c>load</c> by default.
1364        /// The navigation must have been committed when this method is called. If current document
1365        /// has already reached the required state, resolves immediately.
1366        /// </para>
1367        /// <code>
1368        /// await frame.ClickAsync("button");<br/>
1369        /// await frame.WaitForLoadStateAsync(); // Defaults to LoadState.Load
1370        /// </code>
1371        /// </summary>
1372        /// <param name="state">
1373        /// Optional load state to wait for, defaults to <c>load</c>. If the state has been
1374        /// already reached while loading current document, the method resolves immediately.
1375        /// Can be one of:
1376        /// <list type="bullet">
1377        /// <item><description><c>'load'</c> - wait for the <c>load</c> event to be fired.</description></item>
1378        /// <item><description><c>'domcontentloaded'</c> - wait for the <c>DOMContentLoaded</c> event to be fired.</description></item>
1379        /// <item><description>
1380        /// <c>'networkidle'</c> - wait until there are no network connections for at least
1381        /// <c>500</c> ms.
1382        /// </description></item>
1383        /// </list>
1384        /// </param>
1385        /// <param name="options">Call options</param>
1386        Task WaitForLoadStateAsync(LoadState? state = default, FrameWaitForLoadStateOptions? options = default);
1387
1388        /// <summary>
1389        /// <para>
1390        /// Waits for the frame navigation and returns the main resource response. In case of
1391        /// multiple redirects, the navigation will resolve with the response of the last redirect.
1392        /// In case of navigation to a different anchor or navigation due to History API usage,
1393        /// the navigation will resolve with <c>null</c>.
1394        /// </para>
1395        /// <para>
1396        /// This method waits for the frame to navigate to a new URL. It is useful for when
1397        /// you run code which will indirectly cause the frame to navigate. Consider this example:
1398        /// </para>
1399        /// <code>
1400        /// await frame.RunAndWaitForNavigationAsync(async () =&gt;<br/>
1401        /// {<br/>
1402        ///     // Clicking the link will indirectly cause a navigation.<br/>
1403        ///     await frame.ClickAsync("a.delayed-navigation");<br/>
1404        /// });<br/>
1405        /// <br/>
1406        /// // Resolves after navigation has finished
1407        /// </code>
1408        /// </summary>
1409        /// <remarks>
1410        /// <para>
1411        /// Usage of the <a href="https://developer.mozilla.org/en-US/docs/Web/API/History_API">History
1412        /// API</a> to change the URL is considered a navigation.
1413        /// </para>
1414        /// </remarks>
1415        /// <param name="options">Call options</param>
1416        Task<IResponse?> WaitForNavigationAsync(FrameWaitForNavigationOptions? options = default);
1417
1418        /// <summary>
1419        /// <para>
1420        /// Waits for the frame navigation and returns the main resource response. In case of
1421        /// multiple redirects, the navigation will resolve with the response of the last redirect.
1422        /// In case of navigation to a different anchor or navigation due to History API usage,
1423        /// the navigation will resolve with <c>null</c>.
1424        /// </para>
1425        /// <para>
1426        /// This method waits for the frame to navigate to a new URL. It is useful for when
1427        /// you run code which will indirectly cause the frame to navigate. Consider this example:
1428        /// </para>
1429        /// <code>
1430        /// await frame.RunAndWaitForNavigationAsync(async () =&gt;<br/>
1431        /// {<br/>
1432        ///     // Clicking the link will indirectly cause a navigation.<br/>
1433        ///     await frame.ClickAsync("a.delayed-navigation");<br/>
1434        /// });<br/>
1435        /// <br/>
1436        /// // Resolves after navigation has finished
1437        /// </code>
1438        /// </summary>
1439        /// <remarks>
1440        /// <para>
1441        /// Usage of the <a href="https://developer.mozilla.org/en-US/docs/Web/API/History_API">History
1442        /// API</a> to change the URL is considered a navigation.
1443        /// </para>
1444        /// </remarks>
1445        /// <param name="action">Action that triggers the event.</param>
1446        /// <param name="options">Call options</param>
1447        Task<IResponse?> RunAndWaitForNavigationAsync(Func<Task> action, FrameRunAndWaitForNavigationOptions? options = default);
1448
1449        /// <summary>
1450        /// <para>
1451        /// Returns when element specified by selector satisfies <paramref name="state"/> option.
1452        /// Returns <c>null</c> if waiting for <c>hidden</c> or <c>detached</c>.
1453        /// </para>
1454        /// <para>
1455        /// Wait for the <paramref name="selector"/> to satisfy <paramref name="state"/> option
1456        /// (either appear/disappear from dom, or become visible/hidden). If at the moment of
1457        /// calling the method <paramref name="selector"/> already satisfies the condition,
1458        /// the method will return immediately. If the selector doesn't satisfy the condition
1459        /// for the <paramref name="timeout"/> milliseconds, the function will throw.
1460        /// </para>
1461        /// <para>This method works across navigations:</para>
1462        /// <code>
1463        /// using Microsoft.Playwright;<br/>
1464        /// using System;<br/>
1465        /// using System.Threading.Tasks;<br/>
1466        /// <br/>
1467        /// class FrameExamples<br/>
1468        /// {<br/>
1469        ///     public static async Task Main()<br/>
1470        ///     {<br/>
1471        ///         using var playwright = await Playwright.CreateAsync();<br/>
1472        ///         await using var browser = await playwright.Chromium.LaunchAsync();<br/>
1473        ///         var page = await browser.NewPageAsync();<br/>
1474        /// <br/>
1475        ///         foreach (var currentUrl in new[] { "https://www.google.com", "https://bbc.com" })<br/>
1476        ///         {<br/>
1477        ///             await page.GotoAsync(currentUrl);<br/>
1478        ///             element = await page.MainFrame.WaitForSelectorAsync("img");<br/>
1479        ///             Console.WriteLine($"Loaded image: {await element.GetAttributeAsync("src")}");<br/>
1480        ///         }<br/>
1481        ///     }<br/>
1482        /// }
1483        /// </code>
1484        /// </summary>
1485        /// <remarks>
1486        /// <para>
1487        /// Playwright automatically waits for element to be ready before performing an action.
1488        /// Using <see cref="ILocator"/> objects and web-first assertions make the code wait-for-selector-free.
1489        /// </para>
1490        /// </remarks>
1491        /// <param name="selector">
1492        /// A selector to query for. See <a href="https://playwright.dev/dotnet/docs/selectors">working
1493        /// with selectors</a> for more details.
1494        /// </param>
1495        /// <param name="options">Call options</param>
1496        Task<IElementHandle?> WaitForSelectorAsync(string selector, FrameWaitForSelectorOptions? options = default);
1497
1498        /// <summary>
1499        /// <para>Waits for the given <paramref name="timeout"/> in milliseconds.</para>
1500        /// <para>
1501        /// Note that <c>frame.waitForTimeout()</c> should only be used for debugging. Tests
1502        /// using the timer in production are going to be flaky. Use signals such as network
1503        /// events, selectors becoming visible and others instead.
1504        /// </para>
1505        /// </summary>
1506        /// <param name="timeout">A timeout to wait for</param>
1507        Task WaitForTimeoutAsync(float timeout);
1508
1509        /// <summary>
1510        /// <para>Waits for the frame to navigate to the given URL.</para>
1511        /// <code>
1512        /// await frame.ClickAsync("a.delayed-navigation"); // clicking the link will indirectly cause a navigation<br/>
1513        /// await frame.WaitForURLAsync("**/target.html");
1514        /// </code>
1515        /// </summary>
1516        /// <param name="url">
1517        /// A glob pattern, regex pattern or predicate receiving <see cref="URL"/> to match
1518        /// while waiting for the navigation. Note that if the parameter is a string without
1519        /// wildcard characters, the method will wait for navigation to URL that is exactly
1520        /// equal to the string.
1521        /// </param>
1522        /// <param name="options">Call options</param>
1523        Task WaitForURLAsync(string url, FrameWaitForURLOptions? options = default);
1524
1525        /// <summary>
1526        /// <para>Waits for the frame to navigate to the given URL.</para>
1527        /// <code>
1528        /// await frame.ClickAsync("a.delayed-navigation"); // clicking the link will indirectly cause a navigation<br/>
1529        /// await frame.WaitForURLAsync("**/target.html");
1530        /// </code>
1531        /// </summary>
1532        /// <param name="url">
1533        /// A glob pattern, regex pattern or predicate receiving <see cref="URL"/> to match
1534        /// while waiting for the navigation. Note that if the parameter is a string without
1535        /// wildcard characters, the method will wait for navigation to URL that is exactly
1536        /// equal to the string.
1537        /// </param>
1538        /// <param name="options">Call options</param>
1539        Task WaitForURLAsync(Regex url, FrameWaitForURLOptions? options = default);
1540
1541        /// <summary>
1542        /// <para>Waits for the frame to navigate to the given URL.</para>
1543        /// <code>
1544        /// await frame.ClickAsync("a.delayed-navigation"); // clicking the link will indirectly cause a navigation<br/>
1545        /// await frame.WaitForURLAsync("**/target.html");
1546        /// </code>
1547        /// </summary>
1548        /// <param name="url">
1549        /// A glob pattern, regex pattern or predicate receiving <see cref="URL"/> to match
1550        /// while waiting for the navigation. Note that if the parameter is a string without
1551        /// wildcard characters, the method will wait for navigation to URL that is exactly
1552        /// equal to the string.
1553        /// </param>
1554        /// <param name="options">Call options</param>
1555        Task WaitForURLAsync(Func<string, bool> url, FrameWaitForURLOptions? options = default);
1556    }
1557}
1558
1559#nullable disable
1560
Full Screen