playwright-ruby-client 0.5.6 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/docs/api_coverage.md +10 -1
  4. data/lib/playwright/channel_owner.rb +3 -0
  5. data/lib/playwright/channel_owners/browser.rb +27 -2
  6. data/lib/playwright/channel_owners/browser_context.rb +52 -1
  7. data/lib/playwright/channel_owners/browser_type.rb +8 -1
  8. data/lib/playwright/channel_owners/element_handle.rb +15 -6
  9. data/lib/playwright/channel_owners/frame.rb +23 -6
  10. data/lib/playwright/channel_owners/page.rb +25 -44
  11. data/lib/playwright/download.rb +3 -2
  12. data/lib/playwright/events.rb +4 -0
  13. data/lib/playwright/playwright_api.rb +1 -5
  14. data/lib/playwright/tracing_impl.rb +31 -0
  15. data/lib/playwright/version.rb +2 -1
  16. data/lib/playwright_api/accessibility.rb +8 -7
  17. data/lib/playwright_api/android.rb +7 -7
  18. data/lib/playwright_api/android_device.rb +6 -6
  19. data/lib/playwright_api/browser.rb +49 -6
  20. data/lib/playwright_api/browser_context.rb +205 -9
  21. data/lib/playwright_api/browser_type.rb +48 -9
  22. data/lib/playwright_api/console_message.rb +8 -6
  23. data/lib/playwright_api/dialog.rb +29 -6
  24. data/lib/playwright_api/element_handle.rb +130 -26
  25. data/lib/playwright_api/file_chooser.rb +7 -0
  26. data/lib/playwright_api/frame.rb +200 -27
  27. data/lib/playwright_api/js_handle.rb +23 -6
  28. data/lib/playwright_api/keyboard.rb +48 -0
  29. data/lib/playwright_api/page.rb +514 -44
  30. data/lib/playwright_api/playwright.rb +24 -6
  31. data/lib/playwright_api/request.rb +34 -6
  32. data/lib/playwright_api/response.rb +8 -8
  33. data/lib/playwright_api/route.rb +28 -8
  34. data/lib/playwright_api/selectors.rb +31 -6
  35. data/lib/playwright_api/tracing.rb +99 -0
  36. data/lib/playwright_api/worker.rb +2 -2
  37. data/playwright.gemspec +2 -2
  38. metadata +6 -18
@@ -28,6 +28,13 @@ module Playwright
28
28
  # file_chooser = fc_info.value
29
29
  # file_chooser.set_files("myfile.pdf")
30
30
  # ```
31
+ #
32
+ # ```csharp
33
+ # var waitForFileChooserTask = page.WaitForFileChooserAsync();
34
+ # await page.ClickAsync("upload");
35
+ # var fileChooser = await waitForFileChooserTask;
36
+ # await fileChooser.SetFilesAsync("temp.txt");
37
+ # ```
31
38
  class FileChooser < PlaywrightApi
32
39
 
33
40
  # Returns input element associated with this file chooser.
@@ -96,6 +96,32 @@ module Playwright
96
96
  # with sync_playwright() as playwright:
97
97
  # run(playwright)
98
98
  # ```
99
+ #
100
+ # ```csharp
101
+ # using Microsoft.Playwright;
102
+ # using System;
103
+ # using System.Threading.Tasks;
104
+ #
105
+ # class FrameExamples
106
+ # {
107
+ # public static async Task Main()
108
+ # {
109
+ # using var playwright = await Playwright.CreateAsync();
110
+ # await using var browser = await playwright.Firefox.LaunchAsync();
111
+ # var page = await browser.NewPageAsync();
112
+ #
113
+ # await page.GotoAsync("https://www.bing.com");
114
+ # DumpFrameTree(page.MainFrame, string.Empty);
115
+ # }
116
+ #
117
+ # private static void DumpFrameTree(IFrame frame, string indent)
118
+ # {
119
+ # Console.WriteLine($"{indent}{frame.Url}");
120
+ # foreach (var child in frame.ChildFrames)
121
+ # DumpFrameTree(child, indent + " ");
122
+ # }
123
+ # }
124
+ # ```
99
125
  class Frame < PlaywrightApi
100
126
 
101
127
  # Returns the added tag when the script's onload fires or when the script content was injected into frame.
@@ -131,8 +157,9 @@ module Playwright
131
157
  force: nil,
132
158
  noWaitAfter: nil,
133
159
  position: nil,
134
- timeout: nil)
135
- wrap_impl(@impl.check(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
160
+ timeout: nil,
161
+ trial: nil)
162
+ 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)))
136
163
  end
137
164
 
138
165
  def child_frames
@@ -158,8 +185,9 @@ module Playwright
158
185
  modifiers: nil,
159
186
  noWaitAfter: nil,
160
187
  position: nil,
161
- timeout: nil)
162
- 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)))
188
+ timeout: nil,
189
+ trial: nil)
190
+ 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)))
163
191
  end
164
192
 
165
193
  # Gets the full HTML contents of the frame, including the doctype.
@@ -188,8 +216,9 @@ module Playwright
188
216
  modifiers: nil,
189
217
  noWaitAfter: nil,
190
218
  position: nil,
191
- timeout: nil)
192
- 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)))
219
+ timeout: nil,
220
+ trial: nil)
221
+ 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)))
193
222
  end
194
223
 
195
224
  # The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element,
@@ -213,6 +242,10 @@ module Playwright
213
242
  # frame.dispatch_event("button#submit", "click")
214
243
  # ```
215
244
  #
245
+ # ```csharp
246
+ # await frame.DispatchEventAsync("button#submit", "click");
247
+ # ```
248
+ #
216
249
  # Under the hood, it creates an instance of an event based on the given `type`, initializes it with `eventInit` properties
217
250
  # and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default.
218
251
  #
@@ -253,6 +286,12 @@ module Playwright
253
286
  # data_transfer = frame.evaluate_handle("new DataTransfer()")
254
287
  # frame.dispatch_event("#source", "dragstart", { "dataTransfer": data_transfer })
255
288
  # ```
289
+ #
290
+ # ```csharp
291
+ # // Note you can only create DataTransfer in Chromium and Firefox
292
+ # var dataTransfer = await frame.EvaluateHandleAsync("() => new DataTransfer()");
293
+ # await frame.DispatchEventAsync("#source", "dragstart", new { dataTransfer });
294
+ # ```
256
295
  def dispatch_event(selector, type, eventInit: nil, timeout: nil)
257
296
  wrap_impl(@impl.dispatch_event(unwrap_impl(selector), unwrap_impl(type), eventInit: unwrap_impl(eventInit), timeout: unwrap_impl(timeout)))
258
297
  end
@@ -292,6 +331,12 @@ module Playwright
292
331
  # preload_href = frame.eval_on_selector("link[rel=preload]", "el => el.href")
293
332
  # html = frame.eval_on_selector(".main-container", "(e, suffix) => e.outerHTML + suffix", "hello")
294
333
  # ```
334
+ #
335
+ # ```csharp
336
+ # var searchValue = await frame.EvalOnSelectorAsync<string>("#search", "el => el.value");
337
+ # var preloadHref = await frame.EvalOnSelectorAsync<string>("link[rel=preload]", "el => el.href");
338
+ # var html = await frame.EvalOnSelectorAsync(".main-container", "(e, suffix) => e.outerHTML + suffix", "hello");
339
+ # ```
295
340
  def eval_on_selector(selector, expression, arg: nil)
296
341
  wrap_impl(@impl.eval_on_selector(unwrap_impl(selector), unwrap_impl(expression), arg: unwrap_impl(arg)))
297
342
  end
@@ -322,6 +367,10 @@ module Playwright
322
367
  # ```python sync
323
368
  # divs_counts = frame.eval_on_selector_all("div", "(divs, min) => divs.length >= min", 10)
324
369
  # ```
370
+ #
371
+ # ```csharp
372
+ # var divsCount = await frame.EvalOnSelectorAllAsync<bool>("div", "(divs, min) => divs.length >= min", 10);
373
+ # ```
325
374
  def eval_on_selector_all(selector, expression, arg: nil)
326
375
  wrap_impl(@impl.eval_on_selector_all(unwrap_impl(selector), unwrap_impl(expression), arg: unwrap_impl(arg)))
327
376
  end
@@ -360,6 +409,11 @@ module Playwright
360
409
  # print(result) # prints "56"
361
410
  # ```
362
411
  #
412
+ # ```csharp
413
+ # var result = await frame.EvaluateAsync<int>("([x, y]) => Promise.resolve(x * y)", new[] { 7, 8 });
414
+ # Console.WriteLine(result);
415
+ # ```
416
+ #
363
417
  # A string can also be passed in instead of a function.
364
418
  #
365
419
  #
@@ -383,6 +437,10 @@ module Playwright
383
437
  # print(frame.evaluate(f"1 + {x}")) # prints "11"
384
438
  # ```
385
439
  #
440
+ # ```csharp
441
+ # Console.WriteLine(await frame.EvaluateAsync<int>("1 + 2")); // prints "3"
442
+ # ```
443
+ #
386
444
  # `ElementHandle` instances can be passed as an argument to the [`method: Frame.evaluate`]:
387
445
  #
388
446
  #
@@ -409,6 +467,12 @@ module Playwright
409
467
  # html = frame.evaluate("([body, suffix]) => body.innerHTML + suffix", [body_handle, "hello"])
410
468
  # body_handle.dispose()
411
469
  # ```
470
+ #
471
+ # ```csharp
472
+ # var bodyHandle = await frame.QuerySelectorAsync("body");
473
+ # var html = await frame.EvaluateAsync<string>("([body, suffix]) => body.innerHTML + suffix", new object [] { bodyHandle, "hello" });
474
+ # await bodyHandle.DisposeAsync();
475
+ # ```
412
476
  def evaluate(expression, arg: nil)
413
477
  wrap_impl(@impl.evaluate(unwrap_impl(expression), arg: unwrap_impl(arg)))
414
478
  end
@@ -442,6 +506,11 @@ module Playwright
442
506
  # a_window_handle # handle for the window object.
443
507
  # ```
444
508
  #
509
+ # ```csharp
510
+ # // Handle for the window object.
511
+ # var aWindowHandle = await frame.EvaluateHandleAsync("() => Promise.resolve(window)");
512
+ # ```
513
+ #
445
514
  # A string can also be passed in instead of a function.
446
515
  #
447
516
  #
@@ -461,6 +530,10 @@ module Playwright
461
530
  # a_handle = page.evaluate_handle("document") # handle for the "document"
462
531
  # ```
463
532
  #
533
+ # ```csharp
534
+ # var docHandle = await frame.EvalueHandleAsync("document"); // Handle for the `document`
535
+ # ```
536
+ #
464
537
  # `JSHandle` instances can be passed as an argument to the [`method: Frame.evaluateHandle`]:
465
538
  #
466
539
  #
@@ -491,15 +564,25 @@ module Playwright
491
564
  # print(result_handle.json_value())
492
565
  # result_handle.dispose()
493
566
  # ```
567
+ #
568
+ # ```csharp
569
+ # var handle = await frame.EvaluateHandleAsync("() => document.body");
570
+ # var resultHandle = await frame.EvaluateHandleAsync("([body, suffix]) => body.innerHTML + suffix", new object[] { handle, "hello" });
571
+ # Console.WriteLine(await resultHandle.JsonValueAsync<string>());
572
+ # await resultHandle.DisposeAsync();
573
+ # ```
494
574
  def evaluate_handle(expression, arg: nil)
495
575
  wrap_impl(@impl.evaluate_handle(unwrap_impl(expression), arg: unwrap_impl(arg)))
496
576
  end
497
577
 
498
578
  # This method waits for an element matching `selector`, waits for [actionability](./actionability.md) checks, focuses the
499
- # element, fills it and triggers an `input` event after filling. If the element is inside the `<label>` element that has
500
- # associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), that control will be
501
- # filled instead. If the element to be filled is not an `<input>`, `<textarea>` or `[contenteditable]` element, this
502
- # method throws an error. Note that you can pass an empty string to clear the input field.
579
+ # element, fills it and triggers an `input` event after filling. Note that you can pass an empty string to clear the input
580
+ # field.
581
+ #
582
+ # If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error.
583
+ # However, if the element is inside the `<label>` element that has an associated
584
+ # [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled
585
+ # instead.
503
586
  #
504
587
  # To send fine-grained keyboard events, use [`method: Frame.type`].
505
588
  def fill(selector, value, noWaitAfter: nil, timeout: nil)
@@ -543,8 +626,14 @@ module Playwright
543
626
  # content_frame = frame_element.content_frame()
544
627
  # assert frame == content_frame
545
628
  # ```
629
+ #
630
+ # ```csharp
631
+ # var frameElement = await frame.FrameElementAsync();
632
+ # var contentFrame = await frameElement.ContentFrameAsync();
633
+ # Console.WriteLine(frame == contentFrame); // -> True
634
+ # ```
546
635
  def frame_element
547
- raise NotImplementedError.new('frame_element is not implemented yet.')
636
+ wrap_impl(@impl.frame_element)
548
637
  end
549
638
 
550
639
  # Returns element attribute value.
@@ -589,8 +678,9 @@ module Playwright
589
678
  force: nil,
590
679
  modifiers: nil,
591
680
  position: nil,
592
- timeout: nil)
593
- wrap_impl(@impl.hover(unwrap_impl(selector), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
681
+ timeout: nil,
682
+ trial: nil)
683
+ 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)))
594
684
  end
595
685
 
596
686
  # Returns `element.innerHTML`.
@@ -700,12 +790,16 @@ module Playwright
700
790
  wrap_impl(@impl.query_selector_all(unwrap_impl(selector)))
701
791
  end
702
792
 
703
- # Returns the array of option values that have been successfully selected.
793
+ # This method waits for an element matching `selector`, waits for [actionability](./actionability.md) checks, waits until
794
+ # all specified options are present in the `<select>` element and selects these options.
704
795
  #
705
- # Triggers a `change` and `input` event once all the provided options have been selected. If there's no `<select>` element
706
- # matching `selector`, the method throws an error.
796
+ # If the target element is not a `<select>` element, this method throws an error. However, if the element is inside the
797
+ # `<label>` element that has an associated
798
+ # [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used instead.
799
+ #
800
+ # Returns the array of option values that have been successfully selected.
707
801
  #
708
- # Will wait until all specified options are present in the `<select>` element.
802
+ # Triggers a `change` and `input` event once all the provided options have been selected.
709
803
  #
710
804
  #
711
805
  # ```js
@@ -745,6 +839,15 @@ module Playwright
745
839
  # # multiple selection
746
840
  # frame.select_option("select#colors", value=["red", "green", "blue"])
747
841
  # ```
842
+ #
843
+ # ```csharp
844
+ # // single selection matching the value
845
+ # await frame.SelectOptionAsync("select#colors", new[] { "blue" });
846
+ # // single selection matching both the value and the label
847
+ # await frame.SelectOptionAsync("select#colors", new[] { new SelectOptionValue() { Label = "blue" } });
848
+ # // multiple selection
849
+ # await frame.SelectOptionAsync("select#colors", new[] { "red", "green", "blue" });
850
+ # ```
748
851
  def select_option(
749
852
  selector,
750
853
  element: nil,
@@ -788,8 +891,9 @@ module Playwright
788
891
  modifiers: nil,
789
892
  noWaitAfter: nil,
790
893
  position: nil,
791
- timeout: nil)
792
- 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)))
894
+ timeout: nil,
895
+ trial: nil)
896
+ 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)))
793
897
  end
794
898
 
795
899
  # Returns `element.textContent`.
@@ -829,6 +933,11 @@ module Playwright
829
933
  # frame.type("#mytextarea", "hello") # types instantly
830
934
  # frame.type("#mytextarea", "world", delay=100) # types slower, like a user
831
935
  # ```
936
+ #
937
+ # ```csharp
938
+ # await frame.TypeAsync("#mytextarea", "hello"); // types instantly
939
+ # await frame.TypeAsync("#mytextarea", "world", delay: 100); // types slower, like a user
940
+ # ```
832
941
  def type(
833
942
  selector,
834
943
  text,
@@ -856,8 +965,9 @@ module Playwright
856
965
  force: nil,
857
966
  noWaitAfter: nil,
858
967
  position: nil,
859
- timeout: nil)
860
- wrap_impl(@impl.uncheck(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
968
+ timeout: nil,
969
+ trial: nil)
970
+ 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)))
861
971
  end
862
972
 
863
973
  # Returns frame's url.
@@ -933,6 +1043,23 @@ module Playwright
933
1043
  # run(playwright)
934
1044
  # ```
935
1045
  #
1046
+ # ```csharp
1047
+ # using Microsoft.Playwright;
1048
+ # using System.Threading.Tasks;
1049
+ #
1050
+ # class FrameExamples
1051
+ # {
1052
+ # public static async Task Main()
1053
+ # {
1054
+ # using var playwright = await Playwright.CreateAsync();
1055
+ # await using var browser = await playwright.Firefox.LaunchAsync();
1056
+ # var page = await browser.NewPageAsync();
1057
+ # await page.SetViewportSizeAsync(50, 50);
1058
+ # await page.MainFrame.WaitForFunctionAsync("window.innerWidth < 100");
1059
+ # }
1060
+ # }
1061
+ # ```
1062
+ #
936
1063
  # To pass an argument to the predicate of `frame.waitForFunction` function:
937
1064
  #
938
1065
  #
@@ -955,6 +1082,11 @@ module Playwright
955
1082
  # selector = ".foo"
956
1083
  # frame.wait_for_function("selector => !!document.querySelector(selector)", selector)
957
1084
  # ```
1085
+ #
1086
+ # ```csharp
1087
+ # var selector = ".foo";
1088
+ # await page.MainFrame.WaitForFunctionAsync("selector => !!document.querySelector(selector)", selector);
1089
+ # ```
958
1090
  def wait_for_function(expression, arg: nil, polling: nil, timeout: nil)
959
1091
  wrap_impl(@impl.wait_for_function(unwrap_impl(expression), arg: unwrap_impl(arg), polling: unwrap_impl(polling), timeout: unwrap_impl(timeout)))
960
1092
  end
@@ -984,6 +1116,11 @@ module Playwright
984
1116
  # frame.click("button") # click triggers navigation.
985
1117
  # frame.wait_for_load_state() # the promise resolves after "load" event.
986
1118
  # ```
1119
+ #
1120
+ # ```csharp
1121
+ # await frame.ClickAsync("button");
1122
+ # await frame.WaitForLoadStateAsync(); // Defaults to LoadState.Load
1123
+ # ```
987
1124
  def wait_for_load_state(state: nil, timeout: nil)
988
1125
  wrap_impl(@impl.wait_for_load_state(state: unwrap_impl(state), timeout: unwrap_impl(timeout)))
989
1126
  end
@@ -1023,6 +1160,14 @@ module Playwright
1023
1160
  # # Resolves after navigation has finished
1024
1161
  # ```
1025
1162
  #
1163
+ # ```csharp
1164
+ # await Task.WhenAll(
1165
+ # frame.WaitForNavigationAsync(),
1166
+ # // clicking the link will indirectly cause a navigation
1167
+ # frame.ClickAsync("a.delayed-navigation"));
1168
+ # // Resolves after navigation has finished
1169
+ # ```
1170
+ #
1026
1171
  # > NOTE: Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the URL is
1027
1172
  # considered a navigation.
1028
1173
  def expect_navigation(timeout: nil, url: nil, waitUntil: nil, &block)
@@ -1110,6 +1255,29 @@ module Playwright
1110
1255
  # with sync_playwright() as playwright:
1111
1256
  # run(playwright)
1112
1257
  # ```
1258
+ #
1259
+ # ```csharp
1260
+ # using Microsoft.Playwright;
1261
+ # using System;
1262
+ # using System.Threading.Tasks;
1263
+ #
1264
+ # class FrameExamples
1265
+ # {
1266
+ # public static async Task Main()
1267
+ # {
1268
+ # using var playwright = await Playwright.CreateAsync();
1269
+ # await using var browser = await playwright.Chromium.LaunchAsync();
1270
+ # var page = await browser.NewPageAsync();
1271
+ #
1272
+ # foreach (var currentUrl in new[] { "https://www.google.com", "https://bbc.com" })
1273
+ # {
1274
+ # await page.GotoAsync(currentUrl);
1275
+ # element = await page.MainFrame.WaitForSelectorAsync("img");
1276
+ # Console.WriteLine($"Loaded image: {await element.GetAttributeAsync("src")}");
1277
+ # }
1278
+ # }
1279
+ # }
1280
+ # ```
1113
1281
  def wait_for_selector(selector, state: nil, timeout: nil)
1114
1282
  wrap_impl(@impl.wait_for_selector(unwrap_impl(selector), state: unwrap_impl(state), timeout: unwrap_impl(timeout)))
1115
1283
  end
@@ -1144,6 +1312,11 @@ module Playwright
1144
1312
  # frame.click("a.delayed-navigation") # clicking the link will indirectly cause a navigation
1145
1313
  # frame.wait_for_url("**/target.html")
1146
1314
  # ```
1315
+ #
1316
+ # ```csharp
1317
+ # await frame.ClickAsync("a.delayed-navigation"); // clicking the link will indirectly cause a navigation
1318
+ # await frame.WaitForURLAsync("**/target.html");
1319
+ # ```
1147
1320
  def wait_for_url(url, timeout: nil, waitUntil: nil)
1148
1321
  wrap_impl(@impl.wait_for_url(unwrap_impl(url), timeout: unwrap_impl(timeout), waitUntil: unwrap_impl(waitUntil)))
1149
1322
  end
@@ -1155,20 +1328,20 @@ module Playwright
1155
1328
 
1156
1329
  # -- inherited from EventEmitter --
1157
1330
  # @nodoc
1158
- def once(event, callback)
1159
- event_emitter_proxy.once(event, callback)
1331
+ def off(event, callback)
1332
+ event_emitter_proxy.off(event, callback)
1160
1333
  end
1161
1334
 
1162
1335
  # -- inherited from EventEmitter --
1163
1336
  # @nodoc
1164
- def on(event, callback)
1165
- event_emitter_proxy.on(event, callback)
1337
+ def once(event, callback)
1338
+ event_emitter_proxy.once(event, callback)
1166
1339
  end
1167
1340
 
1168
1341
  # -- inherited from EventEmitter --
1169
1342
  # @nodoc
1170
- def off(event, callback)
1171
- event_emitter_proxy.off(event, callback)
1343
+ def on(event, callback)
1344
+ event_emitter_proxy.on(event, callback)
1172
1345
  end
1173
1346
 
1174
1347
  private def event_emitter_proxy
@@ -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
@@ -147,20 +164,20 @@ module Playwright
147
164
 
148
165
  # -- inherited from EventEmitter --
149
166
  # @nodoc
150
- def once(event, callback)
151
- event_emitter_proxy.once(event, callback)
167
+ def off(event, callback)
168
+ event_emitter_proxy.off(event, callback)
152
169
  end
153
170
 
154
171
  # -- inherited from EventEmitter --
155
172
  # @nodoc
156
- def on(event, callback)
157
- event_emitter_proxy.on(event, callback)
173
+ def once(event, callback)
174
+ event_emitter_proxy.once(event, callback)
158
175
  end
159
176
 
160
177
  # -- inherited from EventEmitter --
161
178
  # @nodoc
162
- def off(event, callback)
163
- event_emitter_proxy.off(event, callback)
179
+ def on(event, callback)
180
+ event_emitter_proxy.on(event, callback)
164
181
  end
165
182
 
166
183
  private def event_emitter_proxy