playwright-ruby-client 0.1.0 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +20 -8
  3. data/docs/api_coverage.md +123 -73
  4. data/lib/playwright.rb +48 -9
  5. data/lib/playwright/channel.rb +12 -2
  6. data/lib/playwright/channel_owner.rb +3 -5
  7. data/lib/playwright/channel_owners/android.rb +1 -1
  8. data/lib/playwright/channel_owners/android_device.rb +11 -11
  9. data/lib/playwright/channel_owners/artifact.rb +30 -0
  10. data/lib/playwright/channel_owners/binding_call.rb +3 -0
  11. data/lib/playwright/channel_owners/browser.rb +22 -1
  12. data/lib/playwright/channel_owners/browser_context.rb +155 -4
  13. data/lib/playwright/channel_owners/browser_type.rb +28 -0
  14. data/lib/playwright/channel_owners/dialog.rb +28 -0
  15. data/lib/playwright/channel_owners/element_handle.rb +18 -5
  16. data/lib/playwright/channel_owners/frame.rb +40 -5
  17. data/lib/playwright/channel_owners/js_handle.rb +3 -3
  18. data/lib/playwright/channel_owners/page.rb +172 -51
  19. data/lib/playwright/channel_owners/playwright.rb +24 -27
  20. data/lib/playwright/channel_owners/request.rb +27 -3
  21. data/lib/playwright/channel_owners/response.rb +60 -0
  22. data/lib/playwright/channel_owners/route.rb +78 -0
  23. data/lib/playwright/channel_owners/selectors.rb +19 -1
  24. data/lib/playwright/channel_owners/stream.rb +15 -0
  25. data/lib/playwright/connection.rb +11 -32
  26. data/lib/playwright/download.rb +27 -0
  27. data/lib/playwright/errors.rb +6 -0
  28. data/lib/playwright/events.rb +2 -5
  29. data/lib/playwright/keyboard_impl.rb +1 -1
  30. data/lib/playwright/mouse_impl.rb +41 -0
  31. data/lib/playwright/playwright_api.rb +3 -1
  32. data/lib/playwright/route_handler_entry.rb +28 -0
  33. data/lib/playwright/select_option_values.rb +14 -4
  34. data/lib/playwright/transport.rb +28 -7
  35. data/lib/playwright/url_matcher.rb +1 -1
  36. data/lib/playwright/utils.rb +11 -2
  37. data/lib/playwright/version.rb +1 -1
  38. data/lib/playwright/video.rb +51 -0
  39. data/lib/playwright/wait_helper.rb +2 -2
  40. data/lib/playwright_api/accessibility.rb +39 -1
  41. data/lib/playwright_api/android.rb +72 -5
  42. data/lib/playwright_api/android_device.rb +139 -26
  43. data/lib/playwright_api/android_input.rb +17 -13
  44. data/lib/playwright_api/android_socket.rb +16 -0
  45. data/lib/playwright_api/android_web_view.rb +21 -0
  46. data/lib/playwright_api/browser.rb +87 -19
  47. data/lib/playwright_api/browser_context.rb +216 -32
  48. data/lib/playwright_api/browser_type.rb +45 -58
  49. data/lib/playwright_api/dialog.rb +54 -7
  50. data/lib/playwright_api/element_handle.rb +113 -33
  51. data/lib/playwright_api/file_chooser.rb +6 -1
  52. data/lib/playwright_api/frame.rb +238 -43
  53. data/lib/playwright_api/js_handle.rb +20 -2
  54. data/lib/playwright_api/keyboard.rb +48 -1
  55. data/lib/playwright_api/mouse.rb +26 -5
  56. data/lib/playwright_api/page.rb +534 -63
  57. data/lib/playwright_api/playwright.rb +43 -47
  58. data/lib/playwright_api/request.rb +38 -12
  59. data/lib/playwright_api/response.rb +27 -10
  60. data/lib/playwright_api/route.rb +51 -6
  61. data/lib/playwright_api/selectors.rb +28 -2
  62. data/lib/playwright_api/touchscreen.rb +1 -1
  63. data/lib/playwright_api/web_socket.rb +15 -0
  64. data/lib/playwright_api/worker.rb +25 -1
  65. data/playwright.gemspec +4 -2
  66. metadata +42 -14
  67. data/lib/playwright/channel_owners/chromium_browser.rb +0 -8
  68. data/lib/playwright/channel_owners/chromium_browser_context.rb +0 -8
  69. data/lib/playwright/channel_owners/download.rb +0 -27
  70. data/lib/playwright/channel_owners/firefox_browser.rb +0 -8
  71. data/lib/playwright/channel_owners/webkit_browser.rb +0 -8
  72. data/lib/playwright_api/binding_call.rb +0 -27
  73. data/lib/playwright_api/chromium_browser_context.rb +0 -59
  74. data/lib/playwright_api/download.rb +0 -100
  75. data/lib/playwright_api/video.rb +0 -24
@@ -13,12 +13,32 @@ module Playwright
13
13
  # page.on('dialog', async dialog => {
14
14
  # console.log(dialog.message());
15
15
  # await dialog.dismiss();
16
- # await browser.close();
17
16
  # });
18
- # page.evaluate(() => alert('1'));
17
+ # await page.evaluate(() => alert('1'));
18
+ # await browser.close();
19
19
  # })();
20
20
  # ```
21
21
  #
22
+ # ```java
23
+ # import com.microsoft.playwright.*;
24
+ #
25
+ # public class Example {
26
+ # public static void main(String[] args) {
27
+ # try (Playwright playwright = Playwright.create()) {
28
+ # BrowserType chromium = playwright.chromium();
29
+ # Browser browser = chromium.launch();
30
+ # Page page = browser.newPage();
31
+ # page.onDialog(dialog -> {
32
+ # System.out.println(dialog.message());
33
+ # dialog.dismiss();
34
+ # });
35
+ # page.evaluate("alert('1')");
36
+ # browser.close();
37
+ # }
38
+ # }
39
+ # }
40
+ # ```
41
+ #
22
42
  # ```python async
23
43
  # import asyncio
24
44
  # from playwright.async_api import async_playwright
@@ -68,27 +88,54 @@ module Playwright
68
88
 
69
89
  # Returns when the dialog has been accepted.
70
90
  def accept(promptText: nil)
71
- raise NotImplementedError.new('accept is not implemented yet.')
91
+ wrap_impl(@impl.accept(promptText: unwrap_impl(promptText)))
72
92
  end
73
93
 
74
94
  # If dialog is prompt, returns default prompt value. Otherwise, returns empty string.
75
95
  def default_value
76
- raise NotImplementedError.new('default_value is not implemented yet.')
96
+ wrap_impl(@impl.default_value)
77
97
  end
78
98
 
79
99
  # Returns when the dialog has been dismissed.
80
100
  def dismiss
81
- raise NotImplementedError.new('dismiss is not implemented yet.')
101
+ wrap_impl(@impl.dismiss)
82
102
  end
83
103
 
84
104
  # A message displayed in the dialog.
85
105
  def message
86
- raise NotImplementedError.new('message is not implemented yet.')
106
+ wrap_impl(@impl.message)
87
107
  end
88
108
 
89
109
  # Returns dialog's type, can be one of `alert`, `beforeunload`, `confirm` or `prompt`.
90
110
  def type
91
- raise NotImplementedError.new('type is not implemented yet.')
111
+ wrap_impl(@impl.type)
112
+ end
113
+
114
+ # @nodoc
115
+ def accept_async(promptText: nil)
116
+ wrap_impl(@impl.accept_async(promptText: unwrap_impl(promptText)))
117
+ end
118
+
119
+ # -- inherited from EventEmitter --
120
+ # @nodoc
121
+ def once(event, callback)
122
+ event_emitter_proxy.once(event, callback)
123
+ end
124
+
125
+ # -- inherited from EventEmitter --
126
+ # @nodoc
127
+ def on(event, callback)
128
+ event_emitter_proxy.on(event, callback)
129
+ end
130
+
131
+ # -- inherited from EventEmitter --
132
+ # @nodoc
133
+ def off(event, callback)
134
+ event_emitter_proxy.off(event, callback)
135
+ end
136
+
137
+ private def event_emitter_proxy
138
+ @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
92
139
  end
93
140
  end
94
141
  end
@@ -20,6 +20,24 @@ module Playwright
20
20
  # })();
21
21
  # ```
22
22
  #
23
+ # ```java
24
+ # import com.microsoft.playwright.*;
25
+ #
26
+ # public class Example {
27
+ # public static void main(String[] args) {
28
+ # try (Playwright playwright = Playwright.create()) {
29
+ # BrowserType chromium = playwright.chromium();
30
+ # Browser browser = chromium.launch();
31
+ # Page page = browser.newPage();
32
+ # page.navigate("https://example.com");
33
+ # ElementHandle hrefElement = page.querySelector("a");
34
+ # hrefElement.click();
35
+ # // ...
36
+ # }
37
+ # }
38
+ # }
39
+ # ```
40
+ #
23
41
  # ```python async
24
42
  # import asyncio
25
43
  # from playwright.async_api import async_playwright
@@ -81,6 +99,11 @@ module Playwright
81
99
  # await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2);
82
100
  # ```
83
101
  #
102
+ # ```java
103
+ # BoundingBox box = elementHandle.boundingBox();
104
+ # page.mouse().click(box.x + box.width / 2, box.y + box.height / 2);
105
+ # ```
106
+ #
84
107
  # ```python async
85
108
  # box = await element_handle.bounding_box()
86
109
  # await page.mouse.click(box["x"] + box["width"] / 2, box["y"] + box["height"] / 2)
@@ -95,20 +118,20 @@ module Playwright
95
118
  end
96
119
 
97
120
  # This method checks the element by performing the following steps:
98
- # 1. Ensure that element is a checkbox or a radio input. If not, this method rejects. If the element is already
99
- # checked, this method returns immediately.
121
+ # 1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already checked,
122
+ # this method returns immediately.
100
123
  # 1. Wait for [actionability](./actionability.md) checks on the element, unless `force` option is set.
101
124
  # 1. Scroll the element into view if needed.
102
125
  # 1. Use [`property: Page.mouse`] to click in the center of the element.
103
126
  # 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
104
- # 1. Ensure that the element is now checked. If not, this method rejects.
127
+ # 1. Ensure that the element is now checked. If not, this method throws.
105
128
  #
106
- # If the element is detached from the DOM at any moment during the action, this method rejects.
129
+ # If the element is detached from the DOM at any moment during the action, this method throws.
107
130
  #
108
- # When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`.
109
- # Passing zero timeout disables this.
110
- def check(force: nil, noWaitAfter: nil, timeout: nil)
111
- wrap_impl(@impl.check(force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
131
+ # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
132
+ # zero timeout disables this.
133
+ def check(force: nil, noWaitAfter: nil, position: nil, timeout: nil)
134
+ wrap_impl(@impl.check(force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
112
135
  end
113
136
 
114
137
  # This method clicks the element by performing the following steps:
@@ -117,10 +140,10 @@ module Playwright
117
140
  # 1. Use [`property: Page.mouse`] to click in the center of the element, or the specified `position`.
118
141
  # 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
119
142
  #
120
- # If the element is detached from the DOM at any moment during the action, this method rejects.
143
+ # If the element is detached from the DOM at any moment during the action, this method throws.
121
144
  #
122
- # When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`.
123
- # Passing zero timeout disables this.
145
+ # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
146
+ # zero timeout disables this.
124
147
  def click(
125
148
  button: nil,
126
149
  clickCount: nil,
@@ -143,12 +166,12 @@ module Playwright
143
166
  # 1. Scroll the element into view if needed.
144
167
  # 1. Use [`property: Page.mouse`] to double click in the center of the element, or the specified `position`.
145
168
  # 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the
146
- # first click of the `dblclick()` triggers a navigation event, this method will reject.
169
+ # first click of the `dblclick()` triggers a navigation event, this method will throw.
147
170
  #
148
- # If the element is detached from the DOM at any moment during the action, this method rejects.
171
+ # If the element is detached from the DOM at any moment during the action, this method throws.
149
172
  #
150
- # When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`.
151
- # Passing zero timeout disables this.
173
+ # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
174
+ # zero timeout disables this.
152
175
  #
153
176
  # > NOTE: `elementHandle.dblclick()` dispatches two `click` events and a single `dblclick` event.
154
177
  def dblclick(
@@ -162,8 +185,8 @@ module Playwright
162
185
  wrap_impl(@impl.dblclick(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)))
163
186
  end
164
187
 
165
- # The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the elment, `click`
166
- # is dispatched. This is equivalend to calling
188
+ # The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element,
189
+ # `click` is dispatched. This is equivalent to calling
167
190
  # [element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
168
191
  #
169
192
  #
@@ -171,6 +194,10 @@ module Playwright
171
194
  # await elementHandle.dispatchEvent('click');
172
195
  # ```
173
196
  #
197
+ # ```java
198
+ # elementHandle.dispatchEvent("click");
199
+ # ```
200
+ #
174
201
  # ```python async
175
202
  # await element_handle.dispatch_event("click")
176
203
  # ```
@@ -200,6 +227,14 @@ module Playwright
200
227
  # await elementHandle.dispatchEvent('dragstart', { dataTransfer });
201
228
  # ```
202
229
  #
230
+ # ```java
231
+ # // Note you can only create DataTransfer in Chromium and Firefox
232
+ # JSHandle dataTransfer = page.evaluateHandle("() => new DataTransfer()");
233
+ # Map<String, Object> arg = new HashMap<>();
234
+ # arg.put("dataTransfer", dataTransfer);
235
+ # elementHandle.dispatchEvent("dragstart", arg);
236
+ # ```
237
+ #
203
238
  # ```python async
204
239
  # # note you can only create data_transfer in chromium and firefox
205
240
  # data_transfer = await page.evaluate_handle("new DataTransfer()")
@@ -233,6 +268,12 @@ module Playwright
233
268
  # expect(await tweetHandle.$eval('.retweets', node => node.innerText)).toBe('10');
234
269
  # ```
235
270
  #
271
+ # ```java
272
+ # ElementHandle tweetHandle = page.querySelector(".tweet");
273
+ # assertEquals("100", tweetHandle.evalOnSelector(".like", "node => node.innerText"));
274
+ # assertEquals("10", tweetHandle.evalOnSelector(".retweets", "node => node.innerText"));
275
+ # ```
276
+ #
236
277
  # ```python async
237
278
  # tweet_handle = await page.query_selector(".tweet")
238
279
  # assert await tweet_handle.eval_on_selector(".like", "node => node.innerText") == "100"
@@ -271,6 +312,11 @@ module Playwright
271
312
  # expect(await feedHandle.$$eval('.tweet', nodes => nodes.map(n => n.innerText))).toEqual(['Hello!', 'Hi!']);
272
313
  # ```
273
314
  #
315
+ # ```java
316
+ # ElementHandle feedHandle = page.querySelector(".feed");
317
+ # assertEquals(Arrays.asList("Hello!", "Hi!"), feedHandle.evalOnSelectorAll(".tweet", "nodes => nodes.map(n => n.innerText)"));
318
+ # ```
319
+ #
274
320
  # ```python async
275
321
  # feed_handle = await page.query_selector(".feed")
276
322
  # assert await feed_handle.eval_on_selector_all(".tweet", "nodes => nodes.map(n => n.innerText)") == ["hello!", "hi!"]
@@ -310,10 +356,10 @@ module Playwright
310
356
  # 1. Use [`property: Page.mouse`] to hover over the center of the element, or the specified `position`.
311
357
  # 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
312
358
  #
313
- # If the element is detached from the DOM at any moment during the action, this method rejects.
359
+ # If the element is detached from the DOM at any moment during the action, this method throws.
314
360
  #
315
- # When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`.
316
- # Passing zero timeout disables this.
361
+ # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
362
+ # zero timeout disables this.
317
363
  def hover(force: nil, modifiers: nil, position: nil, timeout: nil)
318
364
  wrap_impl(@impl.hover(force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
319
365
  end
@@ -379,7 +425,7 @@ module Playwright
379
425
  # If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
380
426
  # texts.
381
427
  #
382
- # Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When speficied with the
428
+ # Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
383
429
  # modifier, modifier is pressed and being held while the subsequent key is being pressed.
384
430
  def press(key, delay: nil, noWaitAfter: nil, timeout: nil)
385
431
  wrap_impl(@impl.press(unwrap_impl(key), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
@@ -439,6 +485,15 @@ module Playwright
439
485
  # handle.selectOption(['red', 'green', 'blue']);
440
486
  # ```
441
487
  #
488
+ # ```java
489
+ # // single selection matching the value
490
+ # handle.selectOption("blue");
491
+ # // single selection matching the label
492
+ # handle.selectOption(new SelectOption().setLabel("Blue"));
493
+ # // multiple selection
494
+ # handle.selectOption(new String[] {"red", "green", "blue"});
495
+ # ```
496
+ #
442
497
  # ```python async
443
498
  # # single selection matching the value
444
499
  # await handle.select_option("blue")
@@ -467,8 +522,14 @@ module Playwright
467
522
  # # multiple selection for blue, red and second option
468
523
  # handle.select_option(value="blue", { index: 2 }, "red")
469
524
  # ```
470
- def select_option(values, noWaitAfter: nil, timeout: nil)
471
- wrap_impl(@impl.select_option(unwrap_impl(values), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
525
+ def select_option(
526
+ element: nil,
527
+ index: nil,
528
+ value: nil,
529
+ label: nil,
530
+ noWaitAfter: nil,
531
+ timeout: nil)
532
+ wrap_impl(@impl.select_option(element: unwrap_impl(element), index: unwrap_impl(index), value: unwrap_impl(value), label: unwrap_impl(label), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
472
533
  end
473
534
 
474
535
  # This method waits for [actionability](./actionability.md) checks, then focuses the element and selects all its text
@@ -493,10 +554,10 @@ module Playwright
493
554
  # 1. Use [`property: Page.touchscreen`] to tap the center of the element, or the specified `position`.
494
555
  # 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
495
556
  #
496
- # If the element is detached from the DOM at any moment during the action, this method rejects.
557
+ # If the element is detached from the DOM at any moment during the action, this method throws.
497
558
  #
498
- # When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`.
499
- # Passing zero timeout disables this.
559
+ # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
560
+ # zero timeout disables this.
500
561
  #
501
562
  # > NOTE: `elementHandle.tap()` requires that the `hasTouch` option of the browser context be set to true.
502
563
  def tap_point(
@@ -523,6 +584,11 @@ module Playwright
523
584
  # await elementHandle.type('World', {delay: 100}); // Types slower, like a user
524
585
  # ```
525
586
  #
587
+ # ```java
588
+ # elementHandle.type("Hello"); // Types instantly
589
+ # elementHandle.type("World", new ElementHandle.TypeOptions().setDelay(100)); // Types slower, like a user
590
+ # ```
591
+ #
526
592
  # ```python async
527
593
  # await element_handle.type("hello") # types instantly
528
594
  # await element_handle.type("world", delay=100) # types slower, like a user
@@ -542,6 +608,12 @@ module Playwright
542
608
  # await elementHandle.press('Enter');
543
609
  # ```
544
610
  #
611
+ # ```java
612
+ # ElementHandle elementHandle = page.querySelector("input");
613
+ # elementHandle.type("some text");
614
+ # elementHandle.press("Enter");
615
+ # ```
616
+ #
545
617
  # ```python async
546
618
  # element_handle = await page.query_selector("input")
547
619
  # await element_handle.type("some text")
@@ -558,20 +630,20 @@ module Playwright
558
630
  end
559
631
 
560
632
  # This method checks the element by performing the following steps:
561
- # 1. Ensure that element is a checkbox or a radio input. If not, this method rejects. If the element is already
633
+ # 1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already
562
634
  # unchecked, this method returns immediately.
563
635
  # 1. Wait for [actionability](./actionability.md) checks on the element, unless `force` option is set.
564
636
  # 1. Scroll the element into view if needed.
565
637
  # 1. Use [`property: Page.mouse`] to click in the center of the element.
566
638
  # 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
567
- # 1. Ensure that the element is now unchecked. If not, this method rejects.
639
+ # 1. Ensure that the element is now unchecked. If not, this method throws.
568
640
  #
569
- # If the element is detached from the DOM at any moment during the action, this method rejects.
641
+ # If the element is detached from the DOM at any moment during the action, this method throws.
570
642
  #
571
- # When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`.
572
- # Passing zero timeout disables this.
573
- def uncheck(force: nil, noWaitAfter: nil, timeout: nil)
574
- wrap_impl(@impl.uncheck(force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
643
+ # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
644
+ # zero timeout disables this.
645
+ def uncheck(force: nil, noWaitAfter: nil, position: nil, timeout: nil)
646
+ wrap_impl(@impl.uncheck(force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
575
647
  end
576
648
 
577
649
  # Returns when the element satisfies the `state`.
@@ -608,6 +680,14 @@ module Playwright
608
680
  # const span = await div.waitForSelector('span', { state: 'attached' });
609
681
  # ```
610
682
  #
683
+ # ```java
684
+ # page.setContent("<div><span></span></div>");
685
+ # ElementHandle div = page.querySelector("div");
686
+ # // Waiting for the "span" selector relative to the div.
687
+ # ElementHandle span = div.waitForSelector("span", new ElementHandle.WaitForSelectorOptions()
688
+ # .setState(WaitForSelectorState.ATTACHED));
689
+ # ```
690
+ #
611
691
  # ```python async
612
692
  # await page.set_content("<div><span></span></div>")
613
693
  # div = await page.query_selector("div")
@@ -1,5 +1,5 @@
1
1
  module Playwright
2
- # `FileChooser` objects are dispatched by the page in the [`event: Page.filechooser`] event.
2
+ # `FileChooser` objects are dispatched by the page in the [`event: Page.fileChooser`] event.
3
3
  #
4
4
  #
5
5
  # ```js
@@ -10,6 +10,11 @@ module Playwright
10
10
  # await fileChooser.setFiles('myfile.pdf');
11
11
  # ```
12
12
  #
13
+ # ```java
14
+ # FileChooser fileChooser = page.waitForFileChooser(() -> page.click("upload"));
15
+ # fileChooser.setFiles(Paths.get("myfile.pdf"));
16
+ # ```
17
+ #
13
18
  # ```python async
14
19
  # async with page.expect_file_chooser() as fc_info:
15
20
  # await page.click("upload")
@@ -3,10 +3,10 @@ module Playwright
3
3
  # [`method: Frame.childFrames`] methods.
4
4
  #
5
5
  # `Frame` object's lifecycle is controlled by three events, dispatched on the page object:
6
- # - [`event: Page.frameattached`] - fired when the frame gets attached to the page. A Frame can be attached to the page
6
+ # - [`event: Page.frameAttached`] - fired when the frame gets attached to the page. A Frame can be attached to the page
7
7
  # only once.
8
- # - [`event: Page.framenavigated`] - fired when the frame commits navigation to a different URL.
9
- # - [`event: Page.framedetached`] - fired when the frame gets detached from the page. A Frame can be detached from the
8
+ # - [`event: Page.frameNavigated`] - fired when the frame commits navigation to a different URL.
9
+ # - [`event: Page.frameDetached`] - fired when the frame gets detached from the page. A Frame can be detached from the
10
10
  # page only once.
11
11
  #
12
12
  # An example of dumping frame tree:
@@ -31,6 +31,29 @@ module Playwright
31
31
  # })();
32
32
  # ```
33
33
  #
34
+ # ```java
35
+ # import com.microsoft.playwright.*;
36
+ #
37
+ # public class Example {
38
+ # public static void main(String[] args) {
39
+ # try (Playwright playwright = Playwright.create()) {
40
+ # BrowserType firefox = playwright.firefox();
41
+ # Browser browser = firefox.launch();
42
+ # Page page = browser.newPage();
43
+ # page.navigate("https://www.google.com/chrome/browser/canary.html");
44
+ # dumpFrameTree(page.mainFrame(), "");
45
+ # browser.close();
46
+ # }
47
+ # }
48
+ # static void dumpFrameTree(Frame frame, String indent) {
49
+ # System.out.println(indent + frame.url());
50
+ # for (Frame child : frame.childFrames()) {
51
+ # dumpFrameTree(child, indent + " ");
52
+ # }
53
+ # }
54
+ # }
55
+ # ```
56
+ #
34
57
  # ```python async
35
58
  # import asyncio
36
59
  # from playwright.async_api import async_playwright
@@ -91,20 +114,25 @@ module Playwright
91
114
  end
92
115
 
93
116
  # This method checks an element matching `selector` by performing the following steps:
94
- # 1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
95
- # 1. Ensure that matched element is a checkbox or a radio input. If not, this method rejects. If the element is already
117
+ # 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
118
+ # 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws. If the element is already
96
119
  # checked, this method returns immediately.
97
120
  # 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the
98
121
  # element is detached during the checks, the whole action is retried.
99
122
  # 1. Scroll the element into view if needed.
100
123
  # 1. Use [`property: Page.mouse`] to click in the center of the element.
101
124
  # 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
102
- # 1. Ensure that the element is now checked. If not, this method rejects.
125
+ # 1. Ensure that the element is now checked. If not, this method throws.
103
126
  #
104
- # When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`.
105
- # Passing zero timeout disables this.
106
- def check(selector, force: nil, noWaitAfter: nil, timeout: nil)
107
- wrap_impl(@impl.check(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
127
+ # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
128
+ # zero timeout disables this.
129
+ def check(
130
+ selector,
131
+ force: nil,
132
+ noWaitAfter: nil,
133
+ 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)))
108
136
  end
109
137
 
110
138
  def child_frames
@@ -112,15 +140,15 @@ module Playwright
112
140
  end
113
141
 
114
142
  # This method clicks an element matching `selector` by performing the following steps:
115
- # 1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
143
+ # 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
116
144
  # 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the
117
145
  # element is detached during the checks, the whole action is retried.
118
146
  # 1. Scroll the element into view if needed.
119
147
  # 1. Use [`property: Page.mouse`] to click in the center of the element, or the specified `position`.
120
148
  # 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
121
149
  #
122
- # When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`.
123
- # Passing zero timeout disables this.
150
+ # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
151
+ # zero timeout disables this.
124
152
  def click(
125
153
  selector,
126
154
  button: nil,
@@ -140,16 +168,16 @@ module Playwright
140
168
  end
141
169
 
142
170
  # This method double clicks an element matching `selector` by performing the following steps:
143
- # 1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
171
+ # 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
144
172
  # 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the
145
173
  # element is detached during the checks, the whole action is retried.
146
174
  # 1. Scroll the element into view if needed.
147
175
  # 1. Use [`property: Page.mouse`] to double click in the center of the element, or the specified `position`.
148
176
  # 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the
149
- # first click of the `dblclick()` triggers a navigation event, this method will reject.
177
+ # first click of the `dblclick()` triggers a navigation event, this method will throw.
150
178
  #
151
- # When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`.
152
- # Passing zero timeout disables this.
179
+ # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
180
+ # zero timeout disables this.
153
181
  #
154
182
  # > NOTE: `frame.dblclick()` dispatches two `click` events and a single `dblclick` event.
155
183
  def dblclick(
@@ -164,8 +192,8 @@ module Playwright
164
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)))
165
193
  end
166
194
 
167
- # The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the elment, `click`
168
- # is dispatched. This is equivalend to calling
195
+ # The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element,
196
+ # `click` is dispatched. This is equivalent to calling
169
197
  # [element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
170
198
  #
171
199
  #
@@ -173,6 +201,10 @@ module Playwright
173
201
  # await frame.dispatchEvent('button#submit', 'click');
174
202
  # ```
175
203
  #
204
+ # ```java
205
+ # frame.dispatchEvent("button#submit", "click");
206
+ # ```
207
+ #
176
208
  # ```python async
177
209
  # await frame.dispatch_event("button#submit", "click")
178
210
  # ```
@@ -202,6 +234,14 @@ module Playwright
202
234
  # await frame.dispatchEvent('#source', 'dragstart', { dataTransfer });
203
235
  # ```
204
236
  #
237
+ # ```java
238
+ # // Note you can only create DataTransfer in Chromium and Firefox
239
+ # JSHandle dataTransfer = frame.evaluateHandle("() => new DataTransfer()");
240
+ # Map<String, Object> arg = new HashMap<>();
241
+ # arg.put("dataTransfer", dataTransfer);
242
+ # frame.dispatchEvent("#source", "dragstart", arg);
243
+ # ```
244
+ #
205
245
  # ```python async
206
246
  # # note you can only create data_transfer in chromium and firefox
207
247
  # data_transfer = await frame.evaluate_handle("new DataTransfer()")
@@ -235,6 +275,12 @@ module Playwright
235
275
  # const html = await frame.$eval('.main-container', (e, suffix) => e.outerHTML + suffix, 'hello');
236
276
  # ```
237
277
  #
278
+ # ```java
279
+ # String searchValue = (String) frame.evalOnSelector("#search", "el => el.value");
280
+ # String preloadHref = (String) frame.evalOnSelector("link[rel=preload]", "el => el.href");
281
+ # String html = (String) frame.evalOnSelector(".main-container", "(e, suffix) => e.outerHTML + suffix", "hello");
282
+ # ```
283
+ #
238
284
  # ```python async
239
285
  # search_value = await frame.eval_on_selector("#search", "el => el.value")
240
286
  # preload_href = await frame.eval_on_selector("link[rel=preload]", "el => el.href")
@@ -265,6 +311,10 @@ module Playwright
265
311
  # const divsCounts = await frame.$$eval('div', (divs, min) => divs.length >= min, 10);
266
312
  # ```
267
313
  #
314
+ # ```java
315
+ # boolean divsCounts = (boolean) page.evalOnSelectorAll("div", "(divs, min) => divs.length >= min", 10);
316
+ # ```
317
+ #
268
318
  # ```python async
269
319
  # divs_counts = await frame.eval_on_selector_all("div", "(divs, min) => divs.length >= min", 10)
270
320
  # ```
@@ -293,6 +343,13 @@ module Playwright
293
343
  # console.log(result); // prints "56"
294
344
  # ```
295
345
  #
346
+ # ```java
347
+ # Object result = frame.evaluate("([x, y]) => {\n" +
348
+ # " return Promise.resolve(x * y);\n" +
349
+ # "}", Arrays.asList(7, 8));
350
+ # System.out.println(result); // prints "56"
351
+ # ```
352
+ #
296
353
  # ```python async
297
354
  # result = await frame.evaluate("([x, y]) => Promise.resolve(x * y)", [7, 8])
298
355
  # print(result) # prints "56"
@@ -310,6 +367,10 @@ module Playwright
310
367
  # console.log(await frame.evaluate('1 + 2')); // prints "3"
311
368
  # ```
312
369
  #
370
+ # ```java
371
+ # System.out.println(frame.evaluate("1 + 2")); // prints "3"
372
+ # ```
373
+ #
313
374
  # ```python async
314
375
  # print(await frame.evaluate("1 + 2")) # prints "3"
315
376
  # x = 10
@@ -331,6 +392,12 @@ module Playwright
331
392
  # await bodyHandle.dispose();
332
393
  # ```
333
394
  #
395
+ # ```java
396
+ # ElementHandle bodyHandle = frame.querySelector("body");
397
+ # String html = (String) frame.evaluate("([body, suffix]) => body.innerHTML + suffix", Arrays.asList(bodyHandle, "hello"));
398
+ # bodyHandle.dispose();
399
+ # ```
400
+ #
334
401
  # ```python async
335
402
  # body_handle = await frame.query_selector("body")
336
403
  # html = await frame.evaluate("([body, suffix]) => body.innerHTML + suffix", [body_handle, "hello"])
@@ -349,7 +416,7 @@ module Playwright
349
416
  # Returns the return value of `expression` as a `JSHandle`.
350
417
  #
351
418
  # The only difference between [`method: Frame.evaluate`] and [`method: Frame.evaluateHandle`] is that
352
- # [method: Frame.evaluateHandle`] returns `JSHandle`.
419
+ # [`method: Frame.evaluateHandle`] returns `JSHandle`.
353
420
  #
354
421
  # If the function, passed to the [`method: Frame.evaluateHandle`], returns a [Promise], then
355
422
  # [`method: Frame.evaluateHandle`] would wait for the promise to resolve and return its value.
@@ -360,6 +427,11 @@ module Playwright
360
427
  # aWindowHandle; // Handle for the window object.
361
428
  # ```
362
429
  #
430
+ # ```java
431
+ # // Handle for the window object.
432
+ # JSHandle aWindowHandle = frame.evaluateHandle("() => Promise.resolve(window)");
433
+ # ```
434
+ #
363
435
  # ```python async
364
436
  # a_window_handle = await frame.evaluate_handle("Promise.resolve(window)")
365
437
  # a_window_handle # handle for the window object.
@@ -377,6 +449,10 @@ module Playwright
377
449
  # const aHandle = await frame.evaluateHandle('document'); // Handle for the 'document'.
378
450
  # ```
379
451
  #
452
+ # ```java
453
+ # JSHandle aHandle = frame.evaluateHandle("document"); // Handle for the "document".
454
+ # ```
455
+ #
380
456
  # ```python async
381
457
  # a_handle = await page.evaluate_handle("document") # handle for the "document"
382
458
  # ```
@@ -395,6 +471,13 @@ module Playwright
395
471
  # await resultHandle.dispose();
396
472
  # ```
397
473
  #
474
+ # ```java
475
+ # JSHandle aHandle = frame.evaluateHandle("() => document.body");
476
+ # JSHandle resultHandle = frame.evaluateHandle("([body, suffix]) => body.innerHTML + suffix", Arrays.asList(aHandle, "hello"));
477
+ # System.out.println(resultHandle.jsonValue());
478
+ # resultHandle.dispose();
479
+ # ```
480
+ #
398
481
  # ```python async
399
482
  # a_handle = await page.evaluate_handle("document.body")
400
483
  # result_handle = await page.evaluate_handle("body => body.innerHTML", a_handle)
@@ -443,6 +526,12 @@ module Playwright
443
526
  # console.log(frame === contentFrame); // -> true
444
527
  # ```
445
528
  #
529
+ # ```java
530
+ # ElementHandle frameElement = frame.frameElement();
531
+ # Frame contentFrame = frameElement.contentFrame();
532
+ # System.out.println(frame == contentFrame); // -> true
533
+ # ```
534
+ #
446
535
  # ```python async
447
536
  # frame_element = await frame.frame_element()
448
537
  # content_frame = await frame_element.content_frame()
@@ -486,15 +575,15 @@ module Playwright
486
575
  end
487
576
 
488
577
  # This method hovers over an element matching `selector` by performing the following steps:
489
- # 1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
578
+ # 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
490
579
  # 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the
491
580
  # element is detached during the checks, the whole action is retried.
492
581
  # 1. Scroll the element into view if needed.
493
582
  # 1. Use [`property: Page.mouse`] to hover over the center of the element, or the specified `position`.
494
583
  # 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
495
584
  #
496
- # When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`.
497
- # Passing zero timeout disables this.
585
+ # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
586
+ # zero timeout disables this.
498
587
  def hover(
499
588
  selector,
500
589
  force: nil,
@@ -539,12 +628,14 @@ module Playwright
539
628
  wrap_impl(@impl.enabled?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
540
629
  end
541
630
 
542
- # Returns whether the element is hidden, the opposite of [visible](./actionability.md#visible).
631
+ # Returns whether the element is hidden, the opposite of [visible](./actionability.md#visible). `selector` that does not
632
+ # match any elements is considered hidden.
543
633
  def hidden?(selector, timeout: nil)
544
634
  wrap_impl(@impl.hidden?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
545
635
  end
546
636
 
547
- # Returns whether the element is [visible](./actionability.md#visible).
637
+ # Returns whether the element is [visible](./actionability.md#visible). `selector` that does not match any elements is
638
+ # considered not visible.
548
639
  def visible?(selector, timeout: nil)
549
640
  wrap_impl(@impl.visible?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
550
641
  end
@@ -582,7 +673,7 @@ module Playwright
582
673
  # If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
583
674
  # texts.
584
675
  #
585
- # Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When speficied with the
676
+ # Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
586
677
  # modifier, modifier is pressed and being held while the subsequent key is being pressed.
587
678
  def press(
588
679
  selector,
@@ -628,6 +719,15 @@ module Playwright
628
719
  # frame.selectOption('select#colors', 'red', 'green', 'blue');
629
720
  # ```
630
721
  #
722
+ # ```java
723
+ # // single selection matching the value
724
+ # frame.selectOption("select#colors", "blue");
725
+ # // single selection matching both the value and the label
726
+ # frame.selectOption("select#colors", new SelectOption().setLabel("Blue"));
727
+ # // multiple selection
728
+ # frame.selectOption("select#colors", new String[] {"red", "green", "blue"});
729
+ # ```
730
+ #
631
731
  # ```python async
632
732
  # # single selection matching the value
633
733
  # await frame.select_option("select#colors", "blue")
@@ -645,8 +745,15 @@ module Playwright
645
745
  # # multiple selection
646
746
  # frame.select_option("select#colors", value=["red", "green", "blue"])
647
747
  # ```
648
- def select_option(selector, values, noWaitAfter: nil, timeout: nil)
649
- wrap_impl(@impl.select_option(unwrap_impl(selector), unwrap_impl(values), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
748
+ def select_option(
749
+ selector,
750
+ element: nil,
751
+ index: nil,
752
+ value: nil,
753
+ label: nil,
754
+ noWaitAfter: nil,
755
+ timeout: nil)
756
+ wrap_impl(@impl.select_option(unwrap_impl(selector), element: unwrap_impl(element), index: unwrap_impl(index), value: unwrap_impl(value), label: unwrap_impl(label), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
650
757
  end
651
758
 
652
759
  def set_content(html, timeout: nil, waitUntil: nil)
@@ -664,15 +771,15 @@ module Playwright
664
771
  end
665
772
 
666
773
  # This method taps an element matching `selector` by performing the following steps:
667
- # 1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
774
+ # 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
668
775
  # 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the
669
776
  # element is detached during the checks, the whole action is retried.
670
777
  # 1. Scroll the element into view if needed.
671
778
  # 1. Use [`property: Page.touchscreen`] to tap the center of the element, or the specified `position`.
672
779
  # 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
673
780
  #
674
- # When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`.
675
- # Passing zero timeout disables this.
781
+ # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
782
+ # zero timeout disables this.
676
783
  #
677
784
  # > NOTE: `frame.tap()` requires that the `hasTouch` option of the browser context be set to true.
678
785
  def tap_point(
@@ -706,6 +813,13 @@ module Playwright
706
813
  # await frame.type('#mytextarea', 'World', {delay: 100}); // Types slower, like a user
707
814
  # ```
708
815
  #
816
+ # ```java
817
+ # // Types instantly
818
+ # frame.type("#mytextarea", "Hello");
819
+ # // Types slower, like a user
820
+ # frame.type("#mytextarea", "World", new Frame.TypeOptions().setDelay(100));
821
+ # ```
822
+ #
709
823
  # ```python async
710
824
  # await frame.type("#mytextarea", "hello") # types instantly
711
825
  # await frame.type("#mytextarea", "world", delay=100) # types slower, like a user
@@ -725,20 +839,25 @@ module Playwright
725
839
  end
726
840
 
727
841
  # This method checks an element matching `selector` by performing the following steps:
728
- # 1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
729
- # 1. Ensure that matched element is a checkbox or a radio input. If not, this method rejects. If the element is already
842
+ # 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
843
+ # 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws. If the element is already
730
844
  # unchecked, this method returns immediately.
731
845
  # 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the
732
846
  # element is detached during the checks, the whole action is retried.
733
847
  # 1. Scroll the element into view if needed.
734
848
  # 1. Use [`property: Page.mouse`] to click in the center of the element.
735
849
  # 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
736
- # 1. Ensure that the element is now unchecked. If not, this method rejects.
850
+ # 1. Ensure that the element is now unchecked. If not, this method throws.
737
851
  #
738
- # When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`.
739
- # Passing zero timeout disables this.
740
- def uncheck(selector, force: nil, noWaitAfter: nil, timeout: nil)
741
- wrap_impl(@impl.uncheck(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
852
+ # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
853
+ # zero timeout disables this.
854
+ def uncheck(
855
+ selector,
856
+ force: nil,
857
+ noWaitAfter: nil,
858
+ 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)))
742
861
  end
743
862
 
744
863
  # Returns frame's url.
@@ -764,6 +883,23 @@ module Playwright
764
883
  # })();
765
884
  # ```
766
885
  #
886
+ # ```java
887
+ # import com.microsoft.playwright.*;
888
+ #
889
+ # public class Example {
890
+ # public static void main(String[] args) {
891
+ # try (Playwright playwright = Playwright.create()) {
892
+ # BrowserType firefox = playwright.firefox();
893
+ # Browser browser = firefox.launch();
894
+ # Page page = browser.newPage();
895
+ # page.setViewportSize(50, 50);
896
+ # page.mainFrame().waitForFunction("window.innerWidth < 100");
897
+ # browser.close();
898
+ # }
899
+ # }
900
+ # }
901
+ # ```
902
+ #
767
903
  # ```python async
768
904
  # import asyncio
769
905
  # from playwright.async_api import async_playwright
@@ -805,6 +941,11 @@ module Playwright
805
941
  # await frame.waitForFunction(selector => !!document.querySelector(selector), selector);
806
942
  # ```
807
943
  #
944
+ # ```java
945
+ # String selector = ".foo";
946
+ # frame.waitForFunction("selector => !!document.querySelector(selector)", selector);
947
+ # ```
948
+ #
808
949
  # ```python async
809
950
  # selector = ".foo"
810
951
  # await frame.wait_for_function("selector => !!document.querySelector(selector)", selector)
@@ -829,6 +970,11 @@ module Playwright
829
970
  # await frame.waitForLoadState(); // Waits for 'load' state by default.
830
971
  # ```
831
972
  #
973
+ # ```java
974
+ # frame.click("button"); // Click triggers navigation.
975
+ # frame.waitForLoadState(); // Waits for "load" state by default.
976
+ # ```
977
+ #
832
978
  # ```python async
833
979
  # await frame.click("button") # click triggers navigation.
834
980
  # await frame.wait_for_load_state() # the promise resolves after "load" event.
@@ -857,6 +1003,14 @@ module Playwright
857
1003
  # ]);
858
1004
  # ```
859
1005
  #
1006
+ # ```java
1007
+ # // The method returns after navigation has finished
1008
+ # Response response = frame.waitForNavigation(() -> {
1009
+ # // Clicking the link will indirectly cause a navigation
1010
+ # frame.click("a.delayed-navigation");
1011
+ # });
1012
+ # ```
1013
+ #
860
1014
  # ```python async
861
1015
  # async with frame.expect_navigation():
862
1016
  # await frame.click("a.delayed-navigation") # clicking the link will indirectly cause a navigation
@@ -900,6 +1054,26 @@ module Playwright
900
1054
  # })();
901
1055
  # ```
902
1056
  #
1057
+ # ```java
1058
+ # import com.microsoft.playwright.*;
1059
+ #
1060
+ # public class Example {
1061
+ # public static void main(String[] args) {
1062
+ # try (Playwright playwright = Playwright.create()) {
1063
+ # BrowserType chromium = playwright.chromium();
1064
+ # Browser browser = chromium.launch();
1065
+ # Page page = browser.newPage();
1066
+ # for (String currentURL : Arrays.asList("https://google.com", "https://bbc.com")) {
1067
+ # page.navigate(currentURL);
1068
+ # ElementHandle element = page.mainFrame().waitForSelector("img");
1069
+ # System.out.println("Loaded image: " + element.getAttribute("src"));
1070
+ # }
1071
+ # browser.close();
1072
+ # }
1073
+ # }
1074
+ # }
1075
+ # ```
1076
+ #
903
1077
  # ```python async
904
1078
  # import asyncio
905
1079
  # from playwright.async_api import async_playwright
@@ -948,14 +1122,35 @@ module Playwright
948
1122
  raise NotImplementedError.new('wait_for_timeout is not implemented yet.')
949
1123
  end
950
1124
 
951
- # @nodoc
952
- def detached=(req)
953
- wrap_impl(@impl.detached=(unwrap_impl(req)))
1125
+ # Waits for the frame to navigate to the given URL.
1126
+ #
1127
+ #
1128
+ # ```js
1129
+ # await frame.click('a.delayed-navigation'); // Clicking the link will indirectly cause a navigation
1130
+ # await frame.waitForURL('**/target.html');
1131
+ # ```
1132
+ #
1133
+ # ```java
1134
+ # frame.click("a.delayed-navigation"); // Clicking the link will indirectly cause a navigation
1135
+ # frame.waitForURL("**/target.html");
1136
+ # ```
1137
+ #
1138
+ # ```python async
1139
+ # await frame.click("a.delayed-navigation") # clicking the link will indirectly cause a navigation
1140
+ # await frame.wait_for_url("**/target.html")
1141
+ # ```
1142
+ #
1143
+ # ```python sync
1144
+ # frame.click("a.delayed-navigation") # clicking the link will indirectly cause a navigation
1145
+ # frame.wait_for_url("**/target.html")
1146
+ # ```
1147
+ def wait_for_url(url, timeout: nil, waitUntil: nil)
1148
+ wrap_impl(@impl.wait_for_url(unwrap_impl(url), timeout: unwrap_impl(timeout), waitUntil: unwrap_impl(waitUntil)))
954
1149
  end
955
1150
 
956
1151
  # @nodoc
957
- def after_initialize
958
- wrap_impl(@impl.after_initialize)
1152
+ def detached=(req)
1153
+ wrap_impl(@impl.detached=(unwrap_impl(req)))
959
1154
  end
960
1155
 
961
1156
  # -- inherited from EventEmitter --