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

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

Run Playwright-dotnet automation tests on LambdaTest cloud grid

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

LocatorSelectTextOptions.cs

Source: LocatorSelectTextOptions.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 LocatorSelectTextOptions
43    {
44        public LocatorSelectTextOptions() { }
45
46        public LocatorSelectTextOptions(LocatorSelectTextOptions clone)
47        {
48            if (clone == null)
49            {
50                return;
51            }
52
53            Force = clone.Force;
54            Timeout = clone.Timeout;
55        }
56
57        /// <summary>
58        /// <para>
59        /// Whether to bypass the <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
60        /// checks. Defaults to <c>false</c>.
61        /// </para>
62        /// </summary>
63        [JsonPropertyName("force")]
64        public bool? Force { get; set; }
65
66        /// <summary>
67        /// <para>
68        /// Maximum time in milliseconds, defaults to 30 seconds, pass <c>0</c> to disable timeout.
69        /// The default value can be changed by using the <see cref="IBrowserContext.SetDefaultTimeout"/>
70        /// or <see cref="IPage.SetDefaultTimeout"/> methods.
71        /// </para>
72        /// </summary>
73        [JsonPropertyName("timeout")]
74        public float? Timeout { get; set; }
75    }
76}
77
78#nullable disable
79
Full Screen

Locator.cs

Source: Locator.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.Text.Json;
29using System.Threading.Tasks;
30using Microsoft.Playwright.Helpers;
31using Microsoft.Playwright.Transport.Protocol;
32
33namespace Microsoft.Playwright.Core
34{
35    internal class Locator : ILocator
36    {
37        internal readonly Frame _frame;
38        internal readonly string _selector;
39
40        private readonly LocatorLocatorOptions _options;
41
42        public Locator(Frame parent, string selector, LocatorLocatorOptions options = null)
43        {
44            _frame = parent;
45            _selector = selector;
46            _options = options;
47
48            if (options?.HasTextRegex != null)
49            {
50                _selector += $" >> :scope:text-matches({options.HasTextRegex.ToString().EscapeWithQuotes("\"")}, {options.HasTextRegex.Options.GetInlineFlags().EscapeWithQuotes("\"")})";
51            }
52            if (options?.HasTextString != null)
53            {
54                _selector += $" >> :scope:has-text({options.HasTextString.EscapeWithQuotes("\"")})";
55            }
56
57            if (options?.Has != null)
58            {
59                var has = (Locator)options.Has;
60                if (has._frame != _frame)
61                {
62                    throw new ArgumentException("Inner \"has\" locator must belong to the same frame.");
63                }
64                _selector += " >> has=" + JsonSerializer.Serialize(has._selector);
65            }
66        }
67
68        public ILocator First => new Locator(_frame, $"{_selector} >> nth=0");
69
70        public ILocator Last => new Locator(_frame, $"{_selector} >> nth=-1");
71
72        IPage ILocator.Page => _frame.Page;
73
74        public async Task<IReadOnlyList<string>> AllInnerTextsAsync()
75            => await EvaluateAllAsync<string[]>("ee => ee.map(e => e.innerText)").ConfigureAwait(false);
76
77        public async Task<IReadOnlyList<string>> AllTextContentsAsync()
78            => await EvaluateAllAsync<string[]>("ee => ee.map(e => e.textContent || '')").ConfigureAwait(false);
79
80        public async Task<LocatorBoundingBoxResult> BoundingBoxAsync(LocatorBoundingBoxOptions options = null)
81            => await WithElementAsync(
82                async (h, _) =>
83                {
84                    var bb = await h.BoundingBoxAsync().ConfigureAwait(false);
85                    if (bb == null)
86                    {
87                        return null;
88                    }
89
90                    return new LocatorBoundingBoxResult()
91                    {
92                        Height = bb.Height,
93                        Width = bb.Width,
94                        X = bb.X,
95                        Y = bb.Y,
96                    };
97                },
98                options).ConfigureAwait(false);
99
100        public Task CheckAsync(LocatorCheckOptions options = null)
101            => _frame.CheckAsync(
102                _selector,
103                ConvertOptions<FrameCheckOptions>(options));
104
105        public Task ClickAsync(LocatorClickOptions options = null)
106            => _frame.ClickAsync(
107                _selector,
108                ConvertOptions<FrameClickOptions>(options));
109
110        public Task SetCheckedAsync(bool checkedState, LocatorSetCheckedOptions options = null)
111            => checkedState ?
112                CheckAsync(ConvertOptions<LocatorCheckOptions>(options))
113                : UncheckAsync(ConvertOptions<LocatorUncheckOptions>(options));
114
115        public Task<int> CountAsync()
116            => _frame.QueryCountAsync(_selector);
117
118        public Task DblClickAsync(LocatorDblClickOptions options = null)
119            => _frame.DblClickAsync(_selector, ConvertOptions<FrameDblClickOptions>(options));
120
121        public Task DispatchEventAsync(string type, object eventInit = null, LocatorDispatchEventOptions options = null)
122            => _frame.DispatchEventAsync(_selector, type, eventInit, ConvertOptions<FrameDispatchEventOptions>(options));
123
124        public Task DragToAsync(ILocator target, LocatorDragToOptions options = null)
125            => _frame.DragAndDropAsync(_selector, ((Locator)target)._selector, ConvertOptions<FrameDragAndDropOptions>(options));
126
127        public async Task<IElementHandle> ElementHandleAsync(LocatorElementHandleOptions options = null)
128            => await _frame.WaitForSelectorAsync(
129                _selector,
130                ConvertOptions<FrameWaitForSelectorOptions>(options)).ConfigureAwait(false);
131
132        public Task<IReadOnlyList<IElementHandle>> ElementHandlesAsync()
133            => _frame.QuerySelectorAllAsync(_selector);
134
135        public Task<T> EvaluateAllAsync<T>(string expression, object arg = null)
136            => _frame.EvalOnSelectorAllAsync<T>(_selector, expression, arg);
137
138        public Task<JsonElement?> EvaluateAsync(string expression, object arg = null, LocatorEvaluateOptions options = null)
139            => EvaluateAsync<JsonElement?>(expression, arg, options);
140
141        public Task<T> EvaluateAsync<T>(string expression, object arg = null, LocatorEvaluateOptions options = null)
142            => _frame.EvalOnSelectorAsync<T>(_selector, expression, arg, ConvertOptions<FrameEvalOnSelectorOptions>(options));
143
144        public async Task<IJSHandle> EvaluateHandleAsync(string expression, object arg = null, LocatorEvaluateHandleOptions options = null)
145            => await WithElementAsync(async (e, _) => await e.EvaluateHandleAsync(expression, arg).ConfigureAwait(false), options).ConfigureAwait(false);
146
147        public async Task FillAsync(string value, LocatorFillOptions options = null)
148            => await _frame.FillAsync(_selector, value, ConvertOptions<FrameFillOptions>(options)).ConfigureAwait(false);
149
150        public Task FocusAsync(LocatorFocusOptions options = null)
151            => _frame.FocusAsync(_selector, ConvertOptions<FrameFocusOptions>(options));
152
153        IFrameLocator ILocator.FrameLocator(string selector) =>
154            new FrameLocator(_frame, $"{_selector} >> {selector}");
155
156        public Task<string> GetAttributeAsync(string name, LocatorGetAttributeOptions options = null)
157            => _frame.GetAttributeAsync(_selector, name, ConvertOptions<FrameGetAttributeOptions>(options));
158
159        public Task HoverAsync(LocatorHoverOptions options = null)
160            => _frame.HoverAsync(_selector, ConvertOptions<FrameHoverOptions>(options));
161
162        public Task<string> InnerHTMLAsync(LocatorInnerHTMLOptions options = null)
163            => _frame.InnerHTMLAsync(_selector, ConvertOptions<FrameInnerHTMLOptions>(options));
164
165        public Task<string> InnerTextAsync(LocatorInnerTextOptions options = null)
166            => _frame.InnerTextAsync(_selector, ConvertOptions<FrameInnerTextOptions>(options));
167
168        public Task<string> InputValueAsync(LocatorInputValueOptions options = null)
169            => _frame.InputValueAsync(_selector, ConvertOptions<FrameInputValueOptions>(options));
170
171        public Task<bool> IsCheckedAsync(LocatorIsCheckedOptions options = null)
172            => _frame.IsCheckedAsync(_selector, ConvertOptions<FrameIsCheckedOptions>(options));
173
174        public Task<bool> IsDisabledAsync(LocatorIsDisabledOptions options = null)
175            => _frame.IsDisabledAsync(_selector, ConvertOptions<FrameIsDisabledOptions>(options));
176
177        public Task<bool> IsEditableAsync(LocatorIsEditableOptions options = null)
178            => _frame.IsEditableAsync(_selector, ConvertOptions<FrameIsEditableOptions>(options));
179
180        public Task<bool> IsEnabledAsync(LocatorIsEnabledOptions options = null)
181            => _frame.IsEnabledAsync(_selector, ConvertOptions<FrameIsEnabledOptions>(options));
182
183        public Task<bool> IsHiddenAsync(LocatorIsHiddenOptions options = null)
184            => _frame.IsHiddenAsync(_selector, ConvertOptions<FrameIsHiddenOptions>(options));
185
186        public Task<bool> IsVisibleAsync(LocatorIsVisibleOptions options = null)
187            => _frame.IsVisibleAsync(_selector, ConvertOptions<FrameIsVisibleOptions>(options));
188
189        public ILocator Nth(int index)
190            => new Locator(_frame, $"{_selector} >> nth={index}");
191
192        public Task PressAsync(string key, LocatorPressOptions options = null)
193            => _frame.PressAsync(_selector, key, ConvertOptions<FramePressOptions>(options));
194
195        public Task<byte[]> ScreenshotAsync(LocatorScreenshotOptions options = null)
196            => WithElementAsync(async (h, o) => await h.ScreenshotAsync(ConvertOptions<ElementHandleScreenshotOptions>(o)).ConfigureAwait(false), options);
197
198        public Task ScrollIntoViewIfNeededAsync(LocatorScrollIntoViewIfNeededOptions options = null)
199            => WithElementAsync(async (h, o) => await h.ScrollIntoViewIfNeededAsync(ConvertOptions<ElementHandleScrollIntoViewIfNeededOptions>(o)).ConfigureAwait(false), options);
200
201        public Task<IReadOnlyList<string>> SelectOptionAsync(string values, LocatorSelectOptionOptions options = null)
202            => _frame.SelectOptionAsync(_selector, values, ConvertOptions<FrameSelectOptionOptions>(options));
203
204        public Task<IReadOnlyList<string>> SelectOptionAsync(IElementHandle values, LocatorSelectOptionOptions options = null)
205            => _frame.SelectOptionAsync(_selector, values, ConvertOptions<FrameSelectOptionOptions>(options));
206
207        public Task<IReadOnlyList<string>> SelectOptionAsync(IEnumerable<string> values, LocatorSelectOptionOptions options = null)
208            => _frame.SelectOptionAsync(_selector, values, ConvertOptions<FrameSelectOptionOptions>(options));
209
210        public Task<IReadOnlyList<string>> SelectOptionAsync(SelectOptionValue values, LocatorSelectOptionOptions options = null)
211            => _frame.SelectOptionAsync(_selector, values, ConvertOptions<FrameSelectOptionOptions>(options));
212
213        public Task<IReadOnlyList<string>> SelectOptionAsync(IEnumerable<IElementHandle> values, LocatorSelectOptionOptions options = null)
214            => _frame.SelectOptionAsync(_selector, values, ConvertOptions<FrameSelectOptionOptions>(options));
215
216        public Task<IReadOnlyList<string>> SelectOptionAsync(IEnumerable<SelectOptionValue> values, LocatorSelectOptionOptions options = null)
217            => _frame.SelectOptionAsync(_selector, values, ConvertOptions<FrameSelectOptionOptions>(options));
218
219        public Task SelectTextAsync(LocatorSelectTextOptions options = null)
220            => WithElementAsync((h, o) => h.SelectTextAsync(ConvertOptions<ElementHandleSelectTextOptions>(o)), options);
221
222        public Task SetInputFilesAsync(string files, LocatorSetInputFilesOptions options = null)
223            => _frame.SetInputFilesAsync(_selector, files, ConvertOptions<FrameSetInputFilesOptions>(options));
224
225        public Task SetInputFilesAsync(IEnumerable<string> files, LocatorSetInputFilesOptions options = null)
226            => _frame.SetInputFilesAsync(_selector, files, ConvertOptions<FrameSetInputFilesOptions>(options));
227
228        public Task SetInputFilesAsync(FilePayload files, LocatorSetInputFilesOptions options = null)
229            => _frame.SetInputFilesAsync(_selector, files, ConvertOptions<FrameSetInputFilesOptions>(options));
230
231        public Task SetInputFilesAsync(IEnumerable<FilePayload> files, LocatorSetInputFilesOptions options = null)
232            => _frame.SetInputFilesAsync(_selector, files, ConvertOptions<FrameSetInputFilesOptions>(options));
233
234        public Task TapAsync(LocatorTapOptions options = null)
235            => _frame.TapAsync(_selector, ConvertOptions<FrameTapOptions>(options));
236
237        public Task<string> TextContentAsync(LocatorTextContentOptions options = null)
238            => _frame.TextContentAsync(_selector, ConvertOptions<FrameTextContentOptions>(options));
239
240        public Task TypeAsync(string text, LocatorTypeOptions options = null)
241            => _frame.TypeAsync(_selector, text, ConvertOptions<FrameTypeOptions>(options));
242
243        public Task UncheckAsync(LocatorUncheckOptions options = null)
244            => _frame.UncheckAsync(_selector, ConvertOptions<FrameUncheckOptions>(options));
245
246        ILocator ILocator.Locator(string selector, LocatorLocatorOptions options)
247            => new Locator(_frame, $"{_selector} >> {selector}", options);
248
249        public Task WaitForAsync(LocatorWaitForOptions options = null)
250            => _frame.LocatorWaitForAsync(_selector, ConvertOptions<LocatorWaitForOptions>(options));
251
252        internal Task<FrameExpectResult> ExpectAsync(string expression, FrameExpectOptions options = null)
253            => _frame.ExpectAsync(
254                _selector,
255                expression,
256                options);
257
258        public override string ToString() => "[email protected]" + _selector;
259
260        private T ConvertOptions<T>(object source)
261            where T : class, new()
262        {
263            T target = new();
264            var targetType = target.GetType();
265            if (source != null)
266            {
267                var sourceType = source.GetType();
268                foreach (var sourceProperty in sourceType.GetProperties())
269                {
270                    var targetProperty = targetType.GetProperty(sourceProperty.Name);
271                    if (targetProperty != null)
272                    {
273                        targetProperty.SetValue(target, sourceProperty.GetValue(source));
274                    }
275                }
276            }
277            var strictProperty = targetType.GetProperty("Strict");
278            if (strictProperty != null && strictProperty.GetValue(target) == null)
279            {
280                strictProperty.SetValue(target, true);
281            }
282            return target;
283        }
284
285        private async Task<TResult> WithElementAsync<TOptions, TResult>(Func<IElementHandle, TOptions, Task<TResult>> callback, TOptions options)
286            where TOptions : class
287            where TResult : class
288        {
289            IElementHandle handle = await ElementHandleAsync(ConvertOptions<LocatorElementHandleOptions>(options)).ConfigureAwait(false);
290            try
291            {
292                return await callback(handle, options).ConfigureAwait(false);
293            }
294            finally
295            {
296                await handle.DisposeAsync().ConfigureAwait(false);
297            }
298        }
299
300        private async Task WithElementAsync<TOptions>(Func<IElementHandle, TOptions, Task> callback, TOptions options)
301            where TOptions : class
302        {
303            IElementHandle handle = await ElementHandleAsync(ConvertOptions<LocatorElementHandleOptions>(options)).ConfigureAwait(false);
304            try
305            {
306                await callback(handle, options).ConfigureAwait(false);
307            }
308            finally
309            {
310                await handle.DisposeAsync().ConfigureAwait(false);
311            }
312        }
313
314        public Task HighlightAsync() => _frame.HighlightAsync(_selector);
315    }
316}
317
Full Screen

ILocator.cs

Source: ILocator.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    /// Locators are the central piece of Playwright's auto-waiting and retry-ability. In
45    /// a nutshell, locators represent a way to find element(s) on the page at any moment.
46    /// Locator can be created with the <see cref="IPage.Locator"/> method.
47    /// </para>
48    /// <para><a href="https://playwright.dev/dotnet/docs/locators">Learn more about locators</a>.</para>
49    /// </summary>
50    public partial interface ILocator
51    {
52        /// <summary><para>Returns an array of <c>node.innerText</c> values for all matching nodes.</para></summary>
53        Task<IReadOnlyList<string>> AllInnerTextsAsync();
54
55        /// <summary><para>Returns an array of <c>node.textContent</c> values for all matching nodes.</para></summary>
56        Task<IReadOnlyList<string>> AllTextContentsAsync();
57
58        /// <summary>
59        /// <para>
60        /// This method returns the bounding box of the element, or <c>null</c> if the element
61        /// is not visible. The bounding box is calculated relative to the main frame viewport
62        /// - which is usually the same as the browser window.
63        /// </para>
64        /// <para>
65        /// Scrolling affects the returned bonding box, similarly to <a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect">Element.getBoundingClientRect</a>.
66        /// That means <c>x</c> and/or <c>y</c> may be negative.
67        /// </para>
68        /// <para>
69        /// Elements from child frames return the bounding box relative to the main frame, unlike
70        /// the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect">Element.getBoundingClientRect</a>.
71        /// </para>
72        /// <para>
73        /// Assuming the page is static, it is safe to use bounding box coordinates to perform
74        /// input. For example, the following snippet should click the center of the element.
75        /// </para>
76        /// <code>
77        /// var box = await element.BoundingBoxAsync();<br/>
78        /// await page.Mouse.ClickAsync(box.X + box.Width / 2, box.Y + box.Height / 2);
79        /// </code>
80        /// </summary>
81        /// <param name="options">Call options</param>
82        Task<LocatorBoundingBoxResult?> BoundingBoxAsync(LocatorBoundingBoxOptions? options = default);
83
84        /// <summary>
85        /// <para>This method checks the element by performing the following steps:</para>
86        /// <list type="ordinal">
87        /// <item><description>
88        /// Ensure that element is a checkbox or a radio input. If not, this method throws.
89        /// If the element is already checked, this method returns immediately.
90        /// </description></item>
91        /// <item><description>
92        /// Wait for <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
93        /// checks on the element, unless <paramref name="force"/> option is set.
94        /// </description></item>
95        /// <item><description>Scroll the element into view if needed.</description></item>
96        /// <item><description>Use <see cref="IPage.Mouse"/> to click in the center of the element.</description></item>
97        /// <item><description>
98        /// Wait for initiated navigations to either succeed or fail, unless <paramref name="noWaitAfter"/>
99        /// option is set.
100        /// </description></item>
101        /// <item><description>Ensure that the element is now checked. If not, this method throws.</description></item>
102        /// </list>
103        /// <para>
104        /// If the element is detached from the DOM at any moment during the action, this method
105        /// throws.
106        /// </para>
107        /// <para>
108        /// When all steps combined have not finished during the specified <paramref name="timeout"/>,
109        /// this method throws a <see cref="TimeoutException"/>. Passing zero timeout disables
110        /// this.
111        /// </para>
112        /// </summary>
113        /// <param name="options">Call options</param>
114        Task CheckAsync(LocatorCheckOptions? options = default);
115
116        /// <summary>
117        /// <para>This method clicks the element by performing the following steps:</para>
118        /// <list type="ordinal">
119        /// <item><description>
120        /// Wait for <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
121        /// checks on the element, unless <paramref name="force"/> option is set.
122        /// </description></item>
123        /// <item><description>Scroll the element into view if needed.</description></item>
124        /// <item><description>
125        /// Use <see cref="IPage.Mouse"/> to click in the center of the element, or the specified
126        /// <paramref name="position"/>.
127        /// </description></item>
128        /// <item><description>
129        /// Wait for initiated navigations to either succeed or fail, unless <paramref name="noWaitAfter"/>
130        /// option is set.
131        /// </description></item>
132        /// </list>
133        /// <para>
134        /// If the element is detached from the DOM at any moment during the action, this method
135        /// throws.
136        /// </para>
137        /// <para>
138        /// When all steps combined have not finished during the specified <paramref name="timeout"/>,
139        /// this method throws a <see cref="TimeoutException"/>. Passing zero timeout disables
140        /// this.
141        /// </para>
142        /// </summary>
143        /// <param name="options">Call options</param>
144        Task ClickAsync(LocatorClickOptions? options = default);
145
146        /// <summary><para>Returns the number of elements matching given selector.</para></summary>
147        Task<int> CountAsync();
148
149        /// <summary>
150        /// <para>This method double clicks the element by performing the following steps:</para>
151        /// <list type="ordinal">
152        /// <item><description>
153        /// Wait for <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
154        /// checks on the element, unless <paramref name="force"/> option is set.
155        /// </description></item>
156        /// <item><description>Scroll the element into view if needed.</description></item>
157        /// <item><description>
158        /// Use <see cref="IPage.Mouse"/> to double click in the center of the element, or the
159        /// specified <paramref name="position"/>.
160        /// </description></item>
161        /// <item><description>
162        /// Wait for initiated navigations to either succeed or fail, unless <paramref name="noWaitAfter"/>
163        /// option is set. Note that if the first click of the <c>dblclick()</c> triggers a
164        /// navigation event, this method will throw.
165        /// </description></item>
166        /// </list>
167        /// <para>
168        /// If the element is detached from the DOM at any moment during the action, this method
169        /// throws.
170        /// </para>
171        /// <para>
172        /// When all steps combined have not finished during the specified <paramref name="timeout"/>,
173        /// this method throws a <see cref="TimeoutException"/>. Passing zero timeout disables
174        /// this.
175        /// </para>
176        /// </summary>
177        /// <remarks>
178        /// <para>
179        /// <c>element.dblclick()</c> dispatches two <c>click</c> events and a single <c>dblclick</c>
180        /// event.
181        /// </para>
182        /// </remarks>
183        /// <param name="options">Call options</param>
184        Task DblClickAsync(LocatorDblClickOptions? options = default);
185
186        /// <summary>
187        /// <para>
188        /// The snippet below dispatches the <c>click</c> event on the element. Regardless of
189        /// the visibility state of the element, <c>click</c> is dispatched. This is equivalent
190        /// to calling <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click">element.click()</a>.
191        /// </para>
192        /// <code>await element.DispatchEventAsync("click");</code>
193        /// <para>
194        /// Under the hood, it creates an instance of an event based on the given <paramref
195        /// name="type"/>, initializes it with <paramref name="eventInit"/> properties and dispatches
196        /// it on the element. Events are <c>composed</c>, <c>cancelable</c> and bubble by default.
197        /// </para>
198        /// <para>
199        /// Since <paramref name="eventInit"/> is event-specific, please refer to the events
200        /// documentation for the lists of initial properties:
201        /// </para>
202        /// <list type="bullet">
203        /// <item><description><a href="https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent">DragEvent</a></description></item>
204        /// <item><description><a href="https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent">FocusEvent</a></description></item>
205        /// <item><description><a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent">KeyboardEvent</a></description></item>
206        /// <item><description><a href="https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent">MouseEvent</a></description></item>
207        /// <item><description><a href="https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/PointerEvent">PointerEvent</a></description></item>
208        /// <item><description><a href="https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/TouchEvent">TouchEvent</a></description></item>
209        /// <item><description><a href="https://developer.mozilla.org/en-US/docs/Web/API/Event/Event">Event</a></description></item>
210        /// </list>
211        /// <para>
212        /// You can also specify <c>JSHandle</c> as the property value if you want live objects
213        /// to be passed into the event:
214        /// </para>
215        /// <code>
216        /// var dataTransfer = await page.EvaluateHandleAsync("() =&gt; new DataTransfer()");<br/>
217        /// await element.DispatchEventAsync("dragstart", new Dictionary&lt;string, object&gt;<br/>
218        /// {<br/>
219        ///     { "dataTransfer", dataTransfer }<br/>
220        /// });
221        /// </code>
222        /// </summary>
223        /// <param name="type">DOM event type: <c>"click"</c>, <c>"dragstart"</c>, etc.</param>
224        /// <param name="eventInit">Optional event-specific initialization properties.</param>
225        /// <param name="options">Call options</param>
226        Task DispatchEventAsync(string type, object? eventInit = default, LocatorDispatchEventOptions? options = default);
227
228        /// <param name="target">Locator of the element to drag to.</param>
229        /// <param name="options">Call options</param>
230        Task DragToAsync(ILocator target, LocatorDragToOptions? options = default);
231
232        /// <summary>
233        /// <para>
234        /// Resolves given locator to the first matching DOM element. If no elements matching
235        /// the query are visible, waits for them up to a given timeout. If multiple elements
236        /// match the selector, throws.
237        /// </para>
238        /// </summary>
239        /// <param name="options">Call options</param>
240        Task<IElementHandle> ElementHandleAsync(LocatorElementHandleOptions? options = default);
241
242        /// <summary><para>Resolves given locator to all matching DOM elements.</para></summary>
243        Task<IReadOnlyList<IElementHandle>> ElementHandlesAsync();
244
245        /// <summary>
246        /// <para>Returns the return value of <paramref name="expression"/>.</para>
247        /// <para>This method passes this handle as the first argument to <paramref name="expression"/>.</para>
248        /// <para>
249        /// If <paramref name="expression"/> returns a <see cref="Task"/>, then <c>handle.evaluate</c>
250        /// would wait for the promise to resolve and return its value.
251        /// </para>
252        /// <para>Examples:</para>
253        /// <code>
254        /// var tweets = page.Locator(".tweet .retweets");<br/>
255        /// Assert.AreEqual("10 retweets", await tweets.EvaluateAsync("node =&gt; node.innerText"));
256        /// </code>
257        /// </summary>
258        /// <param name="expression">
259        /// JavaScript expression to be evaluated in the browser context. If it looks like a
260        /// function declaration, it is interpreted as a function. Otherwise, evaluated as an
261        /// expression.
262        /// </param>
263        /// <param name="arg">Optional argument to pass to <paramref name="expression"/>.</param>
264        /// <param name="options">Call options</param>
265        Task<T> EvaluateAsync<T>(string expression, object? arg = default, LocatorEvaluateOptions? options = default);
266
267        /// <summary>
268        /// <para>
269        /// The method finds all elements matching the specified locator and passes an array
270        /// of matched elements as a first argument to <paramref name="expression"/>. Returns
271        /// the result of <paramref name="expression"/> invocation.
272        /// </para>
273        /// <para>
274        /// If <paramref name="expression"/> returns a <see cref="Task"/>, then <see cref="ILocator.EvaluateAllAsync"/>
275        /// would wait for the promise to resolve and return its value.
276        /// </para>
277        /// <para>Examples:</para>
278        /// <code>
279        /// var elements = page.Locator("div");<br/>
280        /// var divsCount = await elements.EvaluateAll&lt;bool&gt;("(divs, min) =&gt; divs.length &gt;= min", 10);
281        /// </code>
282        /// </summary>
283        /// <param name="expression">
284        /// JavaScript expression to be evaluated in the browser context. If it looks like a
285        /// function declaration, it is interpreted as a function. Otherwise, evaluated as an
286        /// expression.
287        /// </param>
288        /// <param name="arg">Optional argument to pass to <paramref name="expression"/>.</param>
289        Task<T> EvaluateAllAsync<T>(string expression, object? arg = default);
290
291        /// <summary>
292        /// <para>Returns the return value of <paramref name="expression"/> as a <see cref="IJSHandle"/>.</para>
293        /// <para>This method passes this handle as the first argument to <paramref name="expression"/>.</para>
294        /// <para>
295        /// The only difference between <see cref="ILocator.EvaluateAsync"/> and <see cref="ILocator.EvaluateHandleAsync"/>
296        /// is that <see cref="ILocator.EvaluateHandleAsync"/> returns <see cref="IJSHandle"/>.
297        /// </para>
298        /// <para>
299        /// If the function passed to the <see cref="ILocator.EvaluateHandleAsync"/> returns
300        /// a <see cref="Task"/>, then <see cref="ILocator.EvaluateHandleAsync"/> would wait
301        /// for the promise to resolve and return its value.
302        /// </para>
303        /// <para>See <see cref="IPage.EvaluateHandleAsync"/> for more details.</para>
304        /// </summary>
305        /// <param name="expression">
306        /// JavaScript expression to be evaluated in the browser context. If it looks like a
307        /// function declaration, it is interpreted as a function. Otherwise, evaluated as an
308        /// expression.
309        /// </param>
310        /// <param name="arg">Optional argument to pass to <paramref name="expression"/>.</param>
311        /// <param name="options">Call options</param>
312        Task<IJSHandle> EvaluateHandleAsync(string expression, object? arg = default, LocatorEvaluateHandleOptions? options = default);
313
314        /// <summary>
315        /// <para>
316        /// This method waits for <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
317        /// checks, focuses the element, fills it and triggers an <c>input</c> event after filling.
318        /// Note that you can pass an empty string to clear the input field.
319        /// </para>
320        /// <para>
321        /// If the target element is not an <c>&lt;input&gt;</c>, <c>&lt;textarea&gt;</c> or
322        /// <c>[contenteditable]</c> element, this method throws an error. However, if the element
323        /// 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>,
324        /// the control will be filled instead.
325        /// </para>
326        /// <para>To send fine-grained keyboard events, use <see cref="ILocator.TypeAsync"/>.</para>
327        /// </summary>
328        /// <param name="value">
329        /// Value to set for the <c>&lt;input&gt;</c>, <c>&lt;textarea&gt;</c> or <c>[contenteditable]</c>
330        /// element.
331        /// </param>
332        /// <param name="options">Call options</param>
333        Task FillAsync(string value, LocatorFillOptions? options = default);
334
335        /// <summary><para>Returns locator to the first matching element.</para></summary>
336        ILocator First { get; }
337
338        /// <summary>
339        /// <para>
340        /// Calls <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus">focus</a>
341        /// on the element.
342        /// </para>
343        /// </summary>
344        /// <param name="options">Call options</param>
345        Task FocusAsync(LocatorFocusOptions? options = default);
346
347        /// <summary>
348        /// <para>
349        /// When working with iframes, you can create a frame locator that will enter the iframe
350        /// and allow selecting elements in that iframe:
351        /// </para>
352        /// <code>
353        /// var locator = page.FrameLocator("iframe").Locator("text=Submit");<br/>
354        /// await locator.ClickAsync();
355        /// </code>
356        /// </summary>
357        /// <param name="selector">
358        /// A selector to use when resolving DOM element. See <a href="https://playwright.dev/dotnet/docs/selectors">working
359        /// with selectors</a> for more details.
360        /// </param>
361        IFrameLocator FrameLocator(string selector);
362
363        /// <summary><para>Returns element attribute value.</para></summary>
364        /// <param name="name">Attribute name to get the value for.</param>
365        /// <param name="options">Call options</param>
366        Task<string?> GetAttributeAsync(string name, LocatorGetAttributeOptions? options = default);
367
368        /// <summary>
369        /// <para>
370        /// Highlight the corresponding element(s) on the screen. Useful for debugging, don't
371        /// commit the code that uses <see cref="ILocator.HighlightAsync"/>.
372        /// </para>
373        /// </summary>
374        Task HighlightAsync();
375
376        /// <summary>
377        /// <para>This method hovers over the element by performing the following steps:</para>
378        /// <list type="ordinal">
379        /// <item><description>
380        /// Wait for <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
381        /// checks on the element, unless <paramref name="force"/> option is set.
382        /// </description></item>
383        /// <item><description>Scroll the element into view if needed.</description></item>
384        /// <item><description>
385        /// Use <see cref="IPage.Mouse"/> to hover over the center of the element, or the specified
386        /// <paramref name="position"/>.
387        /// </description></item>
388        /// <item><description>
389        /// Wait for initiated navigations to either succeed or fail, unless <c>noWaitAfter</c>
390        /// option is set.
391        /// </description></item>
392        /// </list>
393        /// <para>
394        /// If the element is detached from the DOM at any moment during the action, this method
395        /// throws.
396        /// </para>
397        /// <para>
398        /// When all steps combined have not finished during the specified <paramref name="timeout"/>,
399        /// this method throws a <see cref="TimeoutException"/>. Passing zero timeout disables
400        /// this.
401        /// </para>
402        /// </summary>
403        /// <param name="options">Call options</param>
404        Task HoverAsync(LocatorHoverOptions? options = default);
405
406        /// <summary><para>Returns the <c>element.innerHTML</c>.</para></summary>
407        /// <param name="options">Call options</param>
408        Task<string> InnerHTMLAsync(LocatorInnerHTMLOptions? options = default);
409
410        /// <summary><para>Returns the <c>element.innerText</c>.</para></summary>
411        /// <param name="options">Call options</param>
412        Task<string> InnerTextAsync(LocatorInnerTextOptions? options = default);
413
414        /// <summary>
415        /// <para>
416        /// Returns <c>input.value</c> for <c>&lt;input&gt;</c> or <c>&lt;textarea&gt;</c> or
417        /// <c>&lt;select&gt;</c> element. Throws for non-input elements.
418        /// </para>
419        /// </summary>
420        /// <param name="options">Call options</param>
421        Task<string> InputValueAsync(LocatorInputValueOptions? options = default);
422
423        /// <summary>
424        /// <para>
425        /// Returns whether the element is checked. Throws if the element is not a checkbox
426        /// or radio input.
427        /// </para>
428        /// </summary>
429        /// <param name="options">Call options</param>
430        Task<bool> IsCheckedAsync(LocatorIsCheckedOptions? options = default);
431
432        /// <summary><para>Returns whether the element is disabled, the opposite of <a href="https://playwright.dev/dotnet/docs/actionability#enabled">enabled</a>.</para></summary>
433        /// <param name="options">Call options</param>
434        Task<bool> IsDisabledAsync(LocatorIsDisabledOptions? options = default);
435
436        /// <summary><para>Returns whether the element is <a href="https://playwright.dev/dotnet/docs/actionability#editable">editable</a>.</para></summary>
437        /// <param name="options">Call options</param>
438        Task<bool> IsEditableAsync(LocatorIsEditableOptions? options = default);
439
440        /// <summary><para>Returns whether the element is <a href="https://playwright.dev/dotnet/docs/actionability#enabled">enabled</a>.</para></summary>
441        /// <param name="options">Call options</param>
442        Task<bool> IsEnabledAsync(LocatorIsEnabledOptions? options = default);
443
444        /// <summary><para>Returns whether the element is hidden, the opposite of <a href="https://playwright.dev/dotnet/docs/actionability#visible">visible</a>.</para></summary>
445        /// <param name="options">Call options</param>
446        Task<bool> IsHiddenAsync(LocatorIsHiddenOptions? options = default);
447
448        /// <summary><para>Returns whether the element is <a href="https://playwright.dev/dotnet/docs/actionability#visible">visible</a>.</para></summary>
449        /// <param name="options">Call options</param>
450        Task<bool> IsVisibleAsync(LocatorIsVisibleOptions? options = default);
451
452        /// <summary><para>Returns locator to the last matching element.</para></summary>
453        ILocator Last { get; }
454
455        /// <summary>
456        /// <para>
457        /// The method finds an element matching the specified selector in the <c>Locator</c>'s
458        /// subtree.
459        /// </para>
460        /// </summary>
461        /// <param name="selector">
462        /// A selector to use when resolving DOM element. See <a href="https://playwright.dev/dotnet/docs/selectors">working
463        /// with selectors</a> for more details.
464        /// </param>
465        /// <param name="options">Call options</param>
466        ILocator Locator(string selector, LocatorLocatorOptions? options = default);
467
468        /// <summary>
469        /// <para>
470        /// Returns locator to the n-th matching element. It's zero based, <c>nth(0)</c> selects
471        /// the first element.
472        /// </para>
473        /// </summary>
474        /// <param name="index">
475        /// </param>
476        ILocator Nth(int index);
477
478        /// <summary><para>A page this locator belongs to.</para></summary>
479        IPage Page { get; }
480
481        /// <summary>
482        /// <para>Focuses the element, and then uses <see cref="IKeyboard.DownAsync"/> and <see cref="IKeyboard.UpAsync"/>.</para>
483        /// <para>
484        /// <paramref name="key"/> can specify the intended <a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key">keyboardEvent.key</a>
485        /// value or a single character to generate the text for. A superset of the <paramref
486        /// name="key"/> values can be found <a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values">here</a>.
487        /// Examples of the keys are:
488        /// </para>
489        /// <para>
490        /// <c>F1</c> - <c>F12</c>, <c>Digit0</c>- <c>Digit9</c>, <c>KeyA</c>- <c>KeyZ</c>,
491        /// <c>Backquote</c>, <c>Minus</c>, <c>Equal</c>, <c>Backslash</c>, <c>Backspace</c>,
492        /// <c>Tab</c>, <c>Delete</c>, <c>Escape</c>, <c>ArrowDown</c>, <c>End</c>, <c>Enter</c>,
493        /// <c>Home</c>, <c>Insert</c>, <c>PageDown</c>, <c>PageUp</c>, <c>ArrowRight</c>, <c>ArrowUp</c>,
494        /// etc.
495        /// </para>
496        /// <para>
497        /// Following modification shortcuts are also supported: <c>Shift</c>, <c>Control</c>,
498        /// <c>Alt</c>, <c>Meta</c>, <c>ShiftLeft</c>.
499        /// </para>
500        /// <para>
501        /// Holding down <c>Shift</c> will type the text that corresponds to the <paramref name="key"/>
502        /// in the upper case.
503        /// </para>
504        /// <para>
505        /// If <paramref name="key"/> is a single character, it is case-sensitive, so the values
506        /// <c>a</c> and <c>A</c> will generate different respective texts.
507        /// </para>
508        /// <para>
509        /// Shortcuts such as <c>key: "Control+o"</c> or <c>key: "Control+Shift+T"</c> are supported
510        /// as well. When specified with the modifier, modifier is pressed and being held while
511        /// the subsequent key is being pressed.
512        /// </para>
513        /// </summary>
514        /// <param name="key">
515        /// Name of the key to press or a character to generate, such as <c>ArrowLeft</c> or
516        /// <c>a</c>.
517        /// </param>
518        /// <param name="options">Call options</param>
519        Task PressAsync(string key, LocatorPressOptions? options = default);
520
521        /// <summary>
522        /// <para>Returns the buffer with the captured screenshot.</para>
523        /// <para>
524        /// This method waits for the <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
525        /// checks, then scrolls element into view before taking a screenshot. If the element
526        /// is detached from DOM, the method throws an error.
527        /// </para>
528        /// </summary>
529        /// <param name="options">Call options</param>
530        Task<byte[]> ScreenshotAsync(LocatorScreenshotOptions? options = default);
531
532        /// <summary>
533        /// <para>
534        /// This method waits for <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
535        /// checks, then tries to scroll element into view, unless it is completely visible
536        /// as defined by <a href="https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API">IntersectionObserver</a>'s
537        /// <c>ratio</c>.
538        /// </para>
539        /// </summary>
540        /// <param name="options">Call options</param>
541        Task ScrollIntoViewIfNeededAsync(LocatorScrollIntoViewIfNeededOptions? options = default);
542
543        /// <summary>
544        /// <para>
545        /// This method waits for <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
546        /// checks, waits until all specified options are present in the <c>&lt;select&gt;</c>
547        /// element and selects these options.
548        /// </para>
549        /// <para>
550        /// If the target element is not a <c>&lt;select&gt;</c> element, this method throws
551        /// an error. However, if the element is inside the <c>&lt;label&gt;</c> element that
552        /// has an associated <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>,
553        /// the control will be used instead.
554        /// </para>
555        /// <para>Returns the array of option values that have been successfully selected.</para>
556        /// <para>
557        /// Triggers a <c>change</c> and <c>input</c> event once all the provided options have
558        /// been selected.
559        /// </para>
560        /// <code>
561        /// // single selection matching the value<br/>
562        /// await element.SelectOptionAsync(new[] { "blue" });<br/>
563        /// // single selection matching the label<br/>
564        /// await element.SelectOptionAsync(new[] { new SelectOptionValue() { Label = "blue" } });<br/>
565        /// // multiple selection<br/>
566        /// await element.SelectOptionAsync(new[] { "red", "green", "blue" });<br/>
567        /// // multiple selection for blue, red and second option<br/>
568        /// await element.SelectOptionAsync(new[] {<br/>
569        ///     new SelectOptionValue() { Label = "blue" },<br/>
570        ///     new SelectOptionValue() { Index = 2 },<br/>
571        ///     new SelectOptionValue() { Value = "red" }});
572        /// </code>
573        /// </summary>
574        /// <param name="values">
575        /// Options to select. If the <c>&lt;select&gt;</c> has the <c>multiple</c> attribute,
576        /// all matching options are selected, otherwise only the first option matching one
577        /// of the passed options is selected. String values are equivalent to <c>{value:'string'}</c>.
578        /// Option is considered matching if all specified properties match.
579        /// </param>
580        /// <param name="options">Call options</param>
581        Task<IReadOnlyList<string>> SelectOptionAsync(string values, LocatorSelectOptionOptions? options = default);
582
583        /// <summary>
584        /// <para>
585        /// This method waits for <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
586        /// checks, waits until all specified options are present in the <c>&lt;select&gt;</c>
587        /// element and selects these options.
588        /// </para>
589        /// <para>
590        /// If the target element is not a <c>&lt;select&gt;</c> element, this method throws
591        /// an error. However, if the element is inside the <c>&lt;label&gt;</c> element that
592        /// has an associated <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>,
593        /// the control will be used instead.
594        /// </para>
595        /// <para>Returns the array of option values that have been successfully selected.</para>
596        /// <para>
597        /// Triggers a <c>change</c> and <c>input</c> event once all the provided options have
598        /// been selected.
599        /// </para>
600        /// <code>
601        /// // single selection matching the value<br/>
602        /// await element.SelectOptionAsync(new[] { "blue" });<br/>
603        /// // single selection matching the label<br/>
604        /// await element.SelectOptionAsync(new[] { new SelectOptionValue() { Label = "blue" } });<br/>
605        /// // multiple selection<br/>
606        /// await element.SelectOptionAsync(new[] { "red", "green", "blue" });<br/>
607        /// // multiple selection for blue, red and second option<br/>
608        /// await element.SelectOptionAsync(new[] {<br/>
609        ///     new SelectOptionValue() { Label = "blue" },<br/>
610        ///     new SelectOptionValue() { Index = 2 },<br/>
611        ///     new SelectOptionValue() { Value = "red" }});
612        /// </code>
613        /// </summary>
614        /// <param name="values">
615        /// Options to select. If the <c>&lt;select&gt;</c> has the <c>multiple</c> attribute,
616        /// all matching options are selected, otherwise only the first option matching one
617        /// of the passed options is selected. String values are equivalent to <c>{value:'string'}</c>.
618        /// Option is considered matching if all specified properties match.
619        /// </param>
620        /// <param name="options">Call options</param>
621        Task<IReadOnlyList<string>> SelectOptionAsync(IElementHandle values, LocatorSelectOptionOptions? options = default);
622
623        /// <summary>
624        /// <para>
625        /// This method waits for <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
626        /// checks, waits until all specified options are present in the <c>&lt;select&gt;</c>
627        /// element and selects these options.
628        /// </para>
629        /// <para>
630        /// If the target element is not a <c>&lt;select&gt;</c> element, this method throws
631        /// an error. However, if the element is inside the <c>&lt;label&gt;</c> element that
632        /// has an associated <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>,
633        /// the control will be used instead.
634        /// </para>
635        /// <para>Returns the array of option values that have been successfully selected.</para>
636        /// <para>
637        /// Triggers a <c>change</c> and <c>input</c> event once all the provided options have
638        /// been selected.
639        /// </para>
640        /// <code>
641        /// // single selection matching the value<br/>
642        /// await element.SelectOptionAsync(new[] { "blue" });<br/>
643        /// // single selection matching the label<br/>
644        /// await element.SelectOptionAsync(new[] { new SelectOptionValue() { Label = "blue" } });<br/>
645        /// // multiple selection<br/>
646        /// await element.SelectOptionAsync(new[] { "red", "green", "blue" });<br/>
647        /// // multiple selection for blue, red and second option<br/>
648        /// await element.SelectOptionAsync(new[] {<br/>
649        ///     new SelectOptionValue() { Label = "blue" },<br/>
650        ///     new SelectOptionValue() { Index = 2 },<br/>
651        ///     new SelectOptionValue() { Value = "red" }});
652        /// </code>
653        /// </summary>
654        /// <param name="values">
655        /// Options to select. If the <c>&lt;select&gt;</c> has the <c>multiple</c> attribute,
656        /// all matching options are selected, otherwise only the first option matching one
657        /// of the passed options is selected. String values are equivalent to <c>{value:'string'}</c>.
658        /// Option is considered matching if all specified properties match.
659        /// </param>
660        /// <param name="options">Call options</param>
661        Task<IReadOnlyList<string>> SelectOptionAsync(IEnumerable<string> values, LocatorSelectOptionOptions? options = default);
662
663        /// <summary>
664        /// <para>
665        /// This method waits for <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
666        /// checks, waits until all specified options are present in the <c>&lt;select&gt;</c>
667        /// element and selects these options.
668        /// </para>
669        /// <para>
670        /// If the target element is not a <c>&lt;select&gt;</c> element, this method throws
671        /// an error. However, if the element is inside the <c>&lt;label&gt;</c> element that
672        /// has an associated <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>,
673        /// the control will be used instead.
674        /// </para>
675        /// <para>Returns the array of option values that have been successfully selected.</para>
676        /// <para>
677        /// Triggers a <c>change</c> and <c>input</c> event once all the provided options have
678        /// been selected.
679        /// </para>
680        /// <code>
681        /// // single selection matching the value<br/>
682        /// await element.SelectOptionAsync(new[] { "blue" });<br/>
683        /// // single selection matching the label<br/>
684        /// await element.SelectOptionAsync(new[] { new SelectOptionValue() { Label = "blue" } });<br/>
685        /// // multiple selection<br/>
686        /// await element.SelectOptionAsync(new[] { "red", "green", "blue" });<br/>
687        /// // multiple selection for blue, red and second option<br/>
688        /// await element.SelectOptionAsync(new[] {<br/>
689        ///     new SelectOptionValue() { Label = "blue" },<br/>
690        ///     new SelectOptionValue() { Index = 2 },<br/>
691        ///     new SelectOptionValue() { Value = "red" }});
692        /// </code>
693        /// </summary>
694        /// <param name="values">
695        /// Options to select. If the <c>&lt;select&gt;</c> has the <c>multiple</c> attribute,
696        /// all matching options are selected, otherwise only the first option matching one
697        /// of the passed options is selected. String values are equivalent to <c>{value:'string'}</c>.
698        /// Option is considered matching if all specified properties match.
699        /// </param>
700        /// <param name="options">Call options</param>
701        Task<IReadOnlyList<string>> SelectOptionAsync(SelectOptionValue values, LocatorSelectOptionOptions? options = default);
702
703        /// <summary>
704        /// <para>
705        /// This method waits for <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
706        /// checks, waits until all specified options are present in the <c>&lt;select&gt;</c>
707        /// element and selects these options.
708        /// </para>
709        /// <para>
710        /// If the target element is not a <c>&lt;select&gt;</c> element, this method throws
711        /// an error. However, if the element is inside the <c>&lt;label&gt;</c> element that
712        /// has an associated <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>,
713        /// the control will be used instead.
714        /// </para>
715        /// <para>Returns the array of option values that have been successfully selected.</para>
716        /// <para>
717        /// Triggers a <c>change</c> and <c>input</c> event once all the provided options have
718        /// been selected.
719        /// </para>
720        /// <code>
721        /// // single selection matching the value<br/>
722        /// await element.SelectOptionAsync(new[] { "blue" });<br/>
723        /// // single selection matching the label<br/>
724        /// await element.SelectOptionAsync(new[] { new SelectOptionValue() { Label = "blue" } });<br/>
725        /// // multiple selection<br/>
726        /// await element.SelectOptionAsync(new[] { "red", "green", "blue" });<br/>
727        /// // multiple selection for blue, red and second option<br/>
728        /// await element.SelectOptionAsync(new[] {<br/>
729        ///     new SelectOptionValue() { Label = "blue" },<br/>
730        ///     new SelectOptionValue() { Index = 2 },<br/>
731        ///     new SelectOptionValue() { Value = "red" }});
732        /// </code>
733        /// </summary>
734        /// <param name="values">
735        /// Options to select. If the <c>&lt;select&gt;</c> has the <c>multiple</c> attribute,
736        /// all matching options are selected, otherwise only the first option matching one
737        /// of the passed options is selected. String values are equivalent to <c>{value:'string'}</c>.
738        /// Option is considered matching if all specified properties match.
739        /// </param>
740        /// <param name="options">Call options</param>
741        Task<IReadOnlyList<string>> SelectOptionAsync(IEnumerable<IElementHandle> values, LocatorSelectOptionOptions? options = default);
742
743        /// <summary>
744        /// <para>
745        /// This method waits for <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
746        /// checks, waits until all specified options are present in the <c>&lt;select&gt;</c>
747        /// element and selects these options.
748        /// </para>
749        /// <para>
750        /// If the target element is not a <c>&lt;select&gt;</c> element, this method throws
751        /// an error. However, if the element is inside the <c>&lt;label&gt;</c> element that
752        /// has an associated <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>,
753        /// the control will be used instead.
754        /// </para>
755        /// <para>Returns the array of option values that have been successfully selected.</para>
756        /// <para>
757        /// Triggers a <c>change</c> and <c>input</c> event once all the provided options have
758        /// been selected.
759        /// </para>
760        /// <code>
761        /// // single selection matching the value<br/>
762        /// await element.SelectOptionAsync(new[] { "blue" });<br/>
763        /// // single selection matching the label<br/>
764        /// await element.SelectOptionAsync(new[] { new SelectOptionValue() { Label = "blue" } });<br/>
765        /// // multiple selection<br/>
766        /// await element.SelectOptionAsync(new[] { "red", "green", "blue" });<br/>
767        /// // multiple selection for blue, red and second option<br/>
768        /// await element.SelectOptionAsync(new[] {<br/>
769        ///     new SelectOptionValue() { Label = "blue" },<br/>
770        ///     new SelectOptionValue() { Index = 2 },<br/>
771        ///     new SelectOptionValue() { Value = "red" }});
772        /// </code>
773        /// </summary>
774        /// <param name="values">
775        /// Options to select. If the <c>&lt;select&gt;</c> has the <c>multiple</c> attribute,
776        /// all matching options are selected, otherwise only the first option matching one
777        /// of the passed options is selected. String values are equivalent to <c>{value:'string'}</c>.
778        /// Option is considered matching if all specified properties match.
779        /// </param>
780        /// <param name="options">Call options</param>
781        Task<IReadOnlyList<string>> SelectOptionAsync(IEnumerable<SelectOptionValue> values, LocatorSelectOptionOptions? options = default);
782
783        /// <summary>
784        /// <para>
785        /// This method waits for <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
786        /// checks, then focuses the element and selects all its text content.
787        /// </para>
788        /// </summary>
789        /// <param name="options">Call options</param>
790        Task SelectTextAsync(LocatorSelectTextOptions? options = default);
791
792        /// <summary>
793        /// <para>This method checks or unchecks an element by performing the following steps:</para>
794        /// <list type="ordinal">
795        /// <item><description>
796        /// Ensure that matched element is a checkbox or a radio input. If not, this method
797        /// throws.
798        /// </description></item>
799        /// <item><description>If the element already has the right checked state, this method returns immediately.</description></item>
800        /// <item><description>
801        /// Wait for <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
802        /// checks on the matched element, unless <paramref name="force"/> option is set. If
803        /// the element is detached during the checks, the whole action is retried.
804        /// </description></item>
805        /// <item><description>Scroll the element into view if needed.</description></item>
806        /// <item><description>Use <see cref="IPage.Mouse"/> to click in the center of the element.</description></item>
807        /// <item><description>
808        /// Wait for initiated navigations to either succeed or fail, unless <paramref name="noWaitAfter"/>
809        /// option is set.
810        /// </description></item>
811        /// <item><description>Ensure that the element is now checked or unchecked. If not, this method throws.</description></item>
812        /// </list>
813        /// <para>
814        /// When all steps combined have not finished during the specified <paramref name="timeout"/>,
815        /// this method throws a <see cref="TimeoutException"/>. Passing zero timeout disables
816        /// this.
817        /// </para>
818        /// </summary>
819        /// <param name="checkedState">Whether to check or uncheck the checkbox.</param>
820        /// <param name="options">Call options</param>
821        Task SetCheckedAsync(bool checkedState, LocatorSetCheckedOptions? options = default);
822
823        /// <summary>
824        /// <para>
825        /// This method expects <c>element</c> to point to an <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">input
826        /// element</a>.
827        /// </para>
828        /// <para>
829        /// Sets the value of the file input to these file paths or files. If some of the <c>filePaths</c>
830        /// are relative paths, then they are resolved relative to the the current working directory.
831        /// For empty array, clears the selected files.
832        /// </para>
833        /// </summary>
834        /// <param name="files">
835        /// </param>
836        /// <param name="options">Call options</param>
837        Task SetInputFilesAsync(string files, LocatorSetInputFilesOptions? options = default);
838
839        /// <summary>
840        /// <para>
841        /// This method expects <c>element</c> to point to an <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">input
842        /// element</a>.
843        /// </para>
844        /// <para>
845        /// Sets the value of the file input to these file paths or files. If some of the <c>filePaths</c>
846        /// are relative paths, then they are resolved relative to the the current working directory.
847        /// For empty array, clears the selected files.
848        /// </para>
849        /// </summary>
850        /// <param name="files">
851        /// </param>
852        /// <param name="options">Call options</param>
853        Task SetInputFilesAsync(IEnumerable<string> files, LocatorSetInputFilesOptions? options = default);
854
855        /// <summary>
856        /// <para>
857        /// This method expects <c>element</c> to point to an <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">input
858        /// element</a>.
859        /// </para>
860        /// <para>
861        /// Sets the value of the file input to these file paths or files. If some of the <c>filePaths</c>
862        /// are relative paths, then they are resolved relative to the the current working directory.
863        /// For empty array, clears the selected files.
864        /// </para>
865        /// </summary>
866        /// <param name="files">
867        /// </param>
868        /// <param name="options">Call options</param>
869        Task SetInputFilesAsync(FilePayload files, LocatorSetInputFilesOptions? options = default);
870
871        /// <summary>
872        /// <para>
873        /// This method expects <c>element</c> to point to an <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">input
874        /// element</a>.
875        /// </para>
876        /// <para>
877        /// Sets the value of the file input to these file paths or files. If some of the <c>filePaths</c>
878        /// are relative paths, then they are resolved relative to the the current working directory.
879        /// For empty array, clears the selected files.
880        /// </para>
881        /// </summary>
882        /// <param name="files">
883        /// </param>
884        /// <param name="options">Call options</param>
885        Task SetInputFilesAsync(IEnumerable<FilePayload> files, LocatorSetInputFilesOptions? options = default);
886
887        /// <summary>
888        /// <para>This method taps the element by performing the following steps:</para>
889        /// <list type="ordinal">
890        /// <item><description>
891        /// Wait for <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
892        /// checks on the element, unless <paramref name="force"/> option is set.
893        /// </description></item>
894        /// <item><description>Scroll the element into view if needed.</description></item>
895        /// <item><description>
896        /// Use <see cref="IPage.Touchscreen"/> to tap the center of the element, or the specified
897        /// <paramref name="position"/>.
898        /// </description></item>
899        /// <item><description>
900        /// Wait for initiated navigations to either succeed or fail, unless <paramref name="noWaitAfter"/>
901        /// option is set.
902        /// </description></item>
903        /// </list>
904        /// <para>
905        /// If the element is detached from the DOM at any moment during the action, this method
906        /// throws.
907        /// </para>
908        /// <para>
909        /// When all steps combined have not finished during the specified <paramref name="timeout"/>,
910        /// this method throws a <see cref="TimeoutException"/>. Passing zero timeout disables
911        /// this.
912        /// </para>
913        /// </summary>
914        /// <remarks>
915        /// <para>
916        /// <c>element.tap()</c> requires that the <c>hasTouch</c> option of the browser context
917        /// be set to true.
918        /// </para>
919        /// </remarks>
920        /// <param name="options">Call options</param>
921        Task TapAsync(LocatorTapOptions? options = default);
922
923        /// <summary><para>Returns the <c>node.textContent</c>.</para></summary>
924        /// <param name="options">Call options</param>
925        Task<string?> TextContentAsync(LocatorTextContentOptions? options = default);
926
927        /// <summary>
928        /// <para>
929        /// Focuses the element, and then sends a <c>keydown</c>, <c>keypress</c>/<c>input</c>,
930        /// and <c>keyup</c> event for each character in the text.
931        /// </para>
932        /// <para>To press a special key, like <c>Control</c> or <c>ArrowDown</c>, use <see cref="ILocator.PressAsync"/>.</para>
933        /// <code>
934        /// await element.TypeAsync("Hello"); // Types instantly<br/>
935        /// await element.TypeAsync("World", delay: 100); // Types slower, like a user
936        /// </code>
937        /// <para>An example of typing into a text field and then submitting the form:</para>
938        /// <code>
939        /// var element = page.Locator("input");<br/>
940        /// await element.TypeAsync("some text");<br/>
941        /// await element.PressAsync("Enter");
942        /// </code>
943        /// </summary>
944        /// <param name="text">A text to type into a focused element.</param>
945        /// <param name="options">Call options</param>
946        Task TypeAsync(string text, LocatorTypeOptions? options = default);
947
948        /// <summary>
949        /// <para>This method checks the element by performing the following steps:</para>
950        /// <list type="ordinal">
951        /// <item><description>
952        /// Ensure that element is a checkbox or a radio input. If not, this method throws.
953        /// If the element is already unchecked, this method returns immediately.
954        /// </description></item>
955        /// <item><description>
956        /// Wait for <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
957        /// checks on the element, unless <paramref name="force"/> option is set.
958        /// </description></item>
959        /// <item><description>Scroll the element into view if needed.</description></item>
960        /// <item><description>Use <see cref="IPage.Mouse"/> to click in the center of the element.</description></item>
961        /// <item><description>
962        /// Wait for initiated navigations to either succeed or fail, unless <paramref name="noWaitAfter"/>
963        /// option is set.
964        /// </description></item>
965        /// <item><description>Ensure that the element is now unchecked. If not, this method throws.</description></item>
966        /// </list>
967        /// <para>
968        /// If the element is detached from the DOM at any moment during the action, this method
969        /// throws.
970        /// </para>
971        /// <para>
972        /// When all steps combined have not finished during the specified <paramref name="timeout"/>,
973        /// this method throws a <see cref="TimeoutException"/>. Passing zero timeout disables
974        /// this.
975        /// </para>
976        /// </summary>
977        /// <param name="options">Call options</param>
978        Task UncheckAsync(LocatorUncheckOptions? options = default);
979
980        /// <summary>
981        /// <para>
982        /// Returns when element specified by locator satisfies the <paramref name="state"/>
983        /// option.
984        /// </para>
985        /// <para>
986        /// If target element already satisfies the condition, the method returns immediately.
987        /// Otherwise, waits for up to <paramref name="timeout"/> milliseconds until the condition
988        /// is met.
989        /// </para>
990        /// <code>
991        /// var orderSent = page.Locator("#order-sent");<br/>
992        /// orderSent.WaitForAsync();
993        /// </code>
994        /// </summary>
995        /// <param name="options">Call options</param>
996        Task WaitForAsync(LocatorWaitForOptions? options = default);
997    }
998}
999
1000#nullable disable
1001
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 LocatorSelectTextOptions

Trigger LocatorSelectTextOptions code on LambdaTest Cloud Grid

Execute automation tests with LocatorSelectTextOptions 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)