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

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

Run Playwright-dotnet automation tests on LambdaTest cloud grid

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

PageSetCheckedOptions.cs

Source: PageSetCheckedOptions.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 PageSetCheckedOptions
43    {
44        public PageSetCheckedOptions() { }
45
46        public PageSetCheckedOptions(PageSetCheckedOptions clone)
47        {
48            if (clone == null)
49            {
50                return;
51            }
52
53            Force = clone.Force;
54            NoWaitAfter = clone.NoWaitAfter;
55            Position = clone.Position;
56            Strict = clone.Strict;
57            Timeout = clone.Timeout;
58            Trial = clone.Trial;
59        }
60
61        /// <summary>
62        /// <para>
63        /// Whether to bypass the <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
64        /// checks. Defaults to <c>false</c>.
65        /// </para>
66        /// </summary>
67        [JsonPropertyName("force")]
68        public bool? Force { get; set; }
69
70        /// <summary>
71        /// <para>
72        /// Actions that initiate navigations are waiting for these navigations to happen and
73        /// for pages to start loading. You can opt out of waiting via setting this flag. You
74        /// would only need this option in the exceptional cases such as navigating to inaccessible
75        /// pages. Defaults to <c>false</c>.
76        /// </para>
77        /// </summary>
78        [JsonPropertyName("noWaitAfter")]
79        public bool? NoWaitAfter { get; set; }
80
81        /// <summary>
82        /// <para>
83        /// A point to use relative to the top-left corner of element padding box. If not specified,
84        /// uses some visible point of the element.
85        /// </para>
86        /// </summary>
87        [JsonPropertyName("position")]
88        public Position? Position { get; set; }
89
90        /// <summary>
91        /// <para>
92        /// When true, the call requires selector to resolve to a single element. If given selector
93        /// resolves to more then one element, the call throws an exception.
94        /// </para>
95        /// </summary>
96        [JsonPropertyName("strict")]
97        public bool? Strict { get; set; }
98
99        /// <summary>
100        /// <para>
101        /// Maximum time in milliseconds, defaults to 30 seconds, pass <c>0</c> to disable timeout.
102        /// The default value can be changed by using the <see cref="IBrowserContext.SetDefaultTimeout"/>
103        /// or <see cref="IPage.SetDefaultTimeout"/> methods.
104        /// </para>
105        /// </summary>
106        [JsonPropertyName("timeout")]
107        public float? Timeout { get; set; }
108
109        /// <summary>
110        /// <para>
111        /// When set, this method only performs the <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
112        /// checks and skips the action. Defaults to <c>false</c>. Useful to wait until the
113        /// element is ready for the action without performing it.
114        /// </para>
115        /// </summary>
116        [JsonPropertyName("trial")]
117        public bool? Trial { get; set; }
118    }
119}
120
121#nullable disable
122
Full Screen

PageDriver.cs

Source: PageDriver.cs Github

copy
1using Microsoft.Playwright;
2using System;
3using System.Collections.Generic;
4using System.Text.Json;
5using System.Text.RegularExpressions;
6
7namespace CognizantSoftvision.Maqs.BasePlaywrightTest
8{
9    /// <summary>
10    /// Playwright page driver
11    /// </summary>
12    public class PageDriver : IDisposable
13    {
14        /// <summary>
15        /// Initializes a new instance of the <see cref="PageDriver"/> class
16        /// </summary>
17        /// <param name="page">Base page object</param>
18        public PageDriver(IPage page)
19        {
20            this.AsyncPage = page;
21        }
22
23        /// <summary>
24        /// Gets the underlying async page object
25        /// </summary>
26        public IPage AsyncPage { get; private set; }
27
28        /// <inheritdoc cref = "IBrowserContext.Browser"  />
29        public IBrowser? ParentBrower { get { return this.AsyncPage.Context.Browser; } }
30
31        /// <inheritdoc cref = "IPage.Url"  />
32        public string Url { get { return this.AsyncPage.Url; } }
33
34        /// <inheritdoc cref = "IPage.IsClosed"  />
35        public bool IsClosed { get { return this.AsyncPage.IsClosed; } }
36
37        /// <inheritdoc cref = "IPage.AddInitScriptAsync" />  
38        public void AddInitScript(string? script = null, string? scriptPath = null)
39        {
40            this.AsyncPage.AddInitScriptAsync(script, scriptPath).Wait();
41        }
42
43        /// <inheritdoc cref = "IPage.BringToFrontAsync" /> 
44        public void BringToFront()
45        {
46            this.AsyncPage.BringToFrontAsync().Wait();
47        }
48
49        /// <inheritdoc cref = "IPage.CheckAsync" /> 
50        public void Check(string selector, PageCheckOptions? options = null)
51        {
52            this.AsyncPage.CheckAsync(selector, options).Wait();
53        }
54
55        /// <inheritdoc cref = "IPage.ClickAsync" /> 
56        public void Click(string selector, PageClickOptions? options = null)
57        {
58            this.AsyncPage.ClickAsync(selector, options).Wait();
59        }
60
61        /// <inheritdoc cref = "IPage.CloseAsync" /> 
62        public void Close(PageCloseOptions? options = null)
63        {
64            this.AsyncPage.CloseAsync(options).Wait();
65        }
66
67        /// <inheritdoc cref = "IPage.DblClickAsync" /> 
68        public void DblClick(string selector, PageDblClickOptions? options = null)
69        {
70            this.AsyncPage.DblClickAsync(selector, options).Wait();
71        }
72
73        /// <inheritdoc cref = "IPage.DispatchEventAsync" /> 
74        public void DispatchEvent(string selector, string type, object? eventInit = null, PageDispatchEventOptions? options = null)
75        {
76            this.AsyncPage.DispatchEventAsync(selector, type, eventInit, options).Wait();
77        }
78
79        /// <inheritdoc cref = "IPage.DragAndDropAsync" /> 
80        public void DragAndDrop(string source, string target, PageDragAndDropOptions? options = null)
81        {
82            this.AsyncPage.DragAndDropAsync(source, target, options).Wait();
83        }
84
85        /// <inheritdoc cref = "IPage.FillAsync" /> 
86        public void Fill(string selector, string value, PageFillOptions? options = null)
87        {
88            this.AsyncPage.FillAsync(selector, value, options).Wait();
89        }
90
91        /// <inheritdoc cref = "IPage.FocusAsync" /> 
92        public void Focus(string selector, PageFocusOptions? options = null)
93        {
94            this.AsyncPage.FocusAsync(selector, options).Wait();
95        }
96
97        /// <inheritdoc cref = "IPage.HoverAsync" /> 
98        public void Hover(string selector, PageHoverOptions? options = null)
99        {
100            this.AsyncPage.HoverAsync(selector, options).Wait();
101        }
102
103        /// <inheritdoc cref = "IPage.PressAsync" /> 
104        public void Press(string selector, string key, PagePressOptions? options = null)
105        {
106            this.AsyncPage.PressAsync(selector, key, options).Wait();
107        }
108
109        /// <inheritdoc cref = "IPage.SetCheckedAsync" /> 
110        public void SetChecked(string selector, bool checkedState, PageSetCheckedOptions? options = null)
111        {
112            this.AsyncPage.SetCheckedAsync(selector, checkedState, options).Wait();
113        }
114
115        /// <inheritdoc cref = "IPage.SetExtraHTTPHeadersAsync" /> 
116        public void SetExtraHTTPHeaders(IEnumerable<KeyValuePair<string, string>> headers)
117        {
118            this.AsyncPage.SetExtraHTTPHeadersAsync(headers).Wait();
119        }
120
121        /// <inheritdoc cref = "IPage.SetInputFilesAsync(string, FilePayload, PageSetInputFilesOptions)" /> 
122        public void SetInputFiles(string selector, FilePayload files, PageSetInputFilesOptions? options = null)
123        {
124            this.AsyncPage.SetInputFilesAsync(selector, files, options).Wait();
125        }
126
127        /// <inheritdoc cref = "IPage.SetInputFilesAsync(string, IEnumerable{FilePayload}, PageSetInputFilesOptions)" /> 
128        public void SetInputFiles(string selector, IEnumerable<FilePayload> files, PageSetInputFilesOptions? options = null)
129        {
130            this.AsyncPage.SetInputFilesAsync(selector, files, options).Wait();
131        }
132
133        /// <inheritdoc cref = "IPage.SetInputFilesAsync(string, IEnumerable{string}, PageSetInputFilesOptions)" /> 
134        public void SetInputFiles(string selector, IEnumerable<string> files, PageSetInputFilesOptions? options = null)
135        {
136            this.AsyncPage.SetInputFilesAsync(selector, files, options).Wait();
137        }
138
139        /// <inheritdoc cref = "IPage.SetInputFilesAsync(string, string, PageSetInputFilesOptions)" /> 
140        public void SetInputFiles(string selector, string files, PageSetInputFilesOptions? options = null)
141        {
142            this.AsyncPage.SetInputFilesAsync(selector, files, options).Wait();
143        }
144
145        /// <inheritdoc cref = "IPage.SetViewportSizeAsync" /> 
146        public void SetViewportSize(int width, int height)
147        {
148            this.AsyncPage.SetViewportSizeAsync(width, height).Wait();
149        }
150
151        /// <inheritdoc cref = "IPage.TapAsync" /> 
152        public void Tap(string selector, PageTapOptions? options = null)
153        {
154            this.AsyncPage.TapAsync(selector, options).Wait();
155        }
156
157        /// <inheritdoc cref = "IPage.TypeAsync" /> 
158        public void Type(string selector, string text, PageTypeOptions? options = null)
159        {
160            this.AsyncPage.TypeAsync(selector, text, options).Wait();
161        }
162
163        /// <inheritdoc cref = "IPage.UncheckAsync" /> 
164        public void Uncheck(string selector, PageUncheckOptions? options = null)
165        {
166            this.AsyncPage.UncheckAsync(selector, options).Wait();
167        }
168
169        /// <inheritdoc cref = "IPage.WaitForLoadStateAsync" /> 
170        public void WaitForLoadState(LoadState? state = null, PageWaitForLoadStateOptions? options = null)
171        {
172            this.AsyncPage.WaitForLoadStateAsync(state, options).Wait();
173        }
174
175        /// <inheritdoc cref = "IPage.WaitForTimeoutAsync" /> 
176        public void WaitForTimeout(float timeout)
177        {
178            this.AsyncPage.WaitForTimeoutAsync(timeout).Wait();
179        }
180
181        /// <inheritdoc cref = "IPage.WaitForURLAsync(Func{string, bool}, PageWaitForURLOptions)" /> 
182        public void WaitForURL(Func<string, bool> url, PageWaitForURLOptions? options = null)
183        {
184            this.AsyncPage.WaitForURLAsync(url, options).Wait();
185        }
186
187        /// <inheritdoc cref = "IPage.WaitForURLAsync(Regex, PageWaitForURLOptions)" /> 
188        public void WaitForURL(Regex url, PageWaitForURLOptions? options = null)
189        {
190            this.AsyncPage.WaitForURLAsync(url, options).Wait();
191        }
192
193        /// <inheritdoc cref = "IPage.WaitForURLAsync(string, PageWaitForURLOptions)" /> 
194        public void WaitForURL(string url, PageWaitForURLOptions? options = null)
195        {
196            this.AsyncPage.WaitForURLAsync(url, options).Wait();
197        }
198
199        /// <inheritdoc cref = "IPage.IsCheckedAsync"  />
200        public bool IsChecked(string selector, PageIsCheckedOptions? options = null)
201        {
202            return this.AsyncPage.IsCheckedAsync(selector, options).Result;
203        }
204
205        /// <inheritdoc cref = "IPage.IsDisabledAsync"  />
206        public bool IsDisabled(string selector, PageIsDisabledOptions? options = null)
207        {
208            return this.AsyncPage.IsDisabledAsync(selector, options).Result;
209        }
210
211        /// <inheritdoc cref = "IPage.IsEditableAsync"  />
212        public bool IsEditable(string selector, PageIsEditableOptions? options = null)
213        {
214            return this.AsyncPage.IsEditableAsync(selector, options).Result;
215        }
216
217        /// <inheritdoc cref = "IPage.IsEnabledAsync"  />
218        public bool IsEnabled(string selector, PageIsEnabledOptions? options = null)
219        {
220            return this.AsyncPage.IsEnabledAsync(selector, options).Result;
221        }
222
223        /// <inheritdoc cref = "IPage.IsHiddenAsync"  />
224        public bool IsHidden(string selector, PageIsHiddenOptions? options = null)
225        {
226            return this.AsyncPage.IsHiddenAsync(selector, options).Result;
227        }
228
229        /// <inheritdoc cref = "IPage.IsVisibleAsync"  />
230        public bool IsVisible(string selector, PageIsVisibleOptions? options = null)
231        {
232            return this.AsyncPage.IsVisibleAsync(selector, options).Result;
233        }
234
235        /// <summary>
236        /// Check that the element is eventually visible
237        /// </summary>
238        /// <param name="selector">Element selector</param>
239        /// <param name="options">Visible check options</param>
240        /// <returns>True if the element becomes visible within the page timeout</returns>
241        public bool IsEventualyVisible(string selector, PageIsVisibleOptions? options = null)
242        {
243            try
244            {
245                _ = this.AsyncPage.WaitForSelectorAsync(selector, new PageWaitForSelectorOptions
246                {
247                    State = WaitForSelectorState.Visible,
248                    Strict = options == null ? false : options.Strict
249                }).Result;
250                return true;
251            }
252            catch
253            {
254                return false;
255            }
256        }
257
258        /// <summary>
259        /// Check that the element stops being visible
260        /// </summary>
261        /// <param name="selector">Element selector</param>
262        /// <param name="options">Visible check options</param>
263        /// <returns>True if the element becomes is hidden or gone within the page timeout</returns>
264        public bool IsEventualyGone(string selector, PageIsVisibleOptions? options = null)
265        {
266            try
267            {
268                _ = this.AsyncPage.WaitForSelectorAsync(selector, new PageWaitForSelectorOptions
269                {
270                    State = WaitForSelectorState.Hidden,
271                    Strict = options == null ? false : options.Strict
272                }).Result;
273                return true;
274            }
275            catch
276            {
277                return false;
278            }
279        }
280
281        /// <inheritdoc cref = "IPage.QuerySelectorAsync"  />
282        public IElementHandle? QuerySelector(string selector, PageQuerySelectorOptions? options = null)
283        {
284            return this.AsyncPage.QuerySelectorAsync(selector, options).Result;
285        }
286
287        /// <inheritdoc cref = "IPage.WaitForSelectorAsync"  />
288        public IElementHandle? WaitForSelector(string selector, PageWaitForSelectorOptions? options = null)
289        {
290            return this.AsyncPage.WaitForSelectorAsync(selector, options).Result;
291        }
292
293        /// <inheritdoc cref = "IPage.AddScriptTagAsync"  />
294        public IElementHandle AddScriptTag(PageAddScriptTagOptions? options = null)
295        {
296            return this.AsyncPage.AddScriptTagAsync(options).Result;
297        }
298
299        /// <inheritdoc cref = "IPage.AddStyleTagAsync"  />
300        public IElementHandle AddStyleTag(PageAddStyleTagOptions? options = null)
301        {
302            return this.AsyncPage.AddStyleTagAsync(options).Result;
303        }
304
305        /// <inheritdoc cref = "IPage.QuerySelectorAllAsync"  />
306        public IReadOnlyList<IElementHandle> QuerySelectorAll(string selector)
307        {
308            return this.AsyncPage.QuerySelectorAllAsync(selector).Result;
309        }
310
311        /// <inheritdoc cref = "IPage.SelectOptionAsync(string, IElementHandle, PageSelectOptionOptions)"  />
312        public IReadOnlyList<string> SelectOption(string selector, IElementHandle values, PageSelectOptionOptions? options = null)
313        {
314            return this.AsyncPage.SelectOptionAsync(selector, values, options).Result;
315        }
316
317        /// <inheritdoc cref = "IPage.SelectOptionAsync(string, IEnumerable{IElementHandle}, PageSelectOptionOptions)"  />
318        public IReadOnlyList<string> SelectOption(string selector, IEnumerable<IElementHandle> values, PageSelectOptionOptions? options = null)
319        {
320            return this.AsyncPage.SelectOptionAsync(selector, values, options).Result;
321        }
322
323        /// <inheritdoc cref = "IPage.SelectOptionAsync(string, IEnumerable{SelectOptionValue}, PageSelectOptionOptions)"  />
324        public IReadOnlyList<string> SelectOption(string selector, IEnumerable<SelectOptionValue> values, PageSelectOptionOptions? options = null)
325        {
326            return this.AsyncPage.SelectOptionAsync(selector, values, options).Result;
327        }
328
329        /// <inheritdoc cref = "IPage.SelectOptionAsync(string, IEnumerable{string}, PageSelectOptionOptions)"  />
330        public IReadOnlyList<string> SelectOption(string selector, IEnumerable<string> values, PageSelectOptionOptions? options = null)
331        {
332            return this.AsyncPage.SelectOptionAsync(selector, values, options).Result;
333        }
334
335        /// <inheritdoc cref = "IPage.SelectOptionAsync(string, SelectOptionValue, PageSelectOptionOptions)"  />
336        public IReadOnlyList<string> SelectOption(string selector, SelectOptionValue values, PageSelectOptionOptions? options = null)
337        {
338            return this.AsyncPage.SelectOptionAsync(selector, values, options).Result;
339        }
340
341        /// <inheritdoc cref = "IPage.SelectOptionAsync(string, string, PageSelectOptionOptions)"  />
342        public IReadOnlyList<string> SelectOption(string selector, string values, PageSelectOptionOptions? options = null)
343        {
344            return this.AsyncPage.SelectOptionAsync(selector, values, options).Result;
345        }
346
347        /// <inheritdoc cref = "IPage.EvalOnSelectorAllAsync"  />
348        public JsonElement? EvalOnSelectorAll(string selector, string expression, object? arg = null)
349        {
350            return this.AsyncPage.EvalOnSelectorAllAsync(selector, expression, arg).Result;
351        }
352
353        /// <inheritdoc cref = "IPage.EvalOnSelectorAsync"  />
354        public JsonElement? EvalOnSelector(string selector, string expression, object? arg = null)
355        {
356            return this.AsyncPage.EvalOnSelectorAsync(selector, expression, arg).Result;
357        }
358
359        /// <inheritdoc cref = "IPage.EvaluateAsync"  />
360        public JsonElement? Evaluate(string expression, object? arg = null)
361        {
362            return this.AsyncPage.EvaluateAsync(expression, arg).Result;
363        }
364
365        /// <inheritdoc cref = "IPage.GetAttributeAsync"  />
366        public string? GetAttribute(string selector, string name, PageGetAttributeOptions? options = null)
367        {
368            return this.AsyncPage.GetAttributeAsync(selector, name, options).Result;
369        }
370
371        /// <inheritdoc cref = "IPage.TextContentAsync"  />
372        public string? TextContent(string selector, PageTextContentOptions? options = null)
373        {
374            return this.AsyncPage.TextContentAsync(selector, options).Result;
375        }
376
377        /// <inheritdoc cref = "IPage.ContentAsync"  />
378        public string Content()
379        {
380            return this.AsyncPage.ContentAsync().Result;
381        }
382
383        /// <inheritdoc cref = "IPage.InnerHTMLAsync"  />
384        public string InnerHTML(string selector, PageInnerHTMLOptions? options = null)
385        {
386            return this.AsyncPage.InnerHTMLAsync(selector, options).Result;
387        }
388
389        /// <inheritdoc cref = "IPage.InnerTextAsync"  />
390        public string InnerText(string selector, PageInnerTextOptions? options = null)
391        {
392            return this.AsyncPage.InnerTextAsync(selector, options).Result;
393        }
394
395        /// <inheritdoc cref = "IPage.InputValueAsync"  />
396        public string InputValue(string selector, PageInputValueOptions? options = null)
397        {
398            return this.AsyncPage.InputValueAsync(selector, options).Result;
399        }
400
401        /// <inheritdoc cref = "IPage.TitleAsync"  />
402        public string Title()
403        {
404            return this.AsyncPage.TitleAsync().Result;
405        }
406
407        /// <inheritdoc cref = "IPage.GotoAsync"  />
408        public IResponse? Goto(string url, PageGotoOptions? options = null)
409        {
410            return this.AsyncPage.GotoAsync(url, options).Result;
411        }
412
413        /// <inheritdoc cref = "IPage.GoBackAsync"  />
414        public IResponse? GoBack(PageGoBackOptions? options = null)
415        {
416            return this.AsyncPage.GoBackAsync(options).Result;
417        }
418
419        /// <inheritdoc cref = "IPage.GoForwardAsync"  />
420        public IResponse? GoForward(PageGoForwardOptions? options = null)
421        {
422            return this.AsyncPage.GoForwardAsync(options).Result;
423        }
424
425        /// <inheritdoc cref = "IPage.ReloadAsync"  />
426        public IResponse? Reload(PageReloadOptions? options = null)
427        {
428            return this.AsyncPage.ReloadAsync(options).Result;
429        }
430
431        /// <summary>
432        /// Dispose of the database connection
433        /// </summary>
434        public void Dispose()
435        {
436            this.Dispose(true);
437            GC.SuppressFinalize(this);
438        }
439
440        /// <summary>
441        /// Dispose of the database connection
442        /// </summary>
443        /// <param name="disposing">Is the object being disposed</param>
444        protected virtual void Dispose(bool disposing)
445        {
446            // Make sure the connection exists and is open before trying to close it
447            if (disposing && !this.AsyncPage.IsClosed)
448            {
449                this.AsyncPage.CloseAsync().Wait();
450            }
451        }
452    }
453}
454
Full Screen

PageModel.cs

Source: PageModel.cs Github

copy
1/*
2 * MIT License
3 *
4 * Copyright (c) Evgeny Naazarchuk.
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 Microsoft.Playwright;
26using Playwright.Synchronous;
27using System;
28using System.Collections.Generic;
29using System.Text.RegularExpressions;
30using System.Threading.Tasks;
31
32namespace Playwright.PageObjectModel;
33
34public partial class PageModel : IPageModel
35{
36    public IPage Page { get; }
37
38    public PageModel(IPage page)
39    {
40        this.Page = page;
41    }
42
43    protected virtual void Wait() 
44    {
45    }
46
47    protected virtual void WaitForLoadState(LoadState loadState, PageWaitForLoadStateOptions? options = null)
48    {
49        this.Page.WaitForLoadState(loadState, options);
50    }
51
52    protected TPageModel CreatePageModel<TPageModel>()
53        where TPageModel : PageModel
54    {
55        var ctor = typeof(TPageModel).GetConstructor(new[] { typeof(IPage) });
56        if (ctor is null) throw new ApplicationException("Page Model not found");
57        var returnPage = ctor.Invoke(new[] { this.Page });
58        var page = (TPageModel)returnPage;
59
60        return page;
61    }
62
63    protected TBlockModel CreateBlockModel<TBlockModel>(string selector)
64        where TBlockModel : class
65    {
66        var blockType = typeof(TBlockModel);
67        var ctorArgs = new[] { this.GetType(), typeof(string) };
68
69        var ctor = blockType.GetConstructor(ctorArgs);
70        if (ctor is null) throw new ApplicationException("Block Model not found");
71
72        var block = ctor.Invoke(new[] { this, (object)selector });
73        if (block is null) throw new ApplicationException("Block Model not created");
74
75        return (TBlockModel)block;
76    }
77
78    protected TBlockModel CreateBlockModel<TBlockModel>(IElementHandle element)
79        where TBlockModel : class
80    {
81        var blockType = typeof(TBlockModel);
82        var ctorArgs = new[] { this.GetType(), typeof(IElementHandle) };
83
84        var ctor = blockType.GetConstructor(ctorArgs);
85        if (ctor is null) throw new ApplicationException("Block Model not found");
86
87        var block = ctor.Invoke(new[] { this, (object)element });
88        if (block is null) throw new ApplicationException("Block Model not created");
89
90        return (TBlockModel)block;
91    }
92
93    public virtual TPageModel Goto<TPageModel>(string url, PageGotoOptions? options = null)
94        where TPageModel : PageModel
95    {
96        this.Page.Goto(url, options);
97        var page = this.CreatePageModel<TPageModel>();
98        return page;
99    }
100
101    public virtual TPageModel GoBack<TPageModel>(PageGoBackOptions? options = null)
102        where TPageModel : PageModel
103    {
104        this.Page.GoBack(options);
105        var page = this.CreatePageModel<TPageModel>();
106        return page;
107    }
108
109    public virtual TPageModel GoForward<TPageModel>(PageGoForwardOptions? options = null)
110        where TPageModel : PageModel
111    {
112        this.Page.GoForward(options);
113        var page = this.CreatePageModel<TPageModel>();
114        return page;
115    }
116
117    public virtual TPageModel ReloadToPage<TPageModel>(PageReloadOptions? options = null)
118        where TPageModel : PageModel
119    {
120        this.Page.ReloadAsync(options).GetAwaiter().GetResult();
121        var page = this.CreatePageModel<TPageModel>();
122        return page;
123    }
124
125    public virtual void Close(PageCloseOptions? options = null)
126    {
127        this.Page.ClosePage(options);
128    }
129
130    protected virtual IElementHandle? QuerySelector(string selector, PageQuerySelectorOptions? options = null)
131    {
132        return this.Page.QuerySelector(selector, options);
133    }
134
135    protected virtual IReadOnlyList<IElementHandle> QuerySelectorAll(string selector)
136    {
137        return this.Page.QuerySelectorAll(selector);
138    }
139
140    protected virtual IElementHandle GetElement(
141        string selector,
142        PageWaitForSelectorOptions? waitOptions = null,
143        PageQuerySelectorOptions? queryOptions = null)
144    {
145        this.Page.WaitForSelector(selector, waitOptions);
146        var element = this.Page.QuerySelector(selector, queryOptions);
147        return element!;
148    }
149
150    protected virtual IReadOnlyCollection<IElementHandle> GetElements(string selector, PageWaitForSelectorOptions? waitOptions = null)
151    {
152        var elements = this.Page.QuerySelectorAll(selector);
153        return elements;
154    }
155
156    protected virtual TBlockModel GetElementModel<TBlockModel>(string selector, PageWaitForSelectorOptions? waitOptions = null)
157        where TBlockModel : class
158    {
159        var block = this.CreateBlockModel<TBlockModel>(selector);
160        return block;
161    }
162
163    protected virtual IReadOnlyCollection<TBlockModel> GetElementModels<TBlockModel>(string selector, PageWaitForSelectorOptions? waitOptions = null)
164        where TBlockModel : class
165    {
166        var elements = this.Page.QuerySelectorAll(selector);
167        var blocks = new List<TBlockModel>();
168
169        foreach (var element in elements)
170        {
171            var block = this.CreateBlockModel<TBlockModel>(element);
172            blocks.Add(block);
173        }
174
175        return blocks;
176    }
177
178    protected virtual IElementHandle? GetElementOrNull(
179        string selector,
180        PageWaitForSelectorOptions? waitOptions = null,
181        PageQuerySelectorOptions? queryOptions = null)
182    {
183        var element = this.Page.QuerySelector(selector, queryOptions);
184        return element;
185    }
186
187    protected virtual void Click(string selector, PageClickOptions? options = null)
188    {
189        this.Page.Click(selector, options);
190    }
191
192    protected virtual TReturnPage Click<TReturnPage>(string selector, PageClickOptions? options = null)
193        where TReturnPage : PageModel
194    {
195        this.Click(selector, options);
196        var page = this.CreatePageModel<TReturnPage>();
197        return page;
198    }
199
200    protected virtual void DblClick(string selector, PageDblClickOptions? options = null)
201    {
202        this.Page.DblClick(selector, options);
203    }
204
205    protected virtual void Type(string selector, string value, PageTypeOptions? options = null)
206    {
207        this.Page.Type(selector, value, options);
208    }
209
210    protected virtual void Check(string selector, PageCheckOptions? options = null)
211    {
212        this.Page.Check(selector, options);
213    }
214
215    protected virtual void Uncheck(string selector, PageUncheckOptions? options = null)
216    {
217        this.Page.Uncheck(selector, options);
218    }
219
220    protected virtual void SetChecked(string selector, bool checkedState, PageSetCheckedOptions? options = null)
221    {
222        this.Page.SetChecked(selector, checkedState, options);
223    }
224
225    protected virtual void Tap(string selector, PageTapOptions? options = null)
226    {
227        this.Page.Tap(selector, options);
228    }
229
230    protected virtual void DragAndDrop(string source, string target, PageDragAndDropOptions? options = null)
231    {
232        this.Page.DragAndDrop(source, target, options);
233    }
234
235    protected virtual void Focus(string selector, PageFocusOptions? options = null)
236    {
237        this.Page.Focus(selector, options);
238    }
239
240    protected virtual void Fill(string selector, string value, PageFillOptions? options = null)
241    {
242        this.Page.Fill(selector, value, options);
243    }
244
245    protected virtual void Hover(string selector, PageHoverOptions? options = null)
246    {
247        this.Page.Hover(selector, options);
248    }
249
250    protected virtual void Press(string selector, string key, PagePressOptions? options = null)
251    {
252        this.Page.Press(selector, key, options);
253    }
254
255    protected virtual IReadOnlyList<string> SelectOption(string selector, string values, PageSelectOptionOptions? options = null)
256    {
257        var result = this.Page.SelectOption(selector, values, options);
258        return result;
259    }
260
261    protected virtual IReadOnlyList<string> SelectOption(string selector, IElementHandle values, PageSelectOptionOptions? options = null)
262    {
263        var result = this.Page.SelectOption(selector, values, options);
264        return result;
265    }
266
267    protected virtual IReadOnlyList<string> SelectOption(string selector, IEnumerable<string> values, PageSelectOptionOptions? options = null)
268    {
269        var result = this.Page.SelectOption(selector, values, options);
270        return result;
271    }
272
273    protected virtual IReadOnlyList<string> SelectOption(string selector, SelectOptionValue values, PageSelectOptionOptions? options = null)
274    {
275        var result = this.Page.SelectOption(selector, values, options);
276        return result;
277    }
278
279    protected virtual IReadOnlyList<string> SelectOption(string selector, IEnumerable<IElementHandle> values, PageSelectOptionOptions? options = null)
280    {
281        var result = this.Page.SelectOption(selector, values, options);
282        return result;
283    }
284
285    protected virtual IReadOnlyList<string> SelectOption(string selector, IEnumerable<SelectOptionValue> values, PageSelectOptionOptions? options = null)
286    {
287        var result = this.Page.SelectOption(selector, values, options);
288        return result;
289    }
290
291    protected virtual void SetInputFiles(string selector, string files, PageSetInputFilesOptions? options = null)
292    {
293        this.Page.SetInputFiles(selector, files, options);
294    }
295
296    protected virtual void SetInputFiles(string selector, FilePayload files, PageSetInputFilesOptions? options = null)
297    {
298        this.Page.SetInputFiles(selector, files, options);
299    }
300
301    protected virtual void SetInputFiles(string selector, IEnumerable<string> files, PageSetInputFilesOptions? options = null)
302    {
303        this.Page.SetInputFiles(selector, files, options);
304    }
305
306    protected virtual void SetInputFiles(string selector, IEnumerable<FilePayload> files, PageSetInputFilesOptions? options = null)
307    {
308        this.Page.SetInputFiles(selector, files, options);
309    }
310
311    protected virtual void AddInitScript(string? script = null, string? scriptPath = null)
312    {
313        this.Page.AddInitScript(script, scriptPath);
314    }
315
316    protected virtual void AddScriptTag(PageAddScriptTagOptions? options = null)
317    {
318        this.Page.AddScriptTag(options);
319    }
320
321    protected virtual void AddStyleTag(PageAddStyleTagOptions? options = null)
322    {
323        this.Page.AddStyleTag(options);
324    }
325
326    protected virtual void BringToFront()
327    {
328        this.Page.BringToFront();
329    }
330
331    protected virtual string Content()
332    {
333        var content = this.Page.Content();
334        return content;
335    }
336
337    protected virtual void DispatchEvent(string selector, string type, object? eventInit = null, PageDispatchEventOptions? options = null)
338    {
339        this.Page.DispatchEvent(selector, type, eventInit, options); ;
340    }
341
342    protected virtual void EmulateMedia(PageEmulateMediaOptions? options = null)
343    {
344        this.Page.EmulateMedia(options);
345    }
346
347    protected virtual void EvalOnSelectorAll(string selector, string expression, object? arg = null)
348    {
349        this.Page.EvalOnSelectorAll(selector, expression, arg);
350    }
351
352    protected virtual void EvalOnSelectorAll<T>(string selector, string expression, object? arg = null)
353    {
354        this.Page.EvalOnSelectorAll<T>(selector, expression, arg);
355    }
356
357    protected virtual void EvalOnSelector(string selector, string expression, object? arg = null)
358    {
359        this.Page.EvalOnSelector(selector, expression, arg);
360    }
361
362    protected virtual void EvalOnSelector<T>(string selector, string expression, object? arg = null, PageEvalOnSelectorOptions? options = null)
363    {
364        this.Page.EvalOnSelector<T>(selector, expression, arg, options);
365    }
366
367    protected virtual void Evaluate(string expression, object? arg = null)
368    {
369        this.Page.Evaluate(expression, arg);
370    }
371
372    protected virtual void Evaluate<T>(string expression, object? arg = null)
373    {
374        this.Page.Evaluate<T>(expression, arg);
375    }
376
377    protected virtual void EvaluateHandle(string expression, object? arg = null)
378    {
379        this.Page.EvaluateHandle(expression, arg);
380    }
381
382    protected virtual void ExposeBinding(string name, Action<BindingSource> callback)
383    {
384        this.Page.ExposeBinding(name, callback);
385    }
386
387    protected virtual void ExposeBinding(string name, Action callback, PageExposeBindingOptions? options = null)
388    {
389        this.Page.ExposeBinding(name, callback, options);
390    }
391
392    protected virtual void ExposeBinding<T>(string name, Action<BindingSource, T> callback)
393    {
394        this.Page.ExposeBinding<T>(name, callback);
395    }
396
397    protected virtual void ExposeBinding<TResult>(string name, Func<BindingSource, TResult> callback)
398    {
399        this.Page.ExposeBinding<TResult>(name, callback);
400    }
401
402    protected virtual void ExposeBinding<TResult>(string name, Func<BindingSource, IJSHandle, TResult> callback)
403    {
404        this.Page.ExposeBinding<TResult>(name, callback);
405    }
406
407    protected virtual void ExposeBinding<T, TResult>(string name, Func<BindingSource, T, TResult> callback)
408    {
409        this.Page.ExposeBinding<T, TResult>(name, callback);
410    }
411
412    protected virtual void ExposeBinding<T1, T2, TResult>(string name, Func<BindingSource, T1, T2, TResult> callback)
413    {
414        this.Page.ExposeBinding<T1, T2, TResult>(name, callback);
415    }
416
417    protected virtual void ExposeBinding<T1, T2, T3, TResult>(string name, Func<BindingSource, T1, T2, T3, TResult> callback)
418    {
419        this.Page.ExposeBinding<T1, T2, T3, TResult>(name, callback);
420    }
421
422    protected virtual void ExposeBinding<T1, T2, T3, T4, TResult>(string name, Func<BindingSource, T1, T2, T3, T4, TResult> callback)
423    {
424        this.Page.ExposeBinding<T1, T2, T3, T4, TResult>(name, callback);
425    }
426
427    protected virtual void ExposeFunction(string name, Action callback)
428    {
429        this.Page.ExposeFunction(name, callback);
430    }
431
432    protected virtual void ExposeFunction<T>(string name, Action<T> callback)
433    {
434        this.Page.ExposeFunction<T>(name, callback);
435    }
436
437    protected virtual void ExposeFunction<TResult>(string name, Func<TResult> callback)
438    {
439        this.Page.ExposeFunction<TResult>(name, callback);
440    }
441
442    protected virtual void ExposeFunction<T, TResult>(string name, Func<T, TResult> callback)
443    {
444        this.Page.ExposeFunction<T, TResult>(name, callback);
445    }
446
447    protected virtual void ExposeFunction<T1, T2, TResult>(string name, Func<T1, T2, TResult> callback)
448    {
449        this.Page.ExposeFunction<T1, T2, TResult>(name, callback);
450    }
451
452    protected virtual void ExposeFunction<T1, T2, T3, TResult>(string name, Func<T1, T2, T3, TResult> callback)
453    {
454        this.Page.ExposeFunction<T1, T2, T3, TResult>(name, callback);
455    }
456
457    protected virtual void ExposeFunction<T1, T2, T3, T4, TResult>(string name, Func<T1, T2, T3, T4, TResult> callback)
458    {
459        this.Page.ExposeFunction<T1, T2, T3, T4, TResult>(name, callback);
460    }
461
462    protected virtual string? GetAttribute(string selector, string name, PageWaitForSelectorOptions? waitOptions = null, PageGetAttributeOptions? queryOptions = null)
463    {
464        this.Page.WaitForSelector(selector, waitOptions);
465        return this.Page.GetAttribute(selector, name, queryOptions);
466    }
467
468    protected virtual string InnerHTML(string selector, PageWaitForSelectorOptions? waitOptions = null, PageInnerHTMLOptions? queryOptions = null)
469    {
470        this.Page.WaitForSelector(selector, waitOptions);
471        return this.Page.InnerHTML(selector, queryOptions);
472    }
473
474    protected virtual string InnerText(string selector, PageInnerTextOptions? queryOptions = null)
475    {
476        return this.Page.InnerText(selector, queryOptions);
477    }
478
479    protected virtual string InputValue(string selector, PageInputValueOptions? queryOptions = null)
480    {
481        return this.Page.InputValue(selector, queryOptions);
482    }
483
484    protected virtual bool IsChecked(string selector, PageIsCheckedOptions? queryOptions = null)
485    {
486        return this.Page.IsChecked(selector, queryOptions);
487    }
488
489    protected virtual bool IsDisabled(string selector, PageIsDisabledOptions? options = null)
490    {
491        return this.Page.IsDisabled(selector, options);
492    }
493
494    protected virtual bool IsEditable(string selector, PageIsEditableOptions? options = null)
495    {
496        return this.Page.IsEditable(selector, options);
497    }
498
499    protected virtual bool IsEnabled(string selector, PageIsEnabledOptions? options = null)
500    {
501        return this.Page.IsEnabled(selector, options);
502    }
503
504    protected virtual bool IsHidden(string selector, PageIsHiddenOptions? options = null)
505    {
506        return this.Page.IsHidden(selector, options);
507    }
508
509    protected virtual bool IsVisible(string selector, PageIsVisibleOptions? options = null)
510    {
511        return this.Page.IsVisible(selector, options);
512    }
513
514    protected virtual ILocator IsVisible(string selector)
515    {
516        return this.Page.Locator(selector);
517    }
518
519    protected virtual void Route(string url, Action<IRoute> handler, PageRouteOptions? options = null)
520    {
521        this.Page.Route(url, handler, options);
522    }
523
524    protected virtual void Route(Regex url, Action<IRoute> handler, PageRouteOptions? options = null)
525    {
526        this.Page.Route(url, handler, options);
527    }
528
529    protected virtual void Route(Func<string, bool> url, Action<IRoute> handler, PageRouteOptions? options = null)
530    {
531        this.Page.Route(url, handler, options);
532    }
533
534    protected virtual void Unroute(string url, Action<IRoute>? handler = null)
535    {
536        this.Page.Unroute(url, handler);
537    }
538
539    protected virtual void Unroute(Regex url, Action<IRoute>? handler = null)
540    {
541        this.Page.Unroute(url, handler);
542    }
543
544    protected virtual void Unroute(Func<string, bool> url, Action<IRoute>? handler = null)
545    {
546        this.Page.Unroute(url, handler);
547    }
548
549    protected virtual IFrame? Frame(string name)
550    {
551        return this.Page.Frame(name);
552    }
553
554    protected virtual IFrame? FrameByUrl(string url)
555    {
556        return this.Page.FrameByUrl(url);
557    }
558
559    protected virtual IFrame? FrameByUrl(Regex url)
560    {
561        return this.Page.FrameByUrl(url);
562    }
563
564    protected virtual IFrame? FrameyUrl(Func<string, bool> url)
565    {
566        return this.Page.FrameByUrl(url);
567    }
568
569    protected virtual IConsoleMessage RunAndWaitForConsoleMessage(Func<Task> action, PageRunAndWaitForConsoleMessageOptions? options = null)
570    {
571        return this.Page.RunAndWaitForConsoleMessage(action, options);
572    }
573
574    protected virtual IDownload RunAndWaitForDownload(Func<Task> action, PageRunAndWaitForDownloadOptions? options = null)
575    {
576        return this.Page.RunAndWaitForDownload(action, options);
577    }
578
579    protected virtual IFileChooser RunAndWaitForFileChooser(Func<Task> action, PageRunAndWaitForFileChooserOptions? options = null)
580    {
581        return this.Page.RunAndWaitForFileChooser(action, options);
582    }
583
584    protected virtual IResponse? RunAndWaitForNavigation(Func<Task> action, PageRunAndWaitForNavigationOptions? options = null)
585    {
586        return this.Page.RunAndWaitForNavigation(action, options);
587    }
588
589    protected virtual IPage RunAndWaitForPopup(Func<Task> action, PageRunAndWaitForPopupOptions? options = null)
590    {
591        return this.Page.RunAndWaitForPopup(action, options);
592    }
593
594    protected virtual IRequest RunAndWaitForRequest(Func<Task> action, string urlOrPredicate, PageRunAndWaitForRequestOptions? options = null)
595    {
596        return this.Page.RunAndWaitForRequest(action, urlOrPredicate, options);
597    }
598
599    protected virtual IRequest RunAndWaitForRequest(Func<Task> action, Regex urlOrPredicate, PageRunAndWaitForRequestOptions? options = null)
600    {
601        return this.Page.RunAndWaitForRequest(action, urlOrPredicate, options);
602    }
603
604    protected virtual IRequest RunAndWaitForRequest(Func<Task> action, Func<IRequest, bool> urlOrPredicate, PageRunAndWaitForRequestOptions? options = null)
605    {
606        return this.Page.RunAndWaitForRequest(action, urlOrPredicate, options);
607    }
608
609    protected virtual IRequest RunAndWaitForRequestFinished(Func<Task> action, PageRunAndWaitForRequestFinishedOptions? options = null)
610    {
611        return this.Page.RunAndWaitForRequestFinished(action, options);
612    }
613
614    protected virtual IResponse RunAndWaitForResponse(Func<Task> action, string urlOrPredicate, PageRunAndWaitForResponseOptions? options = null)
615    {
616        return this.Page.RunAndWaitForResponse(action, urlOrPredicate, options);
617    }
618
619    protected virtual IResponse RunAndWaitForResponse(Func<Task> action, Regex urlOrPredicate, PageRunAndWaitForResponseOptions? options = null)
620    {
621        return this.Page.RunAndWaitForResponse(action, urlOrPredicate, options);
622    }
623
624    protected virtual IWebSocket RunAndWaitForWebSocket(Func<Task> action, PageRunAndWaitForWebSocketOptions? options = null)
625    {
626        return this.Page.RunAndWaitForWebSocket(action, options);
627    }
628
629    protected virtual void RunAndWaitForWorker(Func<Task> action, PageRunAndWaitForWorkerOptions? options = null)
630    {
631        this.Page.RunAndWaitForWorker(action, options);
632    }
633
634    protected virtual void Screenshot(PageScreenshotOptions? options = null)
635    {
636        this.Page.Screenshot(options);
637    }
638
639    protected virtual byte[] Pdf(PagePdfOptions? options = null)
640    {
641        return this.Page.Pdf(options);
642    }
643
644    protected virtual void SetContent(string html, PageSetContentOptions? options = null)
645    {
646        this.Page.SetContent(html, options);
647    }
648
649    protected virtual void SetExtraHTTPHeaders(IEnumerable<KeyValuePair<string, string>> headers)
650    {
651        this.Page.SetExtraHTTPHeaders(headers);
652    }
653
654    protected virtual void SetViewportSize(int width, int height)
655    {
656        this.Page.SetViewportSize(width, height);
657    }
658
659    protected virtual string? TextContent(string selector, PageTextContentOptions? options = null)
660    {
661        return this.Page.TextContent(selector, options);
662    }
663
664    protected virtual string Title()
665    {
666        return this.Page.Title();
667    }
668
669    protected virtual IConsoleMessage WaitForConsoleMessage(PageWaitForConsoleMessageOptions? options = null)
670    {
671        return this.Page.WaitForConsoleMessage(options);
672    }
673
674    protected virtual IDownload WaitForDownload(PageWaitForDownloadOptions? options = null)
675    {
676        return this.Page.WaitForDownload(options);
677    }
678
679    protected virtual IFileChooser WaitForFileChooser(PageWaitForFileChooserOptions? options = null)
680    {
681        return this.Page.WaitForFileChooser(options);
682    }
683
684    protected virtual IJSHandle WaitForFunction(string expression, object? arg = null, PageWaitForFunctionOptions? options = null)
685    {
686        return this.Page.WaitForFunction(expression, arg, options);
687    }
688
689    protected virtual void WaitForLoadState(LoadState? state = null, PageWaitForLoadStateOptions? options = null)
690    {
691        this.Page.WaitForLoadState(state, options);
692    }
693
694    protected virtual IResponse? WaitForNavigation(PageWaitForNavigationOptions? options = null)
695    {
696        return this.Page.WaitForNavigation(options);
697    }
698
699    protected virtual IPage WaitForPopup(PageWaitForPopupOptions? options = null)
700    {
701        return this.Page.WaitForPopup(options);
702    }
703
704    protected virtual IRequest WaitForRequest(string urlOrPredicate, PageWaitForRequestOptions? options = null)
705    {
706        return this.Page.WaitForRequest(urlOrPredicate, options);
707    }
708
709    protected virtual IRequest WaitForRequest(Regex urlOrPredicate, PageWaitForRequestOptions? options = null)
710    {
711        return this.Page.WaitForRequest(urlOrPredicate, options);
712    }
713
714    protected virtual IRequest WaitForRequest(Func<IRequest, bool> urlOrPredicate, PageWaitForRequestOptions? options = null)
715    {
716        return this.Page.WaitForRequest(urlOrPredicate, options);
717    }
718
719    protected virtual IRequest WaitForRequestFinished(PageWaitForRequestFinishedOptions? options = null)
720    {
721        return this.Page.WaitForRequestFinished(options);
722    }
723
724    protected virtual IResponse WaitForResponse(string urlOrPredicate, PageWaitForResponseOptions? options = null)
725    {
726        return this.Page.WaitForResponse(urlOrPredicate, options);
727    }
728
729    protected virtual IResponse WaitForResponse(Regex urlOrPredicate, PageWaitForResponseOptions? options = null)
730    {
731        return this.Page.WaitForResponse(urlOrPredicate, options);
732    }
733
734    protected virtual IResponse WaitForResponse(Func<IResponse, bool> urlOrPredicate, PageWaitForResponseOptions? options = null)
735    {
736        return this.Page.WaitForResponse(urlOrPredicate, options);
737    }
738
739    protected virtual IResponse RunAndWaitForResponse(Func<Task> action, Func<IResponse, bool> urlOrPredicate, PageRunAndWaitForResponseOptions? options = null)
740    {
741        return this.Page.RunAndWaitForResponse(action, urlOrPredicate, options);
742    }
743
744    protected virtual IElementHandle? WaitForSelector(string selector, PageWaitForSelectorOptions? options = null)
745    {
746        return this.Page.WaitForSelector(selector, options);
747    }
748
749    protected virtual void WaitForTimeout(float timeout)
750    {
751        this.Page.WaitForTimeout(timeout);
752    }
753
754    protected virtual void WaitForURL(Regex url, PageWaitForURLOptions? options = null)
755    {
756        this.Page.WaitForURL(url, options);
757    }
758
759    protected virtual void WaitForURL(Func<string, bool> url, PageWaitForURLOptions? options = null)
760    {
761        this.Page.WaitForURL(url, options);
762    }
763
764    protected virtual IWebSocket WaitForWebSocket(PageWaitForWebSocketOptions? options = null)
765    {
766        return this.Page.WaitForWebSocket(options);
767    }
768
769    protected virtual IWorker WaitForWorker(PageWaitForWorkerOptions? options = null)
770    {
771        return this.Page.WaitForWorker(options);
772    }
773
774    protected virtual IPage? Opener()
775    {
776        return this.Page.Opener();
777    }
778
779    protected virtual void Pause()
780    {
781        this.Page.Pause();
782    }
783
784    protected string GetComputedStyle(
785        string selector,
786        string styleName,
787        PageWaitForSelectorOptions? waitOptions = null,
788        PageQuerySelectorOptions? queryOptions = null)
789    {
790        var element = this.GetElement(selector, waitOptions, queryOptions);
791        var styleValue = this.Page.Evaluate<string>($"e => getComputedStyle(e).{styleName}", element);
792        return styleValue;
793    }
794}
795
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Most used method in PageSetCheckedOptions

Trigger PageSetCheckedOptions code on LambdaTest Cloud Grid

Execute automation tests with PageSetCheckedOptions on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)