playwright-ruby-client 0.5.10 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,6 +23,10 @@ module Playwright
23
23
  # # ...
24
24
  # ```
25
25
  #
26
+ # ```csharp
27
+ # var windowHandle = await page.EvaluateHandleAsync("() => window");
28
+ # ```
29
+ #
26
30
  # JSHandle prevents the referenced JavaScript object being garbage collected unless the handle is exposed with
27
31
  # [`method: JSHandle.dispose`]. JSHandles are auto-disposed when their origin frame gets navigated or the parent context
28
32
  # gets destroyed.
@@ -69,6 +73,11 @@ module Playwright
69
73
  # tweet_handle = page.query_selector(".tweet .retweets")
70
74
  # assert tweet_handle.evaluate("node => node.innerText") == "10 retweets"
71
75
  # ```
76
+ #
77
+ # ```csharp
78
+ # var tweetHandle = await page.QuerySelectorAsync(".tweet .retweets");
79
+ # Assert.Equals("10 retweets", await tweetHandle.EvaluateAsync("node => node.innerText"));
80
+ # ```
72
81
  def evaluate(expression, arg: nil)
73
82
  wrap_impl(@impl.evaluate(unwrap_impl(expression), arg: unwrap_impl(arg)))
74
83
  end
@@ -122,6 +131,14 @@ module Playwright
122
131
  # document_handle = properties.get("document")
123
132
  # handle.dispose()
124
133
  # ```
134
+ #
135
+ # ```csharp
136
+ # var handle = await page.EvaluateHandleAsync("() => ({window, document}");
137
+ # var properties = await handle.GetPropertiesAsync();
138
+ # var windowHandle = properties["window"];
139
+ # var documentHandle = properties["document"];
140
+ # await handle.DisposeAsync();
141
+ # ```
125
142
  def get_properties
126
143
  wrap_impl(@impl.get_properties)
127
144
  end
@@ -54,6 +54,20 @@ module Playwright
54
54
  # # result text will end up saying "Hello!"
55
55
  # ```
56
56
  #
57
+ # ```csharp
58
+ # await page.Keyboard.TypeAsync("Hello World!");
59
+ # await page.Keyboard.PressAsync("ArrowLeft");
60
+ #
61
+ # await page.Keyboard.DownAsync("Shift");
62
+ # for (int i = 0; i < " World".Length; i++)
63
+ # await page.Keyboard.PressAsync("ArrowLeft");
64
+ #
65
+ # await page.Keyboard.UpAsync("Shift");
66
+ #
67
+ # await page.Keyboard.PressAsync("Backspace");
68
+ # // Result text will end up saying "Hello!"
69
+ # ```
70
+ #
57
71
  # An example of pressing uppercase `A`
58
72
  #
59
73
  #
@@ -81,6 +95,12 @@ module Playwright
81
95
  # page.keyboard.press("Shift+A")
82
96
  # ```
83
97
  #
98
+ # ```csharp
99
+ # await page.Keyboard.PressAsync("Shift+KeyA");
100
+ # // or
101
+ # await page.Keyboard.PressAsync("Shift+A");
102
+ # ```
103
+ #
84
104
  # An example to trigger select-all with the keyboard
85
105
  #
86
106
  #
@@ -111,6 +131,13 @@ module Playwright
111
131
  # # on mac_os
112
132
  # page.keyboard.press("Meta+A")
113
133
  # ```
134
+ #
135
+ # ```csharp
136
+ # // on Windows and Linux
137
+ # await page.Keyboard.PressAsync("Control+A");
138
+ # // on macOS
139
+ # await page.Keyboard.PressAsync("Meta+A");
140
+ # ```
114
141
  class Keyboard < PlaywrightApi
115
142
 
116
143
  # Dispatches a `keydown` event.
@@ -160,6 +187,10 @@ module Playwright
160
187
  # page.keyboard.insert_text("嗨")
161
188
  # ```
162
189
  #
190
+ # ```csharp
191
+ # await page.Keyboard.PressAsync("嗨");
192
+ # ```
193
+ #
163
194
  # > NOTE: Modifier keys DO NOT effect `keyboard.insertText`. Holding down `Shift` will not type the text in upper case.
164
195
  def insert_text(text)
165
196
  wrap_impl(@impl.insert_text(unwrap_impl(text)))
@@ -231,6 +262,17 @@ module Playwright
231
262
  # browser.close()
232
263
  # ```
233
264
  #
265
+ # ```csharp
266
+ # await page.GotoAsync("https://keycode.info");
267
+ # await page.Keyboard.PressAsync("A");
268
+ # await page.ScreenshotAsync("A.png");
269
+ # await page.Keyboard.PressAsync("ArrowLeft");
270
+ # await page.ScreenshotAsync("ArrowLeft.png");
271
+ # await page.Keyboard.PressAsync("Shift+O");
272
+ # await page.ScreenshotAsync("O.png");
273
+ # await browser.CloseAsync();
274
+ # ```
275
+ #
234
276
  # Shortcut for [`method: Keyboard.down`] and [`method: Keyboard.up`].
235
277
  def press(key, delay: nil)
236
278
  wrap_impl(@impl.press(unwrap_impl(key), delay: unwrap_impl(delay)))
@@ -263,7 +305,13 @@ module Playwright
263
305
  # page.keyboard.type("World", delay=100) # types slower, like a user
264
306
  # ```
265
307
  #
308
+ # ```csharp
309
+ # await page.Keyboard.TypeAsync("Hello"); // types instantly
310
+ # await page.Keyboard.TypeAsync("World"); // types slower, like a user
311
+ # ```
312
+ #
266
313
  # > NOTE: Modifier keys DO NOT effect `keyboard.type`. Holding down `Shift` will not type the text in upper case.
314
+ # > NOTE: For characters that are not on a US keyboard, only an `input` event will be sent.
267
315
  def type(text, delay: nil)
268
316
  wrap_impl(@impl.type(unwrap_impl(text), delay: unwrap_impl(delay)))
269
317
  end
@@ -74,6 +74,23 @@ module Playwright
74
74
  # run(playwright)
75
75
  # ```
76
76
  #
77
+ # ```csharp
78
+ # using Microsoft.Playwright;
79
+ # using System.Threading.Tasks;
80
+ #
81
+ # class PageExamples
82
+ # {
83
+ # public static async Task Run()
84
+ # {
85
+ # using var playwright = await Playwright.CreateAsync();
86
+ # await using var browser = await playwright.Webkit.LaunchAsync();
87
+ # var page = await browser.NewPageAsync();
88
+ # await page.GotoAsync("https://www.theverge.com");
89
+ # await page.ScreenshotAsync("theverge.png");
90
+ # }
91
+ # }
92
+ # ```
93
+ #
77
94
  # The Page class emits various events (described below) which can be handled using any of Node's native
78
95
  # [`EventEmitter`](https://nodejs.org/api/events.html#events_class_eventemitter) methods, such as `on`, `once` or
79
96
  # `removeListener`.
@@ -93,6 +110,10 @@ module Playwright
93
110
  # page.once("load", lambda: print("page loaded!"))
94
111
  # ```
95
112
  #
113
+ # ```csharp
114
+ # page.Load += (_, _) => Console.WriteLine("Page loaded!");
115
+ # ```
116
+ #
96
117
  # To unsubscribe from events use the `removeListener` method:
97
118
  #
98
119
  #
@@ -121,6 +142,16 @@ module Playwright
121
142
  # # sometime later...
122
143
  # page.remove_listener("request", log_request)
123
144
  # ```
145
+ #
146
+ # ```csharp
147
+ # void PageLoadHandler(object _, IPage p) {
148
+ # Console.WriteLine("Page loaded!");
149
+ # };
150
+ #
151
+ # page.Load += PageLoadHandler;
152
+ # // Do some work...
153
+ # page.Load -= PageLoadHandler;
154
+ # ```
124
155
  class Page < PlaywrightApi
125
156
 
126
157
  def accessibility # property
@@ -176,6 +207,10 @@ module Playwright
176
207
  # page.add_init_script(path="./preload.js")
177
208
  # ```
178
209
  #
210
+ # ```csharp
211
+ # await page.AddInitScriptAsync(scriptPath: "./preload.js");
212
+ # ```
213
+ #
179
214
  # > NOTE: The order of evaluation of multiple scripts installed via [`method: BrowserContext.addInitScript`] and
180
215
  # [`method: Page.addInitScript`] is not defined.
181
216
  def add_init_script(path: nil, script: nil)
@@ -223,8 +258,9 @@ module Playwright
223
258
  force: nil,
224
259
  noWaitAfter: nil,
225
260
  position: nil,
226
- timeout: nil)
227
- wrap_impl(@impl.check(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
261
+ timeout: nil,
262
+ trial: nil)
263
+ wrap_impl(@impl.check(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
228
264
  end
229
265
 
230
266
  # This method clicks an element matching `selector` by performing the following steps:
@@ -248,8 +284,9 @@ module Playwright
248
284
  modifiers: nil,
249
285
  noWaitAfter: nil,
250
286
  position: nil,
251
- timeout: nil)
252
- wrap_impl(@impl.click(unwrap_impl(selector), button: unwrap_impl(button), clickCount: unwrap_impl(clickCount), delay: unwrap_impl(delay), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
287
+ timeout: nil,
288
+ trial: nil)
289
+ wrap_impl(@impl.click(unwrap_impl(selector), button: unwrap_impl(button), clickCount: unwrap_impl(clickCount), delay: unwrap_impl(delay), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
253
290
  end
254
291
 
255
292
  # If `runBeforeUnload` is `false`, does not run any unload handlers and waits for the page to be closed. If
@@ -296,8 +333,9 @@ module Playwright
296
333
  modifiers: nil,
297
334
  noWaitAfter: nil,
298
335
  position: nil,
299
- timeout: nil)
300
- wrap_impl(@impl.dblclick(unwrap_impl(selector), button: unwrap_impl(button), delay: unwrap_impl(delay), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
336
+ timeout: nil,
337
+ trial: nil)
338
+ wrap_impl(@impl.dblclick(unwrap_impl(selector), button: unwrap_impl(button), delay: unwrap_impl(delay), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
301
339
  end
302
340
 
303
341
  # The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element,
@@ -321,6 +359,10 @@ module Playwright
321
359
  # page.dispatch_event("button#submit", "click")
322
360
  # ```
323
361
  #
362
+ # ```csharp
363
+ # await page.DispatchEventAsync("button#submit", "click");
364
+ # ```
365
+ #
324
366
  # Under the hood, it creates an instance of an event based on the given `type`, initializes it with `eventInit` properties
325
367
  # and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default.
326
368
  #
@@ -361,10 +403,18 @@ module Playwright
361
403
  # data_transfer = page.evaluate_handle("new DataTransfer()")
362
404
  # page.dispatch_event("#source", "dragstart", { "dataTransfer": data_transfer })
363
405
  # ```
406
+ #
407
+ # ```csharp
408
+ # var dataTransfer = await page.EvaluateHandleAsync("() => new DataTransfer()");
409
+ # await page.DispatchEventAsync("#source", "dragstart", new { dataTransfer });
410
+ # ```
364
411
  def dispatch_event(selector, type, eventInit: nil, timeout: nil)
365
412
  wrap_impl(@impl.dispatch_event(unwrap_impl(selector), unwrap_impl(type), eventInit: unwrap_impl(eventInit), timeout: unwrap_impl(timeout)))
366
413
  end
367
414
 
415
+ # This method changes the `CSS media type` through the `media` argument, and/or the `'prefers-colors-scheme'` media
416
+ # feature, using the `colorScheme` argument.
417
+ #
368
418
  #
369
419
  # ```js
370
420
  # await page.evaluate(() => matchMedia('screen').matches);
@@ -442,6 +492,25 @@ module Playwright
442
492
  # # → False
443
493
  # ```
444
494
  #
495
+ # ```csharp
496
+ # await page.EvaluateAsync("() => matchMedia('screen').matches");
497
+ # // → true
498
+ # await page.EvaluateAsync("() => matchMedia('print').matches");
499
+ # // → false
500
+ #
501
+ # await page.EmulateMediaAsync(Media.Print);
502
+ # await page.EvaluateAsync("() => matchMedia('screen').matches");
503
+ # // → false
504
+ # await page.EvaluateAsync("() => matchMedia('print').matches");
505
+ # // → true
506
+ #
507
+ # await page.EmulateMediaAsync(Media.Screen);
508
+ # await page.EvaluateAsync("() => matchMedia('screen').matches");
509
+ # // → true
510
+ # await page.EvaluateAsync("() => matchMedia('print').matches");
511
+ # // → false
512
+ # ```
513
+ #
445
514
  #
446
515
  # ```js
447
516
  # await page.emulateMedia({ colorScheme: 'dark' });
@@ -481,6 +550,16 @@ module Playwright
481
550
  # # → False
482
551
  # page.evaluate("matchMedia('(prefers-color-scheme: no-preference)').matches")
483
552
  # ```
553
+ #
554
+ # ```csharp
555
+ # await page.EmulateMediaAsync(colorScheme: ColorScheme.Dark);
556
+ # await page.EvaluateAsync("matchMedia('(prefers-color-scheme: dark)').matches");
557
+ # // → true
558
+ # await page.EvaluateAsync("matchMedia('(prefers-color-scheme: light)').matches");
559
+ # // → false
560
+ # await page.EvaluateAsync("matchMedia('(prefers-color-scheme: no-preference)').matches");
561
+ # // → false
562
+ # ```
484
563
  def emulate_media(colorScheme: nil, media: nil)
485
564
  wrap_impl(@impl.emulate_media(colorScheme: unwrap_impl(colorScheme), media: unwrap_impl(media)))
486
565
  end
@@ -518,6 +597,12 @@ module Playwright
518
597
  # html = page.eval_on_selector(".main-container", "(e, suffix) => e.outer_html + suffix", "hello")
519
598
  # ```
520
599
  #
600
+ # ```csharp
601
+ # var searchValue = await page.EvalOnSelectorAsync<string>("#search", "el => el.value");
602
+ # var preloadHref = await page.EvalOnSelectorAsync<string>("link[rel=preload]", "el => el.href");
603
+ # var html = await page.EvalOnSelectorAsync(".main-container", "(e, suffix) => e.outerHTML + suffix", "hello");
604
+ # ```
605
+ #
521
606
  # Shortcut for main frame's [`method: Frame.evalOnSelector`].
522
607
  def eval_on_selector(selector, expression, arg: nil)
523
608
  wrap_impl(@impl.eval_on_selector(unwrap_impl(selector), unwrap_impl(expression), arg: unwrap_impl(arg)))
@@ -547,6 +632,10 @@ module Playwright
547
632
  # ```python sync
548
633
  # div_counts = page.eval_on_selector_all("div", "(divs, min) => divs.length >= min", 10)
549
634
  # ```
635
+ #
636
+ # ```csharp
637
+ # var divsCount = await page.EvalOnSelectorAllAsync<bool>("div", "(divs, min) => divs.length >= min", 10);
638
+ # ```
550
639
  def eval_on_selector_all(selector, expression, arg: nil)
551
640
  wrap_impl(@impl.eval_on_selector_all(unwrap_impl(selector), unwrap_impl(expression), arg: unwrap_impl(arg)))
552
641
  end
@@ -587,6 +676,11 @@ module Playwright
587
676
  # print(result) # prints "56"
588
677
  # ```
589
678
  #
679
+ # ```csharp
680
+ # var result = await page.EvaluateAsync<int>("([x, y]) => Promise.resolve(x * y)", new[] { 7, 8 });
681
+ # Console.WriteLine(result);
682
+ # ```
683
+ #
590
684
  # A string can also be passed in instead of a function:
591
685
  #
592
686
  #
@@ -612,6 +706,10 @@ module Playwright
612
706
  # print(page.evaluate(f"1 + {x}")) # prints "11"
613
707
  # ```
614
708
  #
709
+ # ```csharp
710
+ # Console.WriteLine(await page.EvaluateAsync<int>("1 + 2")); // prints "3"
711
+ # ```
712
+ #
615
713
  # `ElementHandle` instances can be passed as an argument to the [`method: Page.evaluate`]:
616
714
  #
617
715
  #
@@ -639,6 +737,12 @@ module Playwright
639
737
  # body_handle.dispose()
640
738
  # ```
641
739
  #
740
+ # ```csharp
741
+ # var bodyHandle = await page.QuerySelectorAsync("body");
742
+ # var html = await page.EvaluateAsync<string>("([body, suffix]) => body.innerHTML + suffix", new object [] { bodyHandle, "hello" });
743
+ # await bodyHandle.DisposeAsync();
744
+ # ```
745
+ #
642
746
  # Shortcut for main frame's [`method: Frame.evaluate`].
643
747
  def evaluate(expression, arg: nil)
644
748
  wrap_impl(@impl.evaluate(unwrap_impl(expression), arg: unwrap_impl(arg)))
@@ -673,6 +777,11 @@ module Playwright
673
777
  # a_window_handle # handle for the window object.
674
778
  # ```
675
779
  #
780
+ # ```csharp
781
+ # // Handle for the window object.
782
+ # var aWindowHandle = await page.EvaluateHandleAsync("() => Promise.resolve(window)");
783
+ # ```
784
+ #
676
785
  # A string can also be passed in instead of a function:
677
786
  #
678
787
  #
@@ -692,6 +801,10 @@ module Playwright
692
801
  # a_handle = page.evaluate_handle("document") # handle for the "document"
693
802
  # ```
694
803
  #
804
+ # ```csharp
805
+ # var docHandle = await page.EvalueHandleAsync("document"); // Handle for the `document`
806
+ # ```
807
+ #
695
808
  # `JSHandle` instances can be passed as an argument to the [`method: Page.evaluateHandle`]:
696
809
  #
697
810
  #
@@ -722,6 +835,13 @@ module Playwright
722
835
  # print(result_handle.json_value())
723
836
  # result_handle.dispose()
724
837
  # ```
838
+ #
839
+ # ```csharp
840
+ # var handle = await page.EvaluateHandleAsync("() => document.body");
841
+ # var resultHandle = await page.EvaluateHandleAsync("([body, suffix]) => body.innerHTML + suffix", new object[] { handle, "hello" });
842
+ # Console.WriteLine(await resultHandle.JsonValueAsync<string>());
843
+ # await resultHandle.DisposeAsync();
844
+ # ```
725
845
  def evaluate_handle(expression, arg: nil)
726
846
  wrap_impl(@impl.evaluate_handle(unwrap_impl(expression), arg: unwrap_impl(arg)))
727
847
  end
@@ -836,6 +956,32 @@ module Playwright
836
956
  # run(playwright)
837
957
  # ```
838
958
  #
959
+ # ```csharp
960
+ # using Microsoft.Playwright;
961
+ # using System.Threading.Tasks;
962
+ #
963
+ # class PageExamples
964
+ # {
965
+ # public static async Task Main()
966
+ # {
967
+ # using var playwright = await Playwright.CreateAsync();
968
+ # await using var browser = await playwright.Webkit.LaunchAsync(headless: false);
969
+ # var page = await browser.NewPageAsync();
970
+ #
971
+ # await page.ExposeBindingAsync("pageUrl", (source) => source.Page.Url);
972
+ # await page.SetContentAsync("<script>\n" +
973
+ # " async function onClick() {\n" +
974
+ # " document.querySelector('div').textContent = await window.pageURL();\n" +
975
+ # " }\n" +
976
+ # "</script>\n" +
977
+ # "<button onclick=\"onClick()\">Click me</button>\n" +
978
+ # "<div></div>");
979
+ #
980
+ # await page.ClickAsync("button");
981
+ # }
982
+ # }
983
+ # ```
984
+ #
839
985
  # An example of passing an element handle:
840
986
  #
841
987
  #
@@ -893,6 +1039,23 @@ module Playwright
893
1039
  # <div>Or click me</div>
894
1040
  # """)
895
1041
  # ```
1042
+ #
1043
+ # ```csharp
1044
+ # var result = new TaskCompletionSource<string>();
1045
+ # await page.ExposeBindingAsync("clicked", async (BindingSource _, IJSHandle t) =>
1046
+ # {
1047
+ # return result.TrySetResult(await t.AsElement.TextContentAsync());
1048
+ # });
1049
+ #
1050
+ # await page.SetContentAsync("<script>\n" +
1051
+ # " document.addEventListener('click', event => window.clicked(event.target));\n" +
1052
+ # "</script>\n" +
1053
+ # "<div>Click me</div>\n" +
1054
+ # "<div>Or click me</div>\n");
1055
+ #
1056
+ # await page.ClickAsync("div");
1057
+ # Console.WriteLine(await result.Task);
1058
+ # ```
896
1059
  def expose_binding(name, callback, handle: nil)
897
1060
  wrap_impl(@impl.expose_binding(unwrap_impl(name), unwrap_impl(callback), handle: unwrap_impl(handle)))
898
1061
  end
@@ -1030,19 +1193,58 @@ module Playwright
1030
1193
  # with sync_playwright() as playwright:
1031
1194
  # run(playwright)
1032
1195
  # ```
1196
+ #
1197
+ # ```csharp
1198
+ # using Microsoft.Playwright;
1199
+ # using System;
1200
+ # using System.Security.Cryptography;
1201
+ # using System.Threading.Tasks;
1202
+ #
1203
+ # class PageExamples
1204
+ # {
1205
+ # public static async Task Main()
1206
+ # {
1207
+ # using var playwright = await Playwright.CreateAsync();
1208
+ # await using var browser = await playwright.Webkit.LaunchAsync(headless: false);
1209
+ # var page = await browser.NewPageAsync();
1210
+ #
1211
+ # // NOTE: md5 is inherently insecure, and we strongly discourage using
1212
+ # // this in production in any shape or form
1213
+ # await page.ExposeFunctionAsync("sha1", (string input) =>
1214
+ # {
1215
+ # return Convert.ToBase64String(
1216
+ # MD5.Create().ComputeHash(System.Text.Encoding.UTF8.GetBytes(input)));
1217
+ # });
1218
+ #
1219
+ # await page.SetContentAsync("<script>\n" +
1220
+ # " async function onClick() {\n" +
1221
+ # " document.querySelector('div').textContent = await window.sha1('PLAYWRIGHT');\n" +
1222
+ # " }\n" +
1223
+ # "</script>\n" +
1224
+ # "<button onclick=\"onClick()\">Click me</button>\n" +
1225
+ # "<div></div>");
1226
+ #
1227
+ # await page.ClickAsync("button");
1228
+ # Console.WriteLine(await page.TextContentAsync("div"));
1229
+ # }
1230
+ # }
1231
+ # ```
1033
1232
  def expose_function(name, callback)
1034
1233
  wrap_impl(@impl.expose_function(unwrap_impl(name), unwrap_impl(callback)))
1035
1234
  end
1036
1235
 
1037
1236
  # This method waits for an element matching `selector`, waits for [actionability](./actionability.md) checks, focuses the
1038
- # element, fills it and triggers an `input` event after filling. If the element is inside the `<label>` element that has
1039
- # associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), that control will be
1040
- # filled instead. If the element to be filled is not an `<input>`, `<textarea>` or `[contenteditable]` element, this
1041
- # method throws an error. Note that you can pass an empty string to clear the input field.
1237
+ # element, fills it and triggers an `input` event after filling. Note that you can pass an empty string to clear the input
1238
+ # field.
1239
+ #
1240
+ # If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error.
1241
+ # However, if the element is inside the `<label>` element that has an associated
1242
+ # [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled
1243
+ # instead.
1042
1244
  #
1043
1245
  # To send fine-grained keyboard events, use [`method: Page.type`].
1044
1246
  #
1045
- # Shortcut for main frame's [`method: Frame.fill`]
1247
+ # Shortcut for main frame's [`method: Frame.fill`].
1046
1248
  def fill(selector, value, noWaitAfter: nil, timeout: nil)
1047
1249
  wrap_impl(@impl.fill(unwrap_impl(selector), unwrap_impl(value), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
1048
1250
  end
@@ -1070,6 +1272,10 @@ module Playwright
1070
1272
  # frame = page.frame(name="frame-name")
1071
1273
  # ```
1072
1274
  #
1275
+ # ```csharp
1276
+ # var frame = page.Frame("frame-name");
1277
+ # ```
1278
+ #
1073
1279
  #
1074
1280
  # ```js
1075
1281
  # const frame = page.frame({ url: /.*domain.*/ });
@@ -1082,6 +1288,10 @@ module Playwright
1082
1288
  # ```py
1083
1289
  # frame = page.frame(url=r".*domain.*")
1084
1290
  # ```
1291
+ #
1292
+ # ```csharp
1293
+ # var frame = page.FrameByUrl(".*domain.*");
1294
+ # ```
1085
1295
  def frame(name: nil, url: nil)
1086
1296
  wrap_impl(@impl.frame(name: unwrap_impl(name), url: unwrap_impl(url)))
1087
1297
  end
@@ -1153,8 +1363,9 @@ module Playwright
1153
1363
  force: nil,
1154
1364
  modifiers: nil,
1155
1365
  position: nil,
1156
- timeout: nil)
1157
- wrap_impl(@impl.hover(unwrap_impl(selector), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
1366
+ timeout: nil,
1367
+ trial: nil)
1368
+ wrap_impl(@impl.hover(unwrap_impl(selector), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
1158
1369
  end
1159
1370
 
1160
1371
  # Returns `element.innerHTML`.
@@ -1262,6 +1473,12 @@ module Playwright
1262
1473
  # page.pdf(path="page.pdf")
1263
1474
  # ```
1264
1475
  #
1476
+ # ```csharp
1477
+ # // Generates a PDF with 'screen' media type
1478
+ # await page.EmulateMediaAsync(Media.Screen);
1479
+ # await page.PdfAsync("page.pdf");
1480
+ # ```
1481
+ #
1265
1482
  # The `width`, `height`, and `margin` options accept values labeled with units. Unlabeled values are treated as pixels.
1266
1483
  #
1267
1484
  # A few examples:
@@ -1373,6 +1590,18 @@ module Playwright
1373
1590
  # page.screenshot(path="o.png")
1374
1591
  # browser.close()
1375
1592
  # ```
1593
+ #
1594
+ # ```csharp
1595
+ # await using var browser = await playwright.Webkit.LaunchAsync(headless: false);
1596
+ # var page = await browser.NewPageAsync();
1597
+ # await page.GotoAsync("https://keycode.info");
1598
+ # await page.PressAsync("body", "A");
1599
+ # await page.ScreenshotAsync("A.png");
1600
+ # await page.PressAsync("body", "ArrowLeft");
1601
+ # await page.ScreenshotAsync("ArrowLeft.png");
1602
+ # await page.PressAsync("body", "Shift+O");
1603
+ # await page.ScreenshotAsync("O.png");
1604
+ # ```
1376
1605
  def press(
1377
1606
  selector,
1378
1607
  key,
@@ -1383,7 +1612,7 @@ module Playwright
1383
1612
  end
1384
1613
 
1385
1614
  # The method finds an element matching the specified selector within the page. If no elements match the selector, the
1386
- # return value resolves to `null`.
1615
+ # return value resolves to `null`. To wait for an element on the page, use [`method: Page.waitForSelector`].
1387
1616
  #
1388
1617
  # Shortcut for main frame's [`method: Frame.querySelector`].
1389
1618
  def query_selector(selector)
@@ -1441,6 +1670,13 @@ module Playwright
1441
1670
  # browser.close()
1442
1671
  # ```
1443
1672
  #
1673
+ # ```csharp
1674
+ # await using var browser = await playwright.Webkit.LaunchAsync();
1675
+ # var page = await browser.NewPageAsync();
1676
+ # await page.RouteAsync("**/*.{png,jpg,jpeg}", async r => await r.AbortAsync());
1677
+ # await page.GotoAsync("https://www.microsoft.com");
1678
+ # ```
1679
+ #
1444
1680
  # or the same snippet using a regex pattern instead:
1445
1681
  #
1446
1682
  #
@@ -1472,6 +1708,63 @@ module Playwright
1472
1708
  # browser.close()
1473
1709
  # ```
1474
1710
  #
1711
+ # ```csharp
1712
+ # await using var browser = await playwright.Webkit.LaunchAsync();
1713
+ # var page = await browser.NewPageAsync();
1714
+ # await page.RouteAsync(new Regex("(\\.png$)|(\\.jpg$)"), async r => await r.AbortAsync());
1715
+ # await page.GotoAsync("https://www.microsoft.com");
1716
+ # ```
1717
+ #
1718
+ # It is possible to examine the request to decide the route action. For example, mocking all requests that contain some
1719
+ # post data, and leaving all other requests as is:
1720
+ #
1721
+ #
1722
+ # ```js
1723
+ # await page.route('/api/**', route => {
1724
+ # if (route.request().postData().includes('my-string'))
1725
+ # route.fulfill({ body: 'mocked-data' });
1726
+ # else
1727
+ # route.continue();
1728
+ # });
1729
+ # ```
1730
+ #
1731
+ # ```java
1732
+ # page.route("/api/**", route -> {
1733
+ # if (route.request().postData().contains("my-string"))
1734
+ # route.fulfill(new Route.FulfillOptions().setBody("mocked-data"));
1735
+ # else
1736
+ # route.resume();
1737
+ # });
1738
+ # ```
1739
+ #
1740
+ # ```python async
1741
+ # def handle_route(route):
1742
+ # if ("my-string" in route.request.post_data)
1743
+ # route.fulfill(body="mocked-data")
1744
+ # else
1745
+ # route.continue_()
1746
+ # await page.route("/api/**", handle_route)
1747
+ # ```
1748
+ #
1749
+ # ```python sync
1750
+ # def handle_route(route):
1751
+ # if ("my-string" in route.request.post_data)
1752
+ # route.fulfill(body="mocked-data")
1753
+ # else
1754
+ # route.continue_()
1755
+ # page.route("/api/**", handle_route)
1756
+ # ```
1757
+ #
1758
+ # ```csharp
1759
+ # await page.RouteAsync("/api/**", async r =>
1760
+ # {
1761
+ # if (r.Request.PostData.Contains("my-string"))
1762
+ # await r.FulfillAsync(body: "mocked-data");
1763
+ # else
1764
+ # await r.ContinueAsync();
1765
+ # });
1766
+ # ```
1767
+ #
1475
1768
  # Page routes take precedence over browser context routes (set up with [`method: BrowserContext.route`]) when request
1476
1769
  # matches both handlers.
1477
1770
  #
@@ -1494,12 +1787,16 @@ module Playwright
1494
1787
  wrap_impl(@impl.screenshot(clip: unwrap_impl(clip), fullPage: unwrap_impl(fullPage), omitBackground: unwrap_impl(omitBackground), path: unwrap_impl(path), quality: unwrap_impl(quality), timeout: unwrap_impl(timeout), type: unwrap_impl(type)))
1495
1788
  end
1496
1789
 
1497
- # Returns the array of option values that have been successfully selected.
1790
+ # This method waits for an element matching `selector`, waits for [actionability](./actionability.md) checks, waits until
1791
+ # all specified options are present in the `<select>` element and selects these options.
1792
+ #
1793
+ # If the target element is not a `<select>` element, this method throws an error. However, if the element is inside the
1794
+ # `<label>` element that has an associated
1795
+ # [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used instead.
1498
1796
  #
1499
- # Triggers a `change` and `input` event once all the provided options have been selected. If there's no `<select>` element
1500
- # matching `selector`, the method throws an error.
1797
+ # Returns the array of option values that have been successfully selected.
1501
1798
  #
1502
- # Will wait until all specified options are present in the `<select>` element.
1799
+ # Triggers a `change` and `input` event once all the provided options have been selected.
1503
1800
  #
1504
1801
  #
1505
1802
  # ```js
@@ -1541,7 +1838,16 @@ module Playwright
1541
1838
  # page.select_option("select#colors", value=["red", "green", "blue"])
1542
1839
  # ```
1543
1840
  #
1544
- # Shortcut for main frame's [`method: Frame.selectOption`]
1841
+ # ```csharp
1842
+ # // single selection matching the value
1843
+ # await page.SelectOptionAsync("select#colors", new[] { "blue" });
1844
+ # // single selection matching both the value and the label
1845
+ # await page.SelectOptionAsync("select#colors", new[] { new SelectOptionValue() { Label = "blue" } });
1846
+ # // multiple
1847
+ # await page.SelectOptionAsync("select#colors", new[] { "red", "green", "blue" });
1848
+ # ```
1849
+ #
1850
+ # Shortcut for main frame's [`method: Frame.selectOption`].
1545
1851
  def select_option(
1546
1852
  selector,
1547
1853
  element: nil,
@@ -1632,6 +1938,12 @@ module Playwright
1632
1938
  # page.set_viewport_size({"width": 640, "height": 480})
1633
1939
  # page.goto("https://example.com")
1634
1940
  # ```
1941
+ #
1942
+ # ```csharp
1943
+ # var page = await browser.NewPageAsync();
1944
+ # await page.SetViewportSizeAsync(640, 480);
1945
+ # await page.GotoAsync("https://www.microsoft.com");
1946
+ # ```
1635
1947
  def set_viewport_size(viewportSize)
1636
1948
  wrap_impl(@impl.set_viewport_size(unwrap_impl(viewportSize)))
1637
1949
  end
@@ -1657,8 +1969,9 @@ module Playwright
1657
1969
  modifiers: nil,
1658
1970
  noWaitAfter: nil,
1659
1971
  position: nil,
1660
- timeout: nil)
1661
- wrap_impl(@impl.tap_point(unwrap_impl(selector), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
1972
+ timeout: nil,
1973
+ trial: nil)
1974
+ wrap_impl(@impl.tap_point(unwrap_impl(selector), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
1662
1975
  end
1663
1976
 
1664
1977
  # Returns `element.textContent`.
@@ -1699,6 +2012,11 @@ module Playwright
1699
2012
  # page.type("#mytextarea", "world", delay=100) # types slower, like a user
1700
2013
  # ```
1701
2014
  #
2015
+ # ```csharp
2016
+ # await page.TypeAsync("#mytextarea", "hello"); // types instantly
2017
+ # await page.TypeAsync("#mytextarea", "world"); // types slower, like a user
2018
+ # ```
2019
+ #
1702
2020
  # Shortcut for main frame's [`method: Frame.type`].
1703
2021
  def type(
1704
2022
  selector,
@@ -1729,8 +2047,9 @@ module Playwright
1729
2047
  force: nil,
1730
2048
  noWaitAfter: nil,
1731
2049
  position: nil,
1732
- timeout: nil)
1733
- wrap_impl(@impl.uncheck(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
2050
+ timeout: nil,
2051
+ trial: nil)
2052
+ wrap_impl(@impl.uncheck(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
1734
2053
  end
1735
2054
 
1736
2055
  # Removes a route created with [`method: Page.route`]. When `handler` is not specified, removes all routes for the `url`.
@@ -1788,6 +2107,12 @@ module Playwright
1788
2107
  # page.click("button")
1789
2108
  # frame = event_info.value
1790
2109
  # ```
2110
+ #
2111
+ # ```csharp
2112
+ # var waitTask = page.WaitForEventAsync(PageEvent.FrameNavigated);
2113
+ # await page.ClickAsync("button");
2114
+ # var frame = await waitTask;
2115
+ # ```
1791
2116
  def expect_event(event, predicate: nil, timeout: nil, &block)
1792
2117
  wrap_impl(@impl.expect_event(unwrap_impl(event), predicate: unwrap_impl(predicate), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
1793
2118
  end
@@ -1867,6 +2192,23 @@ module Playwright
1867
2192
  # run(playwright)
1868
2193
  # ```
1869
2194
  #
2195
+ # ```csharp
2196
+ # using Microsoft.Playwright;
2197
+ # using System.Threading.Tasks;
2198
+ #
2199
+ # class FrameExamples
2200
+ # {
2201
+ # public static async Task WaitForFunction()
2202
+ # {
2203
+ # using var playwright = await Playwright.CreateAsync();
2204
+ # await using var browser = await playwright.Webkit.LaunchAsync();
2205
+ # var page = await browser.NewPageAsync();
2206
+ # await page.SetViewportSizeAsync(50, 50);
2207
+ # await page.MainFrame.WaitForFunctionAsync("window.innerWidth < 100");
2208
+ # }
2209
+ # }
2210
+ # ```
2211
+ #
1870
2212
  # To pass an argument to the predicate of [`method: Page.waitForFunction`] function:
1871
2213
  #
1872
2214
  #
@@ -1890,6 +2232,11 @@ module Playwright
1890
2232
  # page.wait_for_function("selector => !!document.querySelector(selector)", selector)
1891
2233
  # ```
1892
2234
  #
2235
+ # ```csharp
2236
+ # var selector = ".foo";
2237
+ # await page.WaitForFunctionAsync("selector => !!document.querySelector(selector)", selector);
2238
+ # ```
2239
+ #
1893
2240
  # Shortcut for main frame's [`method: Frame.waitForFunction`].
1894
2241
  def wait_for_function(expression, arg: nil, polling: nil, timeout: nil)
1895
2242
  wrap_impl(@impl.wait_for_function(unwrap_impl(expression), arg: unwrap_impl(arg), polling: unwrap_impl(polling), timeout: unwrap_impl(timeout)))
@@ -1921,6 +2268,11 @@ module Playwright
1921
2268
  # page.wait_for_load_state() # the promise resolves after "load" event.
1922
2269
  # ```
1923
2270
  #
2271
+ # ```csharp
2272
+ # await page.ClickAsync("button"); // Click triggers navigation.
2273
+ # await page.WaitForLoadStateAsync(); // The promise resolves after 'load' event.
2274
+ # ```
2275
+ #
1924
2276
  #
1925
2277
  # ```js
1926
2278
  # const [popup] = await Promise.all([
@@ -1957,6 +2309,14 @@ module Playwright
1957
2309
  # print(popup.title()) # popup is ready to use.
1958
2310
  # ```
1959
2311
  #
2312
+ # ```csharp
2313
+ # var popupTask = page.WaitForPopupAsync();
2314
+ # await page.ClickAsync("button"); // click triggers the popup/
2315
+ # var popup = await popupTask;
2316
+ # await popup.WaitForLoadStateAsync(LoadState.DOMContentLoaded);
2317
+ # Console.WriteLine(await popup.TitleAsync()); // popup is ready to use.
2318
+ # ```
2319
+ #
1960
2320
  # Shortcut for main frame's [`method: Frame.waitForLoadState`].
1961
2321
  def wait_for_load_state(state: nil, timeout: nil)
1962
2322
  wrap_impl(@impl.wait_for_load_state(state: unwrap_impl(state), timeout: unwrap_impl(timeout)))
@@ -1997,6 +2357,12 @@ module Playwright
1997
2357
  # # Resolves after navigation has finished
1998
2358
  # ```
1999
2359
  #
2360
+ # ```csharp
2361
+ # await Task.WhenAll(page.WaitForNavigationAsync(),
2362
+ # frame.ClickAsync("a.delayed-navigation")); // clicking the link will indirectly cause a navigation
2363
+ # // The method continues after navigation has finished
2364
+ # ```
2365
+ #
2000
2366
  # > NOTE: Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the URL is
2001
2367
  # considered a navigation.
2002
2368
  #
@@ -2012,20 +2378,41 @@ module Playwright
2012
2378
  wrap_impl(@impl.expect_popup(predicate: unwrap_impl(predicate), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
2013
2379
  end
2014
2380
 
2015
- # Waits for the matching request and returns it.
2381
+ # Waits for the matching request and returns it. See [waiting for event](./events.md#waiting-for-event) for more details
2382
+ # about events.
2016
2383
  #
2017
2384
  #
2018
2385
  # ```js
2019
- # const firstRequest = await page.waitForRequest('http://example.com/resource');
2020
- # const finalRequest = await page.waitForRequest(request => request.url() === 'http://example.com' && request.method() === 'GET');
2021
- # return firstRequest.url();
2386
+ # // Note that Promise.all prevents a race condition
2387
+ # // between clicking and waiting for the request.
2388
+ # const [request] = await Promise.all([
2389
+ # // Waits for the next request with the specified url
2390
+ # page.waitForRequest('https://example.com/resource'),
2391
+ # // Triggers the request
2392
+ # page.click('button.triggers-request'),
2393
+ # ]);
2394
+ #
2395
+ # // Alternative way with a predicate.
2396
+ # const [request] = await Promise.all([
2397
+ # // Waits for the next request matching some conditions
2398
+ # page.waitForRequest(request => request.url() === 'https://example.com' && request.method() === 'GET'),
2399
+ # // Triggers the request
2400
+ # page.click('button.triggers-request'),
2401
+ # ]);
2022
2402
  # ```
2023
2403
  #
2024
2404
  # ```java
2025
- # Request firstRequest = page.waitForRequest("http://example.com/resource");
2026
- # Object finalRequest = page.waitForRequest(
2027
- # request -> "http://example.com".equals(request.url()) && "GET".equals(request.method()), () -> {});
2028
- # return firstRequest.url();
2405
+ # // Waits for the next response with the specified url
2406
+ # Request request = page.waitForRequest("https://example.com/resource", () -> {
2407
+ # // Triggers the request
2408
+ # page.click("button.triggers-request");
2409
+ # });
2410
+ #
2411
+ # // Waits for the next request matching some conditions
2412
+ # Request request = page.waitForRequest(request -> "https://example.com".equals(request.url()) && "GET".equals(request.method()), () -> {
2413
+ # // Triggers the request
2414
+ # page.click("button.triggers-request");
2415
+ # });
2029
2416
  # ```
2030
2417
  #
2031
2418
  # ```python async
@@ -2033,6 +2420,7 @@ module Playwright
2033
2420
  # await page.click('button')
2034
2421
  # first_request = await first.value
2035
2422
  #
2423
+ # # or with a lambda
2036
2424
  # async with page.expect_request(lambda request: request.url == "http://example.com" and request.method == "get") as second:
2037
2425
  # await page.click('img')
2038
2426
  # second_request = await second.value
@@ -2043,11 +2431,22 @@ module Playwright
2043
2431
  # page.click('button')
2044
2432
  # first_request = first.value
2045
2433
  #
2434
+ # # or with a lambda
2046
2435
  # with page.expect_request(lambda request: request.url == "http://example.com" and request.method == "get") as second:
2047
2436
  # page.click('img')
2048
2437
  # second_request = second.value
2049
2438
  # ```
2050
2439
  #
2440
+ # ```csharp
2441
+ # // Waits for the next response with the specified url
2442
+ # await Task.WhenAll(page.WaitForRequestAsync("https://example.com/resource"),
2443
+ # page.ClickAsync("button.triggers-request"));
2444
+ #
2445
+ # // Waits for the next request matching some conditions
2446
+ # await Task.WhenAll(page.WaitForRequestAsync(r => "https://example.com".Equals(r.Url) && "GET" == r.Method),
2447
+ # page.ClickAsync("button.triggers-request"));
2448
+ # ```
2449
+ #
2051
2450
  #
2052
2451
  # ```js
2053
2452
  # await page.waitForRequest(request => request.url().searchParams.get('foo') === 'bar' && request.url().searchParams.get('foo2') === 'bar2');
@@ -2056,19 +2455,40 @@ module Playwright
2056
2455
  wrap_impl(@impl.expect_request(unwrap_impl(urlOrPredicate), timeout: unwrap_impl(timeout)))
2057
2456
  end
2058
2457
 
2059
- # Returns the matched response.
2458
+ # Returns the matched response. See [waiting for event](./events.md#waiting-for-event) for more details about events.
2060
2459
  #
2061
2460
  #
2062
2461
  # ```js
2063
- # const firstResponse = await page.waitForResponse('https://example.com/resource');
2064
- # const finalResponse = await page.waitForResponse(response => response.url() === 'https://example.com' && response.status() === 200);
2065
- # return finalResponse.ok();
2462
+ # // Note that Promise.all prevents a race condition
2463
+ # // between clicking and waiting for the response.
2464
+ # const [response] = await Promise.all([
2465
+ # // Waits for the next response with the specified url
2466
+ # page.waitForResponse('https://example.com/resource'),
2467
+ # // Triggers the response
2468
+ # page.click('button.triggers-response'),
2469
+ # ]);
2470
+ #
2471
+ # // Alternative way with a predicate.
2472
+ # const [response] = await Promise.all([
2473
+ # // Waits for the next response matching some conditions
2474
+ # page.waitForResponse(response => response.url() === 'https://example.com' && response.status() === 200),
2475
+ # // Triggers the response
2476
+ # page.click('button.triggers-response'),
2477
+ # ]);
2066
2478
  # ```
2067
2479
  #
2068
2480
  # ```java
2069
- # Response firstResponse = page.waitForResponse("https://example.com/resource", () -> {});
2070
- # Response finalResponse = page.waitForResponse(response -> "https://example.com".equals(response.url()) && response.status() == 200, () -> {});
2071
- # return finalResponse.ok();
2481
+ # // Waits for the next response with the specified url
2482
+ # Response response = page.waitForResponse("https://example.com/resource", () -> {
2483
+ # // Triggers the response
2484
+ # page.click("button.triggers-response");
2485
+ # });
2486
+ #
2487
+ # // Waits for the next response matching some conditions
2488
+ # Response response = page.waitForResponse(response -> "https://example.com".equals(response.url()) && response.status() == 200, () -> {
2489
+ # // Triggers the response
2490
+ # page.click("button.triggers-response");
2491
+ # });
2072
2492
  # ```
2073
2493
  #
2074
2494
  # ```python async
@@ -2096,6 +2516,16 @@ module Playwright
2096
2516
  # response = response_info.value
2097
2517
  # return response.ok
2098
2518
  # ```
2519
+ #
2520
+ # ```csharp
2521
+ # // Waits for the next response with the specified url
2522
+ # await Task.WhenAll(page.WaitForResponseAsync("https://example.com/resource"),
2523
+ # page.ClickAsync("button.triggers-response"));
2524
+ #
2525
+ # // Waits for the next response matching some conditions
2526
+ # await Task.WhenAll(page.WaitForResponseAsync(r => "https://example.com".Equals(r.Url) && r.Status == 200),
2527
+ # page.ClickAsync("button.triggers-response"));
2528
+ # ```
2099
2529
  def expect_response(urlOrPredicate, timeout: nil)
2100
2530
  wrap_impl(@impl.expect_response(unwrap_impl(urlOrPredicate), timeout: unwrap_impl(timeout)))
2101
2531
  end
@@ -2181,6 +2611,31 @@ module Playwright
2181
2611
  # with sync_playwright() as playwright:
2182
2612
  # run(playwright)
2183
2613
  # ```
2614
+ #
2615
+ # ```csharp
2616
+ # using Microsoft.Playwright;
2617
+ # using System;
2618
+ # using System.Threading.Tasks;
2619
+ #
2620
+ # class FrameExamples
2621
+ # {
2622
+ # public static async Task Images()
2623
+ # {
2624
+ # using var playwright = await Playwright.CreateAsync();
2625
+ # await using var browser = await playwright.Chromium.LaunchAsync();
2626
+ # var page = await browser.NewPageAsync();
2627
+ #
2628
+ # foreach (var currentUrl in new[] { "https://www.google.com", "https://bbc.com" })
2629
+ # {
2630
+ # await page.GotoAsync(currentUrl);
2631
+ # var element = await page.WaitForSelectorAsync("img");
2632
+ # Console.WriteLine($"Loaded image: {await element.GetAttributeAsync("src")}");
2633
+ # }
2634
+ #
2635
+ # await browser.CloseAsync();
2636
+ # }
2637
+ # }
2638
+ # ```
2184
2639
  def wait_for_selector(selector, state: nil, timeout: nil)
2185
2640
  wrap_impl(@impl.wait_for_selector(unwrap_impl(selector), state: unwrap_impl(state), timeout: unwrap_impl(timeout)))
2186
2641
  end
@@ -2211,6 +2666,11 @@ module Playwright
2211
2666
  # page.wait_for_timeout(1000)
2212
2667
  # ```
2213
2668
  #
2669
+ # ```csharp
2670
+ # // Wait for 1 second
2671
+ # await page.WaitForTimeoutAsync(1000);
2672
+ # ```
2673
+ #
2214
2674
  # Shortcut for main frame's [`method: Frame.waitForTimeout`].
2215
2675
  def wait_for_timeout(timeout)
2216
2676
  raise NotImplementedError.new('wait_for_timeout is not implemented yet.')
@@ -2239,6 +2699,11 @@ module Playwright
2239
2699
  # page.wait_for_url("**/target.html")
2240
2700
  # ```
2241
2701
  #
2702
+ # ```csharp
2703
+ # await page.ClickAsync("a.delayed-navigation"); // clicking the link will indirectly cause a navigation
2704
+ # await page.WaitForURLAsync("**/target.html");
2705
+ # ```
2706
+ #
2242
2707
  # Shortcut for main frame's [`method: Frame.waitForURL`].
2243
2708
  def wait_for_url(url, timeout: nil, waitUntil: nil)
2244
2709
  wrap_impl(@impl.wait_for_url(unwrap_impl(url), timeout: unwrap_impl(timeout), waitUntil: unwrap_impl(waitUntil)))