-
Notifications
You must be signed in to change notification settings - Fork 258
/
Copy pathILocator.cs
1904 lines (1823 loc) · 91.1 KB
/
ILocator.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* MIT License
*
* Copyright (c) Microsoft Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
#nullable enable
namespace Microsoft.Playwright;
/// <summary>
/// <para>
/// Locators are the central piece of Playwright's auto-waiting and retry-ability. In
/// a nutshell, locators represent a way to find element(s) on the page at any moment.
/// A locator can be created with the <see cref="IPage.Locator"/> method.
/// </para>
/// <para><a href="https://playwright.dev/dotnet/docs/locators">Learn more about locators</a>.</para>
/// </summary>
public partial interface ILocator
{
/// <summary>
/// <para>
/// When the locator points to a list of elements, this returns an array of locators,
/// pointing to their respective elements.
/// </para>
/// <para>
/// <see cref="ILocator.AllAsync"/> does not wait for elements to match the locator,
/// and instead immediately returns whatever is present in the page.
/// </para>
/// <para>
/// When the list of elements changes dynamically, <see cref="ILocator.AllAsync"/> will
/// produce unpredictable and flaky results.
/// </para>
/// <para>
/// When the list of elements is stable, but loaded dynamically, wait for the full list
/// to finish loading before calling <see cref="ILocator.AllAsync"/>.
/// </para>
/// <para>**Usage**</para>
/// <code>
/// foreach (var li in await page.GetByRole("listitem").AllAsync())<br/>
/// await li.ClickAsync();
/// </code>
/// </summary>
/// <remarks>
/// <para>
/// <see cref="ILocator.AllAsync"/> does not wait for elements to match the locator,
/// and instead immediately returns whatever is present in the page. When the list
/// of elements changes dynamically, <see cref="ILocator.AllAsync"/> will produce unpredictable
/// and flaky results. When the list of elements is stable, but loaded dynamically,
/// wait for the full list to finish loading before calling <see cref="ILocator.AllAsync"/>.
///
/// </para>
/// </remarks>
Task<IReadOnlyList<ILocator>> AllAsync();
/// <summary>
/// <para>Returns an array of <c>node.innerText</c> values for all matching nodes.</para>
/// <para>
/// If you need to assert text on the page, prefer <see cref="ILocatorAssertions.ToHaveTextAsync"/>
/// with <see cref="ILocatorAssertions.ToHaveTextAsync"/> option to avoid flakiness.
/// See <a href="https://playwright.dev/dotnet/docs/test-assertions">assertions guide</a>
/// for more details.
/// </para>
/// <para>**Usage**</para>
/// <code>var texts = await page.GetByRole(AriaRole.Link).AllInnerTextsAsync();</code>
/// </summary>
/// <remarks>
/// <para>
/// If you need to assert text on the page, prefer <see cref="ILocatorAssertions.ToHaveTextAsync"/>
/// with <see cref="ILocatorAssertions.ToHaveTextAsync"/> option to avoid flakiness.
/// See <a href="https://playwright.dev/dotnet/docs/test-assertions">assertions guide</a>
/// for more details.
/// </para>
/// </remarks>
Task<IReadOnlyList<string>> AllInnerTextsAsync();
/// <summary>
/// <para>Returns an array of <c>node.textContent</c> values for all matching nodes.</para>
/// <para>
/// If you need to assert text on the page, prefer <see cref="ILocatorAssertions.ToHaveTextAsync"/>
/// to avoid flakiness. See <a href="https://playwright.dev/dotnet/docs/test-assertions">assertions
/// guide</a> for more details.
/// </para>
/// <para>**Usage**</para>
/// <code>var texts = await page.GetByRole(AriaRole.Link).AllTextContentsAsync();</code>
/// </summary>
/// <remarks>
/// <para>
/// If you need to assert text on the page, prefer <see cref="ILocatorAssertions.ToHaveTextAsync"/>
/// to avoid flakiness. See <a href="https://playwright.dev/dotnet/docs/test-assertions">assertions
/// guide</a> for more details.
/// </para>
/// </remarks>
Task<IReadOnlyList<string>> AllTextContentsAsync();
/// <summary>
/// <para>Creates a locator that matches both this locator and the argument locator.</para>
/// <para>**Usage**</para>
/// <para>The following example finds a button with a specific title.</para>
/// <code>var button = page.GetByRole(AriaRole.Button).And(page.GetByTitle("Subscribe"));</code>
/// </summary>
/// <param name="locator">Additional locator to match.</param>
ILocator And(ILocator locator);
/// <summary>
/// <para>
/// Captures the aria snapshot of the given element. Read more about <a href="https://playwright.dev/dotnet/docs/aria-snapshots">aria
/// snapshots</a> and <see cref="ILocatorAssertions.ToMatchAriaSnapshotAsync"/> for
/// the corresponding assertion.
/// </para>
/// <para>**Usage**</para>
/// <code>await page.GetByRole(AriaRole.Link).AriaSnapshotAsync();</code>
/// <para>**Details**</para>
/// <para>
/// This method captures the aria snapshot of the given element. The snapshot is a string
/// that represents the state of the element and its children. The snapshot can be used
/// to assert the state of the element in the test, or to compare it to state in the
/// future.
/// </para>
/// <para>
/// The ARIA snapshot is represented using <a href="https://yaml.org/spec/1.2.2/">YAML</a>
/// markup language:
/// </para>
/// <list type="bullet">
/// <item><description>The keys of the objects are the roles and optional accessible names of the elements.</description></item>
/// <item><description>The values are either text content or an array of child elements.</description></item>
/// <item><description>Generic static text can be represented with the <c>text</c> key.</description></item>
/// </list>
/// <para>Below is the HTML markup and the respective ARIA snapshot:</para>
/// </summary>
/// <param name="options">Call options</param>
Task<string> AriaSnapshotAsync(LocatorAriaSnapshotOptions? options = default);
/// <summary>
/// <para>
/// Calls <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/blur">blur</a>
/// on the element.
/// </para>
/// </summary>
/// <param name="options">Call options</param>
Task BlurAsync(LocatorBlurOptions? options = default);
/// <summary>
/// <para>
/// This method returns the bounding box of the element matching the locator, or <c>null</c>
/// if the element is not visible. The bounding box is calculated relative to the main
/// frame viewport - which is usually the same as the browser window.
/// </para>
/// <para>**Details**</para>
/// <para>
/// Scrolling affects the returned bounding box, similarly to <a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect">Element.getBoundingClientRect</a>.
/// That means <c>x</c> and/or <c>y</c> may be negative.
/// </para>
/// <para>
/// Elements from child frames return the bounding box relative to the main frame, unlike
/// the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect">Element.getBoundingClientRect</a>.
/// </para>
/// <para>
/// Assuming the page is static, it is safe to use bounding box coordinates to perform
/// input. For example, the following snippet should click the center of the element.
/// </para>
/// <para>**Usage**</para>
/// <code>
/// var box = await page.GetByRole(AriaRole.Button).BoundingBoxAsync();<br/>
/// await page.Mouse.ClickAsync(box.X + box.Width / 2, box.Y + box.Height / 2);
/// </code>
/// </summary>
/// <param name="options">Call options</param>
Task<LocatorBoundingBoxResult?> BoundingBoxAsync(LocatorBoundingBoxOptions? options = default);
/// <summary>
/// <para>Ensure that checkbox or radio element is checked.</para>
/// <para>**Details**</para>
/// <para>Performs the following steps:</para>
/// <list type="ordinal">
/// <item><description>
/// Ensure that element is a checkbox or a radio input. If not, this method throws.
/// If the element is already checked, this method returns immediately.
/// </description></item>
/// <item><description>
/// Wait for <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
/// checks on the element, unless <see cref="ILocator.CheckAsync"/> option is set.
/// </description></item>
/// <item><description>Scroll the element into view if needed.</description></item>
/// <item><description>Use <see cref="IPage.Mouse"/> to click in the center of the element.</description></item>
/// <item><description>Ensure that the element is now checked. If not, this method throws.</description></item>
/// </list>
/// <para>
/// If the element is detached from the DOM at any moment during the action, this method
/// throws.
/// </para>
/// <para>
/// When all steps combined have not finished during the specified <see cref="ILocator.CheckAsync"/>,
/// this method throws a <see cref="TimeoutException"/>. Passing zero timeout disables
/// this.
/// </para>
/// <para>**Usage**</para>
/// <code>await page.GetByRole(AriaRole.Checkbox).CheckAsync();</code>
/// </summary>
/// <param name="options">Call options</param>
Task CheckAsync(LocatorCheckOptions? options = default);
/// <summary>
/// <para>Clear the input field.</para>
/// <para>**Details**</para>
/// <para>
/// This method waits for <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
/// checks, focuses the element, clears it and triggers an <c>input</c> event after
/// clearing.
/// </para>
/// <para>
/// If the target element is not an <c><input></c>, <c><textarea></c> or
/// <c>[contenteditable]</c> element, this method throws an error. However, if the element
/// is inside the <c><label></c> element that has an associated <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>,
/// the control will be cleared instead.
/// </para>
/// <para>**Usage**</para>
/// <code>await page.GetByRole(AriaRole.Textbox).ClearAsync();</code>
/// </summary>
/// <param name="options">Call options</param>
Task ClearAsync(LocatorClearOptions? options = default);
/// <summary>
/// <para>Click an element.</para>
/// <para>**Details**</para>
/// <para>This method clicks the element by performing the following steps:</para>
/// <list type="ordinal">
/// <item><description>
/// Wait for <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
/// checks on the element, unless <see cref="ILocator.ClickAsync"/> option is set.
/// </description></item>
/// <item><description>Scroll the element into view if needed.</description></item>
/// <item><description>
/// Use <see cref="IPage.Mouse"/> to click in the center of the element, or the specified
/// <see cref="ILocator.ClickAsync"/>.
/// </description></item>
/// <item><description>
/// Wait for initiated navigations to either succeed or fail, unless <see cref="ILocator.ClickAsync"/>
/// option is set.
/// </description></item>
/// </list>
/// <para>
/// If the element is detached from the DOM at any moment during the action, this method
/// throws.
/// </para>
/// <para>
/// When all steps combined have not finished during the specified <see cref="ILocator.ClickAsync"/>,
/// this method throws a <see cref="TimeoutException"/>. Passing zero timeout disables
/// this.
/// </para>
/// <para>**Usage**</para>
/// <para>Click a button:</para>
/// <code>await page.GetByRole(AriaRole.Button).ClickAsync();</code>
/// <para>Shift-right-click at a specific position on a canvas:</para>
/// <code>
/// await page.Locator("canvas").ClickAsync(new() {<br/>
/// Button = MouseButton.Right,<br/>
/// Modifiers = new[] { KeyboardModifier.Shift },<br/>
/// Position = new Position { X = 0, Y = 0 }<br/>
/// });
/// </code>
/// </summary>
/// <param name="options">Call options</param>
Task ClickAsync(LocatorClickOptions? options = default);
/// <summary>
/// <para>Returns the number of elements matching the locator.</para>
/// <para>
/// If you need to assert the number of elements on the page, prefer <see cref="ILocatorAssertions.ToHaveCountAsync"/>
/// to avoid flakiness. See <a href="https://playwright.dev/dotnet/docs/test-assertions">assertions
/// guide</a> for more details.
/// </para>
/// <para>**Usage**</para>
/// <code>int count = await page.GetByRole(AriaRole.Listitem).CountAsync();</code>
/// </summary>
/// <remarks>
/// <para>
/// If you need to assert the number of elements on the page, prefer <see cref="ILocatorAssertions.ToHaveCountAsync"/>
/// to avoid flakiness. See <a href="https://playwright.dev/dotnet/docs/test-assertions">assertions
/// guide</a> for more details.
/// </para>
/// </remarks>
Task<int> CountAsync();
/// <summary>
/// <para>Double-click an element.</para>
/// <para>**Details**</para>
/// <para>This method double clicks the element by performing the following steps:</para>
/// <list type="ordinal">
/// <item><description>
/// Wait for <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
/// checks on the element, unless <see cref="ILocator.DblClickAsync"/> option is set.
/// </description></item>
/// <item><description>Scroll the element into view if needed.</description></item>
/// <item><description>
/// Use <see cref="IPage.Mouse"/> to double click in the center of the element, or the
/// specified <see cref="ILocator.DblClickAsync"/>.
/// </description></item>
/// </list>
/// <para>
/// If the element is detached from the DOM at any moment during the action, this method
/// throws.
/// </para>
/// <para>
/// When all steps combined have not finished during the specified <see cref="ILocator.DblClickAsync"/>,
/// this method throws a <see cref="TimeoutException"/>. Passing zero timeout disables
/// this.
/// </para>
/// <para>
/// <c>element.dblclick()</c> dispatches two <c>click</c> events and a single <c>dblclick</c>
/// event.
/// </para>
/// </summary>
/// <remarks>
/// <para>
/// <c>element.dblclick()</c> dispatches two <c>click</c> events and a single <c>dblclick</c>
/// event.
/// </para>
/// </remarks>
/// <param name="options">Call options</param>
Task DblClickAsync(LocatorDblClickOptions? options = default);
/// <summary>
/// <para>Programmatically dispatch an event on the matching element.</para>
/// <para>**Usage**</para>
/// <code>await locator.DispatchEventAsync("click");</code>
/// <para>**Details**</para>
/// <para>
/// The snippet above dispatches the <c>click</c> event on the element. Regardless of
/// the visibility state of the element, <c>click</c> is dispatched. This is equivalent
/// to calling <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click">element.click()</a>.
/// </para>
/// <para>
/// Under the hood, it creates an instance of an event based on the given <see cref="ILocator.DispatchEventAsync"/>,
/// initializes it with <see cref="ILocator.DispatchEventAsync"/> properties and dispatches
/// it on the element. Events are <c>composed</c>, <c>cancelable</c> and bubble by default.
/// </para>
/// <para>
/// Since <see cref="ILocator.DispatchEventAsync"/> is event-specific, please refer
/// to the events documentation for the lists of initial properties:
/// </para>
/// <list type="bullet">
/// <item><description><a href="https://developer.mozilla.org/en-US/docs/Web/API/DeviceMotionEvent/DeviceMotionEvent">DeviceMotionEvent</a></description></item>
/// <item><description><a href="https://developer.mozilla.org/en-US/docs/Web/API/DeviceOrientationEvent/DeviceOrientationEvent">DeviceOrientationEvent</a></description></item>
/// <item><description><a href="https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent">DragEvent</a></description></item>
/// <item><description><a href="https://developer.mozilla.org/en-US/docs/Web/API/Event/Event">Event</a></description></item>
/// <item><description><a href="https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent">FocusEvent</a></description></item>
/// <item><description><a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent">KeyboardEvent</a></description></item>
/// <item><description><a href="https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent">MouseEvent</a></description></item>
/// <item><description><a href="https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/PointerEvent">PointerEvent</a></description></item>
/// <item><description><a href="https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/TouchEvent">TouchEvent</a></description></item>
/// <item><description><a href="https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/WheelEvent">WheelEvent</a></description></item>
/// </list>
/// <para>
/// You can also specify <see cref="IJSHandle"/> as the property value if you want live
/// objects to be passed into the event:
/// </para>
/// <code>
/// var dataTransfer = await page.EvaluateHandleAsync("() => new DataTransfer()");<br/>
/// await locator.DispatchEventAsync("dragstart", new Dictionary<string, object><br/>
/// {<br/>
/// { "dataTransfer", dataTransfer }<br/>
/// });
/// </code>
/// </summary>
/// <param name="type">DOM event type: <c>"click"</c>, <c>"dragstart"</c>, etc.</param>
/// <param name="eventInit">Optional event-specific initialization properties.</param>
/// <param name="options">Call options</param>
Task DispatchEventAsync(string type, object? eventInit = default, LocatorDispatchEventOptions? options = default);
/// <summary>
/// <para>Drag the source element towards the target element and drop it.</para>
/// <para>**Details**</para>
/// <para>
/// This method drags the locator to another target locator or target position. It will
/// first move to the source element, perform a <c>mousedown</c>, then move to the target
/// element or position and perform a <c>mouseup</c>.
/// </para>
/// <para>**Usage**</para>
/// <code>
/// var source = Page.Locator("#source");<br/>
/// var target = Page.Locator("#target");<br/>
/// <br/>
/// await source.DragToAsync(target);<br/>
/// // or specify exact positions relative to the top-left corners of the elements:<br/>
/// await source.DragToAsync(target, new()<br/>
/// {<br/>
/// SourcePosition = new() { X = 34, Y = 7 },<br/>
/// TargetPosition = new() { X = 10, Y = 20 },<br/>
/// });
/// </code>
/// </summary>
/// <param name="target">Locator of the element to drag to.</param>
/// <param name="options">Call options</param>
Task DragToAsync(ILocator target, LocatorDragToOptions? options = default);
/// <summary>
/// <para>
/// Always prefer using <see cref="ILocator"/>s and web assertions over <see cref="IElementHandle"/>s
/// because latter are inherently racy.
/// </para>
/// <para>
/// Resolves given locator to the first matching DOM element. If there are no matching
/// elements, waits for one. If multiple elements match the locator, throws.
/// </para>
/// </summary>
/// <param name="options">Call options</param>
Task<IElementHandle> ElementHandleAsync(LocatorElementHandleOptions? options = default);
/// <summary>
/// <para>
/// Always prefer using <see cref="ILocator"/>s and web assertions over <see cref="IElementHandle"/>s
/// because latter are inherently racy.
/// </para>
/// <para>
/// Resolves given locator to all matching DOM elements. If there are no matching elements,
/// returns an empty list.
/// </para>
/// </summary>
Task<IReadOnlyList<IElementHandle>> ElementHandlesAsync();
/// <summary>
/// <para>
/// Returns a <see cref="IFrameLocator"/> object pointing to the same <c>iframe</c>
/// as this locator.
/// </para>
/// <para>
/// Useful when you have a <see cref="ILocator"/> object obtained somewhere, and later
/// on would like to interact with the content inside the frame.
/// </para>
/// <para>For a reverse operation, use <see cref="IFrameLocator.Owner"/>.</para>
/// <para>**Usage**</para>
/// <code>
/// var locator = Page.Locator("iframe[name=\"embedded\"]");<br/>
/// // ...<br/>
/// var frameLocator = locator.ContentFrame;<br/>
/// await frameLocator.GetByRole(AriaRole.Button).ClickAsync();
/// </code>
/// </summary>
IFrameLocator ContentFrame { get; }
/// <summary>
/// <para>Execute JavaScript code in the page, taking the matching element as an argument.</para>
/// <para>**Details**</para>
/// <para>
/// Returns the return value of <see cref="ILocator.EvaluateAsync"/>, called with the
/// matching element as a first argument, and <see cref="ILocator.EvaluateAsync"/> as
/// a second argument.
/// </para>
/// <para>
/// If <see cref="ILocator.EvaluateAsync"/> returns a <see cref="Task"/>, this method
/// will wait for the promise to resolve and return its value.
/// </para>
/// <para>If <see cref="ILocator.EvaluateAsync"/> throws or rejects, this method throws.</para>
/// <para>**Usage**</para>
/// <code>
/// var tweets = page.Locator(".tweet .retweets");<br/>
/// Assert.AreEqual("10 retweets", await tweets.EvaluateAsync("node => node.innerText"));
/// </code>
/// </summary>
/// <param name="expression">
/// JavaScript expression to be evaluated in the browser context. If the expression
/// evaluates to a function, the function is automatically invoked.
/// </param>
/// <param name="arg">Optional argument to pass to <see cref="ILocator.EvaluateAsync"/>.</param>
/// <param name="options">Call options</param>
Task<T> EvaluateAsync<T>(string expression, object? arg = default, LocatorEvaluateOptions? options = default);
/// <summary>
/// <para>Execute JavaScript code in the page, taking all matching elements as an argument.</para>
/// <para>**Details**</para>
/// <para>
/// Returns the return value of <see cref="ILocator.EvaluateAllAsync"/>, called with
/// an array of all matching elements as a first argument, and <see cref="ILocator.EvaluateAllAsync"/>
/// as a second argument.
/// </para>
/// <para>
/// If <see cref="ILocator.EvaluateAllAsync"/> returns a <see cref="Task"/>, this method
/// will wait for the promise to resolve and return its value.
/// </para>
/// <para>If <see cref="ILocator.EvaluateAllAsync"/> throws or rejects, this method throws.</para>
/// <para>**Usage**</para>
/// <code>
/// var locator = page.Locator("div");<br/>
/// var moreThanTen = await locator.EvaluateAllAsync<bool>("(divs, min) => divs.length > min", 10);
/// </code>
/// </summary>
/// <param name="expression">
/// JavaScript expression to be evaluated in the browser context. If the expression
/// evaluates to a function, the function is automatically invoked.
/// </param>
/// <param name="arg">Optional argument to pass to <see cref="ILocator.EvaluateAllAsync"/>.</param>
Task<T> EvaluateAllAsync<T>(string expression, object? arg = default);
/// <summary>
/// <para>
/// Execute JavaScript code in the page, taking the matching element as an argument,
/// and return a <see cref="IJSHandle"/> with the result.
/// </para>
/// <para>**Details**</para>
/// <para>
/// Returns the return value of <see cref="ILocator.EvaluateHandleAsync"/> as a<see
/// cref="IJSHandle"/>, called with the matching element as a first argument, and <see
/// cref="ILocator.EvaluateHandleAsync"/> as a second argument.
/// </para>
/// <para>
/// The only difference between <see cref="ILocator.EvaluateAsync"/> and <see cref="ILocator.EvaluateHandleAsync"/>
/// is that <see cref="ILocator.EvaluateHandleAsync"/> returns <see cref="IJSHandle"/>.
/// </para>
/// <para>
/// If <see cref="ILocator.EvaluateHandleAsync"/> returns a <see cref="Task"/>, this
/// method will wait for the promise to resolve and return its value.
/// </para>
/// <para>If <see cref="ILocator.EvaluateHandleAsync"/> throws or rejects, this method throws.</para>
/// <para>See <see cref="IPage.EvaluateHandleAsync"/> for more details.</para>
/// </summary>
/// <param name="expression">
/// JavaScript expression to be evaluated in the browser context. If the expression
/// evaluates to a function, the function is automatically invoked.
/// </param>
/// <param name="arg">Optional argument to pass to <see cref="ILocator.EvaluateHandleAsync"/>.</param>
/// <param name="options">Call options</param>
Task<IJSHandle> EvaluateHandleAsync(string expression, object? arg = default, LocatorEvaluateHandleOptions? options = default);
/// <summary>
/// <para>Set a value to the input field.</para>
/// <para>**Usage**</para>
/// <code>await page.GetByRole(AriaRole.Textbox).FillAsync("example value");</code>
/// <para>**Details**</para>
/// <para>
/// This method waits for <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
/// checks, focuses the element, fills it and triggers an <c>input</c> event after filling.
/// Note that you can pass an empty string to clear the input field.
/// </para>
/// <para>
/// If the target element is not an <c><input></c>, <c><textarea></c> or
/// <c>[contenteditable]</c> element, this method throws an error. However, if the element
/// is inside the <c><label></c> element that has an associated <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>,
/// the control will be filled instead.
/// </para>
/// <para>To send fine-grained keyboard events, use <see cref="ILocator.PressSequentiallyAsync"/>.</para>
/// </summary>
/// <param name="value">
/// Value to set for the <c><input></c>, <c><textarea></c> or <c>[contenteditable]</c>
/// element.
/// </param>
/// <param name="options">Call options</param>
Task FillAsync(string value, LocatorFillOptions? options = default);
/// <summary>
/// <para>
/// This method narrows existing locator according to the options, for example filters
/// by text. It can be chained to filter multiple times.
/// </para>
/// <para>**Usage**</para>
/// <code>
/// var rowLocator = page.Locator("tr");<br/>
/// // ...<br/>
/// await rowLocator<br/>
/// .Filter(new() { HasText = "text in column 1" })<br/>
/// .Filter(new() {<br/>
/// Has = page.GetByRole(AriaRole.Button, new() { Name = "column 2 button" } )<br/>
/// })<br/>
/// .ScreenshotAsync();
/// </code>
/// </summary>
/// <param name="options">Call options</param>
ILocator Filter(LocatorFilterOptions? options = default);
/// <summary><para>Returns locator to the first matching element.</para></summary>
ILocator First { get; }
/// <summary>
/// <para>
/// Calls <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus">focus</a>
/// on the matching element.
/// </para>
/// </summary>
/// <param name="options">Call options</param>
Task FocusAsync(LocatorFocusOptions? options = default);
/// <summary>
/// <para>
/// When working with iframes, you can create a frame locator that will enter the iframe
/// and allow locating elements in that iframe:
/// </para>
/// <para>**Usage**</para>
/// <code>
/// var locator = page.FrameLocator("iframe").GetByText("Submit");<br/>
/// await locator.ClickAsync();
/// </code>
/// </summary>
/// <param name="selector">A selector to use when resolving DOM element.</param>
IFrameLocator FrameLocator(string selector);
/// <summary>
/// <para>Returns the matching element's attribute value.</para>
/// <para>
/// If you need to assert an element's attribute, prefer <see cref="ILocatorAssertions.ToHaveAttributeAsync"/>
/// to avoid flakiness. See <a href="https://playwright.dev/dotnet/docs/test-assertions">assertions
/// guide</a> for more details.
/// </para>
/// </summary>
/// <remarks>
/// <para>
/// If you need to assert an element's attribute, prefer <see cref="ILocatorAssertions.ToHaveAttributeAsync"/>
/// to avoid flakiness. See <a href="https://playwright.dev/dotnet/docs/test-assertions">assertions
/// guide</a> for more details.
/// </para>
/// </remarks>
/// <param name="name">Attribute name to get the value for.</param>
/// <param name="options">Call options</param>
Task<string?> GetAttributeAsync(string name, LocatorGetAttributeOptions? options = default);
/// <summary>
/// <para>Allows locating elements by their alt text.</para>
/// <para>**Usage**</para>
/// <para>For example, this method will find the image by alt text "Playwright logo":</para>
/// <code>await page.GetByAltText("Playwright logo").ClickAsync();</code>
/// </summary>
/// <param name="text">Text to locate the element for.</param>
/// <param name="options">Call options</param>
ILocator GetByAltText(string text, LocatorGetByAltTextOptions? options = default);
/// <summary>
/// <para>Allows locating elements by their alt text.</para>
/// <para>**Usage**</para>
/// <para>For example, this method will find the image by alt text "Playwright logo":</para>
/// <code>await page.GetByAltText("Playwright logo").ClickAsync();</code>
/// </summary>
/// <param name="text">Text to locate the element for.</param>
/// <param name="options">Call options</param>
ILocator GetByAltText(Regex text, LocatorGetByAltTextOptions? options = default);
/// <summary>
/// <para>
/// Allows locating input elements by the text of the associated <c><label></c>
/// or <c>aria-labelledby</c> element, or by the <c>aria-label</c> attribute.
/// </para>
/// <para>**Usage**</para>
/// <para>
/// For example, this method will find inputs by label "Username" and "Password" in
/// the following DOM:
/// </para>
/// <code>
/// await page.GetByLabel("Username").FillAsync("john");<br/>
/// await page.GetByLabel("Password").FillAsync("secret");
/// </code>
/// </summary>
/// <param name="text">Text to locate the element for.</param>
/// <param name="options">Call options</param>
ILocator GetByLabel(string text, LocatorGetByLabelOptions? options = default);
/// <summary>
/// <para>
/// Allows locating input elements by the text of the associated <c><label></c>
/// or <c>aria-labelledby</c> element, or by the <c>aria-label</c> attribute.
/// </para>
/// <para>**Usage**</para>
/// <para>
/// For example, this method will find inputs by label "Username" and "Password" in
/// the following DOM:
/// </para>
/// <code>
/// await page.GetByLabel("Username").FillAsync("john");<br/>
/// await page.GetByLabel("Password").FillAsync("secret");
/// </code>
/// </summary>
/// <param name="text">Text to locate the element for.</param>
/// <param name="options">Call options</param>
ILocator GetByLabel(Regex text, LocatorGetByLabelOptions? options = default);
/// <summary>
/// <para>Allows locating input elements by the placeholder text.</para>
/// <para>**Usage**</para>
/// <para>For example, consider the following DOM structure.</para>
/// <para>You can fill the input after locating it by the placeholder text:</para>
/// <code>
/// await page<br/>
/// .GetByPlaceholder("[email protected]")<br/>
/// .FillAsync("[email protected]");
/// </code>
/// </summary>
/// <param name="text">Text to locate the element for.</param>
/// <param name="options">Call options</param>
ILocator GetByPlaceholder(string text, LocatorGetByPlaceholderOptions? options = default);
/// <summary>
/// <para>Allows locating input elements by the placeholder text.</para>
/// <para>**Usage**</para>
/// <para>For example, consider the following DOM structure.</para>
/// <para>You can fill the input after locating it by the placeholder text:</para>
/// <code>
/// await page<br/>
/// .GetByPlaceholder("[email protected]")<br/>
/// .FillAsync("[email protected]");
/// </code>
/// </summary>
/// <param name="text">Text to locate the element for.</param>
/// <param name="options">Call options</param>
ILocator GetByPlaceholder(Regex text, LocatorGetByPlaceholderOptions? options = default);
/// <summary>
/// <para>
/// Allows locating elements by their <a href="https://www.w3.org/TR/wai-aria-1.2/#roles">ARIA
/// role</a>, <a href="https://www.w3.org/TR/wai-aria-1.2/#aria-attributes">ARIA attributes</a>
/// and <a href="https://w3c.github.io/accname/#dfn-accessible-name">accessible name</a>.
/// </para>
/// <para>**Usage**</para>
/// <para>Consider the following DOM structure.</para>
/// <para>You can locate each element by it's implicit role:</para>
/// <code>
/// await Expect(Page<br/>
/// .GetByRole(AriaRole.Heading, new() { Name = "Sign up" }))<br/>
/// .ToBeVisibleAsync();<br/>
/// <br/>
/// await page<br/>
/// .GetByRole(AriaRole.Checkbox, new() { Name = "Subscribe" })<br/>
/// .CheckAsync();<br/>
/// <br/>
/// await page<br/>
/// .GetByRole(AriaRole.Button, new() {<br/>
/// NameRegex = new Regex("submit", RegexOptions.IgnoreCase)<br/>
/// })<br/>
/// .ClickAsync();
/// </code>
/// <para>**Details**</para>
/// <para>
/// Role selector **does not replace** accessibility audits and conformance tests, but
/// rather gives early feedback about the ARIA guidelines.
/// </para>
/// <para>
/// Many html elements have an implicitly <a href="https://w3c.github.io/html-aam/#html-element-role-mappings">defined
/// role</a> that is recognized by the role selector. You can find all the <a href="https://www.w3.org/TR/wai-aria-1.2/#role_definitions">supported
/// roles here</a>. ARIA guidelines **do not recommend** duplicating implicit roles
/// and attributes by setting <c>role</c> and/or <c>aria-*</c> attributes to default
/// values.
/// </para>
/// </summary>
/// <param name="role">Required aria role.</param>
/// <param name="options">Call options</param>
ILocator GetByRole(AriaRole role, LocatorGetByRoleOptions? options = default);
/// <summary>
/// <para>Locate element by the test id.</para>
/// <para>**Usage**</para>
/// <para>Consider the following DOM structure.</para>
/// <para>You can locate the element by it's test id:</para>
/// <code>await page.GetByTestId("directions").ClickAsync();</code>
/// <para>**Details**</para>
/// <para>
/// By default, the <c>data-testid</c> attribute is used as a test id. Use <see cref="ISelectors.SetTestIdAttribute"/>
/// to configure a different test id attribute if necessary.
/// </para>
/// </summary>
/// <param name="testId">Id to locate the element by.</param>
ILocator GetByTestId(string testId);
/// <summary>
/// <para>Locate element by the test id.</para>
/// <para>**Usage**</para>
/// <para>Consider the following DOM structure.</para>
/// <para>You can locate the element by it's test id:</para>
/// <code>await page.GetByTestId("directions").ClickAsync();</code>
/// <para>**Details**</para>
/// <para>
/// By default, the <c>data-testid</c> attribute is used as a test id. Use <see cref="ISelectors.SetTestIdAttribute"/>
/// to configure a different test id attribute if necessary.
/// </para>
/// </summary>
/// <param name="testId">Id to locate the element by.</param>
ILocator GetByTestId(Regex testId);
/// <summary>
/// <para>Allows locating elements that contain given text.</para>
/// <para>
/// See also <see cref="ILocator.Filter"/> that allows to match by another criteria,
/// like an accessible role, and then filter by the text content.
/// </para>
/// <para>**Usage**</para>
/// <para>Consider the following DOM structure:</para>
/// <para>You can locate by text substring, exact string, or a regular expression:</para>
/// <code>
/// // Matches <span><br/>
/// page.GetByText("world");<br/>
/// <br/>
/// // Matches first <div><br/>
/// page.GetByText("Hello world");<br/>
/// <br/>
/// // Matches second <div><br/>
/// page.GetByText("Hello", new() { Exact = true });<br/>
/// <br/>
/// // Matches both <div>s<br/>
/// page.GetByText(new Regex("Hello"));<br/>
/// <br/>
/// // Matches second <div><br/>
/// page.GetByText(new Regex("^hello$", RegexOptions.IgnoreCase));
/// </code>
/// <para>**Details**</para>
/// <para>
/// Matching by text always normalizes whitespace, even with exact match. For example,
/// it turns multiple spaces into one, turns line breaks into spaces and ignores leading
/// and trailing whitespace.
/// </para>
/// <para>
/// Input elements of the type <c>button</c> and <c>submit</c> are matched by their
/// <c>value</c> instead of the text content. For example, locating by text <c>"Log
/// in"</c> matches <c><input type=button value="Log in"></c>.
/// </para>
/// </summary>
/// <param name="text">Text to locate the element for.</param>
/// <param name="options">Call options</param>
ILocator GetByText(string text, LocatorGetByTextOptions? options = default);
/// <summary>
/// <para>Allows locating elements that contain given text.</para>
/// <para>
/// See also <see cref="ILocator.Filter"/> that allows to match by another criteria,
/// like an accessible role, and then filter by the text content.
/// </para>
/// <para>**Usage**</para>
/// <para>Consider the following DOM structure:</para>
/// <para>You can locate by text substring, exact string, or a regular expression:</para>
/// <code>
/// // Matches <span><br/>
/// page.GetByText("world");<br/>
/// <br/>
/// // Matches first <div><br/>
/// page.GetByText("Hello world");<br/>
/// <br/>
/// // Matches second <div><br/>
/// page.GetByText("Hello", new() { Exact = true });<br/>
/// <br/>
/// // Matches both <div>s<br/>
/// page.GetByText(new Regex("Hello"));<br/>
/// <br/>
/// // Matches second <div><br/>
/// page.GetByText(new Regex("^hello$", RegexOptions.IgnoreCase));
/// </code>
/// <para>**Details**</para>
/// <para>
/// Matching by text always normalizes whitespace, even with exact match. For example,
/// it turns multiple spaces into one, turns line breaks into spaces and ignores leading
/// and trailing whitespace.
/// </para>
/// <para>
/// Input elements of the type <c>button</c> and <c>submit</c> are matched by their
/// <c>value</c> instead of the text content. For example, locating by text <c>"Log
/// in"</c> matches <c><input type=button value="Log in"></c>.
/// </para>
/// </summary>
/// <param name="text">Text to locate the element for.</param>
/// <param name="options">Call options</param>
ILocator GetByText(Regex text, LocatorGetByTextOptions? options = default);
/// <summary>
/// <para>Allows locating elements by their title attribute.</para>
/// <para>**Usage**</para>
/// <para>Consider the following DOM structure.</para>
/// <para>You can check the issues count after locating it by the title text:</para>
/// <code>await Expect(Page.GetByTitle("Issues count")).toHaveText("25 issues");</code>
/// </summary>
/// <param name="text">Text to locate the element for.</param>
/// <param name="options">Call options</param>
ILocator GetByTitle(string text, LocatorGetByTitleOptions? options = default);
/// <summary>
/// <para>Allows locating elements by their title attribute.</para>
/// <para>**Usage**</para>
/// <para>Consider the following DOM structure.</para>
/// <para>You can check the issues count after locating it by the title text:</para>
/// <code>await Expect(Page.GetByTitle("Issues count")).toHaveText("25 issues");</code>
/// </summary>
/// <param name="text">Text to locate the element for.</param>
/// <param name="options">Call options</param>
ILocator GetByTitle(Regex text, LocatorGetByTitleOptions? options = default);
/// <summary>
/// <para>
/// Highlight the corresponding element(s) on the screen. Useful for debugging, don't
/// commit the code that uses <see cref="ILocator.HighlightAsync"/>.
/// </para>
/// </summary>
Task HighlightAsync();
/// <summary>
/// <para>Hover over the matching element.</para>
/// <para>**Usage**</para>
/// <code>await page.GetByRole(AriaRole.Link).HoverAsync();</code>
/// <para>**Details**</para>
/// <para>This method hovers over the element by performing the following steps:</para>
/// <list type="ordinal">
/// <item><description>
/// Wait for <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
/// checks on the element, unless <see cref="ILocator.HoverAsync"/> option is set.
/// </description></item>
/// <item><description>Scroll the element into view if needed.</description></item>
/// <item><description>
/// Use <see cref="IPage.Mouse"/> to hover over the center of the element, or the specified
/// <see cref="ILocator.HoverAsync"/>.
/// </description></item>
/// </list>
/// <para>
/// If the element is detached from the DOM at any moment during the action, this method
/// throws.
/// </para>
/// <para>
/// When all steps combined have not finished during the specified <see cref="ILocator.HoverAsync"/>,
/// this method throws a <see cref="TimeoutException"/>. Passing zero timeout disables
/// this.
/// </para>
/// </summary>
/// <param name="options">Call options</param>
Task HoverAsync(LocatorHoverOptions? options = default);
/// <summary><para>Returns the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML"><c>element.innerHTML</c></a>.</para></summary>
/// <param name="options">Call options</param>
Task<string> InnerHTMLAsync(LocatorInnerHTMLOptions? options = default);
/// <summary>
/// <para>Returns the <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText"><c>element.innerText</c></a>.</para>
/// <para>
/// If you need to assert text on the page, prefer <see cref="ILocatorAssertions.ToHaveTextAsync"/>
/// with <see cref="ILocatorAssertions.ToHaveTextAsync"/> option to avoid flakiness.
/// See <a href="https://playwright.dev/dotnet/docs/test-assertions">assertions guide</a>
/// for more details.
/// </para>
/// </summary>
/// <remarks>
/// <para>
/// If you need to assert text on the page, prefer <see cref="ILocatorAssertions.ToHaveTextAsync"/>
/// with <see cref="ILocatorAssertions.ToHaveTextAsync"/> option to avoid flakiness.
/// See <a href="https://playwright.dev/dotnet/docs/test-assertions">assertions guide</a>
/// for more details.
/// </para>
/// </remarks>
/// <param name="options">Call options</param>
Task<string> InnerTextAsync(LocatorInnerTextOptions? options = default);
/// <summary>
/// <para>
/// Returns the value for the matching <c><input></c> or <c><textarea></c>
/// or <c><select></c> element.
/// </para>
/// <para>
/// If you need to assert input value, prefer <see cref="ILocatorAssertions.ToHaveValueAsync"/>
/// to avoid flakiness. See <a href="https://playwright.dev/dotnet/docs/test-assertions">assertions
/// guide</a> for more details.
/// </para>
/// <para>**Usage**</para>
/// <code>String value = await page.GetByRole(AriaRole.Textbox).InputValueAsync();</code>
/// <para>**Details**</para>
/// <para>
/// Throws elements that are not an input, textarea or a select. However, if the element
/// is inside the <c><label></c> element that has an associated <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>,
/// returns the value of the control.
/// </para>
/// </summary>
/// <remarks>
/// <para>
/// If you need to assert input value, prefer <see cref="ILocatorAssertions.ToHaveValueAsync"/>
/// to avoid flakiness. See <a href="https://playwright.dev/dotnet/docs/test-assertions">assertions
/// guide</a> for more details.
/// </para>
/// </remarks>
/// <param name="options">Call options</param>
Task<string> InputValueAsync(LocatorInputValueOptions? options = default);
/// <summary>
/// <para>
/// Returns whether the element is checked. Throws if the element is not a checkbox
/// or radio input.
/// </para>
/// <para>
/// If you need to assert that checkbox is checked, prefer <see cref="ILocatorAssertions.ToBeCheckedAsync"/>
/// to avoid flakiness. See <a href="https://playwright.dev/dotnet/docs/test-assertions">assertions
/// guide</a> for more details.