playwright-ruby-client 0.0.8 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/docs/api_coverage.md +159 -101
  4. data/lib/playwright.rb +5 -2
  5. data/lib/playwright/{input_types/android_input.rb → android_input_impl.rb} +5 -1
  6. data/lib/playwright/api_implementation.rb +18 -0
  7. data/lib/playwright/channel.rb +13 -6
  8. data/lib/playwright/channel_owner.rb +3 -5
  9. data/lib/playwright/channel_owners/android.rb +1 -1
  10. data/lib/playwright/channel_owners/android_device.rb +12 -12
  11. data/lib/playwright/channel_owners/binding_call.rb +3 -0
  12. data/lib/playwright/channel_owners/browser.rb +1 -1
  13. data/lib/playwright/channel_owners/browser_context.rb +157 -3
  14. data/lib/playwright/channel_owners/dialog.rb +28 -0
  15. data/lib/playwright/channel_owners/download.rb +27 -0
  16. data/lib/playwright/channel_owners/element_handle.rb +15 -4
  17. data/lib/playwright/channel_owners/frame.rb +24 -5
  18. data/lib/playwright/channel_owners/js_handle.rb +1 -1
  19. data/lib/playwright/channel_owners/page.rb +367 -29
  20. data/lib/playwright/channel_owners/playwright.rb +4 -0
  21. data/lib/playwright/channel_owners/request.rb +35 -3
  22. data/lib/playwright/channel_owners/response.rb +60 -0
  23. data/lib/playwright/channel_owners/route.rb +78 -0
  24. data/lib/playwright/channel_owners/selectors.rb +19 -1
  25. data/lib/playwright/errors.rb +1 -1
  26. data/lib/playwright/event_emitter.rb +8 -1
  27. data/lib/playwright/event_emitter_proxy.rb +49 -0
  28. data/lib/playwright/file_chooser_impl.rb +23 -0
  29. data/lib/playwright/http_headers.rb +20 -0
  30. data/lib/playwright/input_files.rb +1 -1
  31. data/lib/playwright/{input_types/keyboard.rb → keyboard_impl.rb} +5 -1
  32. data/lib/playwright/mouse_impl.rb +7 -0
  33. data/lib/playwright/playwright_api.rb +59 -20
  34. data/lib/playwright/route_handler_entry.rb +36 -0
  35. data/lib/playwright/select_option_values.rb +14 -4
  36. data/lib/playwright/touchscreen_impl.rb +7 -0
  37. data/lib/playwright/utils.rb +4 -3
  38. data/lib/playwright/version.rb +1 -1
  39. data/lib/playwright/wait_helper.rb +1 -1
  40. data/lib/playwright_api/android.rb +82 -11
  41. data/lib/playwright_api/android_device.rb +148 -32
  42. data/lib/playwright_api/android_input.rb +17 -13
  43. data/lib/playwright_api/android_socket.rb +16 -0
  44. data/lib/playwright_api/android_web_view.rb +21 -0
  45. data/lib/playwright_api/binding_call.rb +14 -5
  46. data/lib/playwright_api/browser.rb +22 -23
  47. data/lib/playwright_api/browser_context.rb +49 -35
  48. data/lib/playwright_api/browser_type.rb +24 -64
  49. data/lib/playwright_api/chromium_browser_context.rb +10 -8
  50. data/lib/playwright_api/console_message.rb +10 -6
  51. data/lib/playwright_api/dialog.rb +37 -6
  52. data/lib/playwright_api/download.rb +28 -11
  53. data/lib/playwright_api/element_handle.rb +107 -96
  54. data/lib/playwright_api/file_chooser.rb +18 -10
  55. data/lib/playwright_api/frame.rb +124 -117
  56. data/lib/playwright_api/js_handle.rb +20 -22
  57. data/lib/playwright_api/keyboard.rb +5 -5
  58. data/lib/playwright_api/page.rb +206 -148
  59. data/lib/playwright_api/playwright.rb +33 -45
  60. data/lib/playwright_api/request.rb +11 -12
  61. data/lib/playwright_api/response.rb +30 -16
  62. data/lib/playwright_api/route.rb +27 -5
  63. data/lib/playwright_api/selectors.rb +14 -10
  64. data/lib/playwright_api/web_socket.rb +10 -1
  65. data/lib/playwright_api/worker.rb +13 -13
  66. metadata +16 -7
  67. data/lib/playwright/input_type.rb +0 -19
  68. data/lib/playwright/input_types/mouse.rb +0 -4
  69. data/lib/playwright/input_types/touchscreen.rb +0 -4
@@ -114,7 +114,7 @@ module Playwright
114
114
  #
115
115
  # > NOTE: Modifier keys DO influence `keyboard.down`. Holding down `Shift` will type the text in upper case.
116
116
  def down(key)
117
- @impl.down(unwrap_impl(key))
117
+ wrap_impl(@impl.down(unwrap_impl(key)))
118
118
  end
119
119
 
120
120
  # Dispatches only `input` event, does not emit the `keydown`, `keyup` or `keypress` events.
@@ -134,7 +134,7 @@ module Playwright
134
134
  #
135
135
  # > NOTE: Modifier keys DO NOT effect `keyboard.insertText`. Holding down `Shift` will not type the text in upper case.
136
136
  def insert_text(text)
137
- @impl.insert_text(unwrap_impl(text))
137
+ wrap_impl(@impl.insert_text(unwrap_impl(text)))
138
138
  end
139
139
 
140
140
  # `key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)
@@ -193,7 +193,7 @@ module Playwright
193
193
  #
194
194
  # Shortcut for [`method: Keyboard.down`] and [`method: Keyboard.up`].
195
195
  def press(key, delay: nil)
196
- @impl.press(unwrap_impl(key), delay: unwrap_impl(delay))
196
+ wrap_impl(@impl.press(unwrap_impl(key), delay: unwrap_impl(delay)))
197
197
  end
198
198
 
199
199
  # Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
@@ -218,12 +218,12 @@ module Playwright
218
218
  #
219
219
  # > NOTE: Modifier keys DO NOT effect `keyboard.type`. Holding down `Shift` will not type the text in upper case.
220
220
  def type(text, delay: nil)
221
- @impl.type(unwrap_impl(text), delay: unwrap_impl(delay))
221
+ wrap_impl(@impl.type(unwrap_impl(text), delay: unwrap_impl(delay)))
222
222
  end
223
223
 
224
224
  # Dispatches a `keyup` event.
225
225
  def up(key)
226
- @impl.up(unwrap_impl(key))
226
+ wrap_impl(@impl.up(unwrap_impl(key)))
227
227
  end
228
228
  end
229
229
  end
@@ -2,8 +2,8 @@ module Playwright
2
2
  # - extends: [EventEmitter]
3
3
  #
4
4
  # Page provides methods to interact with a single tab in a `Browser`, or an
5
- # [extension background page](https://developer.chrome.com/extensions/background_pages) in Chromium. One [Browser]
6
- # instance might have multiple [Page] instances.
5
+ # [extension background page](https://developer.chrome.com/extensions/background_pages) in Chromium. One `Browser`
6
+ # instance might have multiple `Page` instances.
7
7
  #
8
8
  # This example creates a page, navigates it to a URL, and then saves a screenshot:
9
9
  #
@@ -96,12 +96,6 @@ module Playwright
96
96
  wrap_impl(@impl.accessibility)
97
97
  end
98
98
 
99
- # Browser-specific Coverage implementation, only available for Chromium atm. See
100
- # `ChromiumCoverage`(#class-chromiumcoverage) for more details.
101
- def coverage # property
102
- raise NotImplementedError.new('coverage is not implemented yet.')
103
- end
104
-
105
99
  def keyboard # property
106
100
  wrap_impl(@impl.keyboard)
107
101
  end
@@ -114,78 +108,6 @@ module Playwright
114
108
  wrap_impl(@impl.touchscreen)
115
109
  end
116
110
 
117
- # The method finds an element matching the specified selector within the page. If no elements match the selector, the
118
- # return value resolves to `null`.
119
- #
120
- # Shortcut for main frame's [`method: Frame.$`].
121
- def query_selector(selector)
122
- wrap_impl(@impl.query_selector(unwrap_impl(selector)))
123
- end
124
-
125
- # The method finds all elements matching the specified selector within the page. If no elements match the selector, the
126
- # return value resolves to `[]`.
127
- #
128
- # Shortcut for main frame's [`method: Frame.$$`].
129
- def query_selector_all(selector)
130
- wrap_impl(@impl.query_selector_all(unwrap_impl(selector)))
131
- end
132
-
133
- # The method finds an element matching the specified selector within the page and passes it as a first argument to
134
- # `pageFunction`. If no elements match the selector, the method throws an error. Returns the value of `pageFunction`.
135
- #
136
- # If `pageFunction` returns a [Promise], then [`method: Page.$eval`] would wait for the promise to resolve and return its
137
- # value.
138
- #
139
- # Examples:
140
- #
141
- #
142
- # ```js
143
- # const searchValue = await page.$eval('#search', el => el.value);
144
- # const preloadHref = await page.$eval('link[rel=preload]', el => el.href);
145
- # const html = await page.$eval('.main-container', (e, suffix) => e.outerHTML + suffix, 'hello');
146
- # ```
147
- #
148
- # ```python async
149
- # search_value = await page.eval_on_selector("#search", "el => el.value")
150
- # preload_href = await page.eval_on_selector("link[rel=preload]", "el => el.href")
151
- # html = await page.eval_on_selector(".main-container", "(e, suffix) => e.outer_html + suffix", "hello")
152
- # ```
153
- #
154
- # ```python sync
155
- # search_value = page.eval_on_selector("#search", "el => el.value")
156
- # preload_href = page.eval_on_selector("link[rel=preload]", "el => el.href")
157
- # html = page.eval_on_selector(".main-container", "(e, suffix) => e.outer_html + suffix", "hello")
158
- # ```
159
- #
160
- # Shortcut for main frame's [`method: Frame.$eval`].
161
- def eval_on_selector(selector, pageFunction, arg: nil)
162
- wrap_impl(@impl.eval_on_selector(unwrap_impl(selector), unwrap_impl(pageFunction), arg: unwrap_impl(arg)))
163
- end
164
-
165
- # The method finds all elements matching the specified selector within the page and passes an array of matched elements as
166
- # a first argument to `pageFunction`. Returns the result of `pageFunction` invocation.
167
- #
168
- # If `pageFunction` returns a [Promise], then [`method: Page.$$eval`] would wait for the promise to resolve and return its
169
- # value.
170
- #
171
- # Examples:
172
- #
173
- #
174
- # ```js
175
- # const divCounts = await page.$$eval('div', (divs, min) => divs.length >= min, 10);
176
- # ```
177
- #
178
- # ```python async
179
- # div_counts = await page.eval_on_selector_all("div", "(divs, min) => divs.length >= min", 10)
180
- # ```
181
- #
182
- # ```python sync
183
- # div_counts = page.eval_on_selector_all("div", "(divs, min) => divs.length >= min", 10)
184
- # ```
185
- def eval_on_selector_all(selector, pageFunction, arg: nil)
186
- wrap_impl(@impl.eval_on_selector_all(unwrap_impl(selector), unwrap_impl(pageFunction), arg: unwrap_impl(arg)))
187
- end
188
-
189
111
  # Adds a script which would be evaluated in one of the following scenarios:
190
112
  # - Whenever the page is navigated.
191
113
  # - Whenever the child frame is attached or navigated. In this case, the script is evaluated in the context of the newly
@@ -220,8 +142,8 @@ module Playwright
220
142
  #
221
143
  # > NOTE: The order of evaluation of multiple scripts installed via [`method: BrowserContext.addInitScript`] and
222
144
  # [`method: Page.addInitScript`] is not defined.
223
- def add_init_script(script, arg: nil)
224
- raise NotImplementedError.new('add_init_script is not implemented yet.')
145
+ def add_init_script(path: nil, script: nil)
146
+ wrap_impl(@impl.add_init_script(path: unwrap_impl(path), script: unwrap_impl(script)))
225
147
  end
226
148
 
227
149
  # Adds a `<script>` tag into the page with the desired url or content. Returns the added tag when the script's onload
@@ -242,7 +164,7 @@ module Playwright
242
164
 
243
165
  # Brings page to front (activates tab).
244
166
  def bring_to_front
245
- raise NotImplementedError.new('bring_to_front is not implemented yet.')
167
+ wrap_impl(@impl.bring_to_front)
246
168
  end
247
169
 
248
170
  # This method checks an element matching `selector` by performing the following steps:
@@ -261,7 +183,7 @@ module Playwright
261
183
  #
262
184
  # Shortcut for main frame's [`method: Frame.check`].
263
185
  def check(selector, force: nil, noWaitAfter: nil, timeout: nil)
264
- raise NotImplementedError.new('check is not implemented yet.')
186
+ wrap_impl(@impl.check(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
265
187
  end
266
188
 
267
189
  # This method clicks an element matching `selector` by performing the following steps:
@@ -387,7 +309,7 @@ module Playwright
387
309
  # page.dispatch_event("#source", "dragstart", { "dataTransfer": data_transfer })
388
310
  # ```
389
311
  def dispatch_event(selector, type, eventInit: nil, timeout: nil)
390
- raise NotImplementedError.new('dispatch_event is not implemented yet.')
312
+ wrap_impl(@impl.dispatch_event(unwrap_impl(selector), unwrap_impl(type), eventInit: unwrap_impl(eventInit), timeout: unwrap_impl(timeout)))
391
313
  end
392
314
 
393
315
  #
@@ -478,20 +400,76 @@ module Playwright
478
400
  # # → False
479
401
  # page.evaluate("matchMedia('(prefers-color-scheme: no-preference)').matches")
480
402
  # ```
481
- def emulate_media(params)
482
- raise NotImplementedError.new('emulate_media is not implemented yet.')
403
+ def emulate_media(colorScheme: nil, media: nil)
404
+ wrap_impl(@impl.emulate_media(colorScheme: unwrap_impl(colorScheme), media: unwrap_impl(media)))
483
405
  end
484
406
 
485
- # Returns the value of the `pageFunction` invocation.
407
+ # The method finds an element matching the specified selector within the page and passes it as a first argument to
408
+ # `expression`. If no elements match the selector, the method throws an error. Returns the value of `expression`.
409
+ #
410
+ # If `expression` returns a [Promise], then [`method: Page.evalOnSelector`] would wait for the promise to resolve and
411
+ # return its value.
412
+ #
413
+ # Examples:
414
+ #
415
+ #
416
+ # ```js
417
+ # const searchValue = await page.$eval('#search', el => el.value);
418
+ # const preloadHref = await page.$eval('link[rel=preload]', el => el.href);
419
+ # const html = await page.$eval('.main-container', (e, suffix) => e.outerHTML + suffix, 'hello');
420
+ # ```
421
+ #
422
+ # ```python async
423
+ # search_value = await page.eval_on_selector("#search", "el => el.value")
424
+ # preload_href = await page.eval_on_selector("link[rel=preload]", "el => el.href")
425
+ # html = await page.eval_on_selector(".main-container", "(e, suffix) => e.outer_html + suffix", "hello")
426
+ # ```
427
+ #
428
+ # ```python sync
429
+ # search_value = page.eval_on_selector("#search", "el => el.value")
430
+ # preload_href = page.eval_on_selector("link[rel=preload]", "el => el.href")
431
+ # html = page.eval_on_selector(".main-container", "(e, suffix) => e.outer_html + suffix", "hello")
432
+ # ```
433
+ #
434
+ # Shortcut for main frame's [`method: Frame.evalOnSelector`].
435
+ def eval_on_selector(selector, expression, arg: nil)
436
+ wrap_impl(@impl.eval_on_selector(unwrap_impl(selector), unwrap_impl(expression), arg: unwrap_impl(arg)))
437
+ end
438
+
439
+ # The method finds all elements matching the specified selector within the page and passes an array of matched elements as
440
+ # a first argument to `expression`. Returns the result of `expression` invocation.
441
+ #
442
+ # If `expression` returns a [Promise], then [`method: Page.evalOnSelectorAll`] would wait for the promise to resolve and
443
+ # return its value.
444
+ #
445
+ # Examples:
446
+ #
447
+ #
448
+ # ```js
449
+ # const divCounts = await page.$$eval('div', (divs, min) => divs.length >= min, 10);
450
+ # ```
451
+ #
452
+ # ```python async
453
+ # div_counts = await page.eval_on_selector_all("div", "(divs, min) => divs.length >= min", 10)
454
+ # ```
455
+ #
456
+ # ```python sync
457
+ # div_counts = page.eval_on_selector_all("div", "(divs, min) => divs.length >= min", 10)
458
+ # ```
459
+ def eval_on_selector_all(selector, expression, arg: nil)
460
+ wrap_impl(@impl.eval_on_selector_all(unwrap_impl(selector), unwrap_impl(expression), arg: unwrap_impl(arg)))
461
+ end
462
+
463
+ # Returns the value of the `expression` invocation.
486
464
  #
487
465
  # If the function passed to the [`method: Page.evaluate`] returns a [Promise], then [`method: Page.evaluate`] would wait
488
466
  # for the promise to resolve and return its value.
489
467
  #
490
- # If the function passed to the [`method: Page.evaluate`] returns a non-[Serializable] value,
491
- # then[ method: `Page.evaluate`] resolves to `undefined`. DevTools Protocol also supports transferring some additional
492
- # values that are not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`, and bigint literals.
468
+ # If the function passed to the [`method: Page.evaluate`] returns a non-[Serializable] value, then
469
+ # [`method: Page.evaluate`] resolves to `undefined`. Playwright also supports transferring some additional values that are
470
+ # not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`.
493
471
  #
494
- # Passing argument to `pageFunction`:
472
+ # Passing argument to `expression`:
495
473
  #
496
474
  #
497
475
  # ```js
@@ -554,14 +532,14 @@ module Playwright
554
532
  # ```
555
533
  #
556
534
  # Shortcut for main frame's [`method: Frame.evaluate`].
557
- def evaluate(pageFunction, arg: nil)
558
- wrap_impl(@impl.evaluate(unwrap_impl(pageFunction), arg: unwrap_impl(arg)))
535
+ def evaluate(expression, arg: nil)
536
+ wrap_impl(@impl.evaluate(unwrap_impl(expression), arg: unwrap_impl(arg)))
559
537
  end
560
538
 
561
- # Returns the value of the `pageFunction` invocation as in-page object (JSHandle).
539
+ # Returns the value of the `expression` invocation as a `JSHandle`.
562
540
  #
563
541
  # The only difference between [`method: Page.evaluate`] and [`method: Page.evaluateHandle`] is that
564
- # [`method: Page.evaluateHandle`] returns in-page object (JSHandle).
542
+ # [`method: Page.evaluateHandle`] returns `JSHandle`.
565
543
  #
566
544
  # If the function passed to the [`method: Page.evaluateHandle`] returns a [Promise], then [`method: Page.evaluateHandle`]
567
545
  # would wait for the promise to resolve and return its value.
@@ -573,7 +551,6 @@ module Playwright
573
551
  # ```
574
552
  #
575
553
  # ```python async
576
- # # FIXME
577
554
  # a_window_handle = await page.evaluate_handle("Promise.resolve(window)")
578
555
  # a_window_handle # handle for the window object.
579
556
  # ```
@@ -621,8 +598,8 @@ module Playwright
621
598
  # print(result_handle.json_value())
622
599
  # result_handle.dispose()
623
600
  # ```
624
- def evaluate_handle(pageFunction, arg: nil)
625
- wrap_impl(@impl.evaluate_handle(unwrap_impl(pageFunction), arg: unwrap_impl(arg)))
601
+ def evaluate_handle(expression, arg: nil)
602
+ wrap_impl(@impl.evaluate_handle(unwrap_impl(expression), arg: unwrap_impl(arg)))
626
603
  end
627
604
 
628
605
  # The method adds a function called `name` on the `window` object of every frame in this page. When called, the function
@@ -755,7 +732,7 @@ module Playwright
755
732
  # """)
756
733
  # ```
757
734
  def expose_binding(name, callback, handle: nil)
758
- raise NotImplementedError.new('expose_binding is not implemented yet.')
735
+ wrap_impl(@impl.expose_binding(unwrap_impl(name), unwrap_impl(callback), handle: unwrap_impl(handle)))
759
736
  end
760
737
 
761
738
  # The method adds a function called `name` on the `window` object of every frame in the page. When called, the function
@@ -854,13 +831,14 @@ module Playwright
854
831
  # run(playwright)
855
832
  # ```
856
833
  def expose_function(name, callback)
857
- raise NotImplementedError.new('expose_function is not implemented yet.')
834
+ wrap_impl(@impl.expose_function(unwrap_impl(name), unwrap_impl(callback)))
858
835
  end
859
836
 
860
837
  # This method waits for an element matching `selector`, waits for [actionability](./actionability.md) checks, focuses the
861
- # element, fills it and triggers an `input` event after filling. If the element matching `selector` is not an `<input>`,
862
- # `<textarea>` or `[contenteditable]` element, this method throws an error. Note that you can pass an empty string to
863
- # clear the input field.
838
+ # element, fills it and triggers an `input` event after filling. If the element is inside the `<label>` element that has
839
+ # associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), that control will be
840
+ # filled instead. If the element to be filled is not an `<input>`, `<textarea>` or `[contenteditable]` element, this
841
+ # method throws an error. Note that you can pass an empty string to clear the input field.
864
842
  #
865
843
  # To send fine-grained keyboard events, use [`method: Page.type`].
866
844
  #
@@ -896,8 +874,8 @@ module Playwright
896
874
  # ```py
897
875
  # frame = page.frame(url=r".*domain.*")
898
876
  # ```
899
- def frame(frameSelector)
900
- wrap_impl(@impl.frame(unwrap_impl(frameSelector)))
877
+ def frame(name: nil, url: nil)
878
+ wrap_impl(@impl.frame(name: unwrap_impl(name), url: unwrap_impl(url)))
901
879
  end
902
880
 
903
881
  # An array of all frames attached to the page.
@@ -907,7 +885,7 @@ module Playwright
907
885
 
908
886
  # Returns element attribute value.
909
887
  def get_attribute(selector, name, timeout: nil)
910
- raise NotImplementedError.new('get_attribute is not implemented yet.')
888
+ wrap_impl(@impl.get_attribute(unwrap_impl(selector), unwrap_impl(name), timeout: unwrap_impl(timeout)))
911
889
  end
912
890
 
913
891
  # Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
@@ -915,7 +893,7 @@ module Playwright
915
893
  #
916
894
  # Navigate to the previous page in history.
917
895
  def go_back(timeout: nil, waitUntil: nil)
918
- raise NotImplementedError.new('go_back is not implemented yet.')
896
+ wrap_impl(@impl.go_back(timeout: unwrap_impl(timeout), waitUntil: unwrap_impl(waitUntil)))
919
897
  end
920
898
 
921
899
  # Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
@@ -923,7 +901,7 @@ module Playwright
923
901
  #
924
902
  # Navigate to the next page in history.
925
903
  def go_forward(timeout: nil, waitUntil: nil)
926
- raise NotImplementedError.new('go_forward is not implemented yet.')
904
+ wrap_impl(@impl.go_forward(timeout: unwrap_impl(timeout), waitUntil: unwrap_impl(waitUntil)))
927
905
  end
928
906
 
929
907
  # Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
@@ -968,22 +946,22 @@ module Playwright
968
946
  modifiers: nil,
969
947
  position: nil,
970
948
  timeout: nil)
971
- raise NotImplementedError.new('hover is not implemented yet.')
949
+ wrap_impl(@impl.hover(unwrap_impl(selector), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
972
950
  end
973
951
 
974
952
  # Returns `element.innerHTML`.
975
953
  def inner_html(selector, timeout: nil)
976
- raise NotImplementedError.new('inner_html is not implemented yet.')
954
+ wrap_impl(@impl.inner_html(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
977
955
  end
978
956
 
979
957
  # Returns `element.innerText`.
980
958
  def inner_text(selector, timeout: nil)
981
- raise NotImplementedError.new('inner_text is not implemented yet.')
959
+ wrap_impl(@impl.inner_text(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
982
960
  end
983
961
 
984
962
  # Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
985
963
  def checked?(selector, timeout: nil)
986
- raise NotImplementedError.new('checked? is not implemented yet.')
964
+ wrap_impl(@impl.checked?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
987
965
  end
988
966
 
989
967
  # Indicates that the page has been closed.
@@ -993,27 +971,29 @@ module Playwright
993
971
 
994
972
  # Returns whether the element is disabled, the opposite of [enabled](./actionability.md#enabled).
995
973
  def disabled?(selector, timeout: nil)
996
- raise NotImplementedError.new('disabled? is not implemented yet.')
974
+ wrap_impl(@impl.disabled?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
997
975
  end
998
976
 
999
977
  # Returns whether the element is [editable](./actionability.md#editable).
1000
978
  def editable?(selector, timeout: nil)
1001
- raise NotImplementedError.new('editable? is not implemented yet.')
979
+ wrap_impl(@impl.editable?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
1002
980
  end
1003
981
 
1004
982
  # Returns whether the element is [enabled](./actionability.md#enabled).
1005
983
  def enabled?(selector, timeout: nil)
1006
- raise NotImplementedError.new('enabled? is not implemented yet.')
984
+ wrap_impl(@impl.enabled?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
1007
985
  end
1008
986
 
1009
- # Returns whether the element is hidden, the opposite of [visible](./actionability.md#visible).
987
+ # Returns whether the element is hidden, the opposite of [visible](./actionability.md#visible). `selector` that does not
988
+ # match any elements is considered hidden.
1010
989
  def hidden?(selector, timeout: nil)
1011
- raise NotImplementedError.new('hidden? is not implemented yet.')
990
+ wrap_impl(@impl.hidden?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
1012
991
  end
1013
992
 
1014
- # Returns whether the element is [visible](./actionability.md#visible).
993
+ # Returns whether the element is [visible](./actionability.md#visible). `selector` that does not match any elements is
994
+ # considered not visible.
1015
995
  def visible?(selector, timeout: nil)
1016
- raise NotImplementedError.new('visible? is not implemented yet.')
996
+ wrap_impl(@impl.visible?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
1017
997
  end
1018
998
 
1019
999
  # The page's main frame. Page is guaranteed to have a main frame which persists during navigations.
@@ -1026,6 +1006,18 @@ module Playwright
1026
1006
  wrap_impl(@impl.opener)
1027
1007
  end
1028
1008
 
1009
+ # Pauses script execution. Playwright will stop executing the script and wait for the user to either press 'Resume' button
1010
+ # in the page overlay or to call `playwright.resume()` in the DevTools console.
1011
+ #
1012
+ # User can inspect selectors or perform manual steps while paused. Resume will continue running the original script from
1013
+ # the place it was paused.
1014
+ #
1015
+ # > NOTE: This method requires Playwright to be started in a headed mode, with a falsy `headless` value in the
1016
+ # [`method: BrowserType.launch`].
1017
+ def pause
1018
+ raise NotImplementedError.new('pause is not implemented yet.')
1019
+ end
1020
+
1029
1021
  # Returns the PDF buffer.
1030
1022
  #
1031
1023
  # > NOTE: Generating a pdf is currently only supported in Chromium headless.
@@ -1098,7 +1090,7 @@ module Playwright
1098
1090
  printBackground: nil,
1099
1091
  scale: nil,
1100
1092
  width: nil)
1101
- raise NotImplementedError.new('pdf is not implemented yet.')
1093
+ wrap_impl(@impl.pdf(displayHeaderFooter: unwrap_impl(displayHeaderFooter), footerTemplate: unwrap_impl(footerTemplate), format: unwrap_impl(format), headerTemplate: unwrap_impl(headerTemplate), height: unwrap_impl(height), landscape: unwrap_impl(landscape), margin: unwrap_impl(margin), pageRanges: unwrap_impl(pageRanges), path: unwrap_impl(path), preferCSSPageSize: unwrap_impl(preferCSSPageSize), printBackground: unwrap_impl(printBackground), scale: unwrap_impl(scale), width: unwrap_impl(width)))
1102
1094
  end
1103
1095
 
1104
1096
  # Focuses the element, and then uses [`method: Keyboard.down`] and [`method: Keyboard.up`].
@@ -1165,6 +1157,22 @@ module Playwright
1165
1157
  wrap_impl(@impl.press(unwrap_impl(selector), unwrap_impl(key), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
1166
1158
  end
1167
1159
 
1160
+ # The method finds an element matching the specified selector within the page. If no elements match the selector, the
1161
+ # return value resolves to `null`.
1162
+ #
1163
+ # Shortcut for main frame's [`method: Frame.querySelector`].
1164
+ def query_selector(selector)
1165
+ wrap_impl(@impl.query_selector(unwrap_impl(selector)))
1166
+ end
1167
+
1168
+ # The method finds all elements matching the specified selector within the page. If no elements match the selector, the
1169
+ # return value resolves to `[]`.
1170
+ #
1171
+ # Shortcut for main frame's [`method: Frame.querySelectorAll`].
1172
+ def query_selector_all(selector)
1173
+ wrap_impl(@impl.query_selector_all(unwrap_impl(selector)))
1174
+ end
1175
+
1168
1176
  # Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
1169
1177
  # last redirect.
1170
1178
  def reload(timeout: nil, waitUntil: nil)
@@ -1230,7 +1238,7 @@ module Playwright
1230
1238
  #
1231
1239
  # > NOTE: Enabling routing disables http cache.
1232
1240
  def route(url, handler)
1233
- raise NotImplementedError.new('route is not implemented yet.')
1241
+ wrap_impl(@impl.route(unwrap_impl(url), unwrap_impl(handler)))
1234
1242
  end
1235
1243
 
1236
1244
  # Returns the buffer with the captured screenshot.
@@ -1287,8 +1295,15 @@ module Playwright
1287
1295
  # ```
1288
1296
  #
1289
1297
  # Shortcut for main frame's [`method: Frame.selectOption`]
1290
- def select_option(selector, values, noWaitAfter: nil, timeout: nil)
1291
- raise NotImplementedError.new('select_option is not implemented yet.')
1298
+ def select_option(
1299
+ selector,
1300
+ element: nil,
1301
+ index: nil,
1302
+ value: nil,
1303
+ label: nil,
1304
+ noWaitAfter: nil,
1305
+ timeout: nil)
1306
+ 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)))
1292
1307
  end
1293
1308
 
1294
1309
  def set_content(html, timeout: nil, waitUntil: nil)
@@ -1323,7 +1338,7 @@ module Playwright
1323
1338
  #
1324
1339
  # > NOTE: [`method: Page.setExtraHTTPHeaders`] does not guarantee the order of headers in the outgoing requests.
1325
1340
  def set_extra_http_headers(headers)
1326
- raise NotImplementedError.new('set_extra_http_headers is not implemented yet.')
1341
+ wrap_impl(@impl.set_extra_http_headers(unwrap_impl(headers)))
1327
1342
  end
1328
1343
  alias_method :extra_http_headers=, :set_extra_http_headers
1329
1344
 
@@ -1333,7 +1348,7 @@ module Playwright
1333
1348
  # Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
1334
1349
  # are resolved relative to the the current working directory. For empty array, clears the selected files.
1335
1350
  def set_input_files(selector, files, noWaitAfter: nil, timeout: nil)
1336
- raise NotImplementedError.new('set_input_files is not implemented yet.')
1351
+ wrap_impl(@impl.set_input_files(unwrap_impl(selector), unwrap_impl(files), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
1337
1352
  end
1338
1353
 
1339
1354
  # In the case of multiple pages in a single browser, each page can have its own viewport size. However,
@@ -1389,12 +1404,12 @@ module Playwright
1389
1404
  noWaitAfter: nil,
1390
1405
  position: nil,
1391
1406
  timeout: nil)
1392
- raise NotImplementedError.new('tap_point is not implemented yet.')
1407
+ 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)))
1393
1408
  end
1394
1409
 
1395
1410
  # Returns `element.textContent`.
1396
1411
  def text_content(selector, timeout: nil)
1397
- raise NotImplementedError.new('text_content is not implemented yet.')
1412
+ wrap_impl(@impl.text_content(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
1398
1413
  end
1399
1414
 
1400
1415
  # Returns the page's title. Shortcut for main frame's [`method: Frame.title`].
@@ -1449,12 +1464,12 @@ module Playwright
1449
1464
  #
1450
1465
  # Shortcut for main frame's [`method: Frame.uncheck`].
1451
1466
  def uncheck(selector, force: nil, noWaitAfter: nil, timeout: nil)
1452
- raise NotImplementedError.new('uncheck is not implemented yet.')
1467
+ wrap_impl(@impl.uncheck(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
1453
1468
  end
1454
1469
 
1455
1470
  # Removes a route created with [`method: Page.route`]. When `handler` is not specified, removes all routes for the `url`.
1456
1471
  def unroute(url, handler: nil)
1457
- raise NotImplementedError.new('unroute is not implemented yet.')
1472
+ wrap_impl(@impl.unroute(unwrap_impl(url), handler: unwrap_impl(handler)))
1458
1473
  end
1459
1474
 
1460
1475
  # Shortcut for main frame's [`method: Frame.url`].
@@ -1471,6 +1486,20 @@ module Playwright
1471
1486
  wrap_impl(@impl.viewport_size)
1472
1487
  end
1473
1488
 
1489
+ # Performs action and waits for a [ConoleMessage] to be logged by in the page. If predicate is provided, it passes
1490
+ # `ConsoleMessage` value into the `predicate` function and waits for `predicate(message)` to return a truthy value. Will
1491
+ # throw an error if the page is closed before the console event is fired.
1492
+ def expect_console_message(predicate: nil, timeout: nil, &block)
1493
+ wrap_impl(@impl.expect_console_message(predicate: unwrap_impl(predicate), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
1494
+ end
1495
+
1496
+ # Performs action and waits for a new `Download`. If predicate is provided, it passes `Download` value into the
1497
+ # `predicate` function and waits for `predicate(download)` to return a truthy value. Will throw an error if the page is
1498
+ # closed before the download event is fired.
1499
+ def expect_download(predicate: nil, timeout: nil, &block)
1500
+ wrap_impl(@impl.expect_download(predicate: unwrap_impl(predicate), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
1501
+ end
1502
+
1474
1503
  # Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy
1475
1504
  # value. Will throw an error if the page is closed before the event is fired. Returns the event data value.
1476
1505
  #
@@ -1493,13 +1522,20 @@ module Playwright
1493
1522
  # page.click("button")
1494
1523
  # frame = event_info.value
1495
1524
  # ```
1496
- def expect_event(event, optionsOrPredicate: nil, &block)
1497
- wrap_impl(@impl.expect_event(unwrap_impl(event), optionsOrPredicate: unwrap_impl(optionsOrPredicate), &wrap_block_call(block)))
1525
+ def expect_event(event, predicate: nil, timeout: nil, &block)
1526
+ wrap_impl(@impl.expect_event(unwrap_impl(event), predicate: unwrap_impl(predicate), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
1498
1527
  end
1499
1528
 
1500
- # Returns when the `pageFunction` returns a truthy value. It resolves to a JSHandle of the truthy value.
1529
+ # Performs action and waits for a new `FileChooser` to be created. If predicate is provided, it passes `FileChooser` value
1530
+ # into the `predicate` function and waits for `predicate(fileChooser)` to return a truthy value. Will throw an error if
1531
+ # the page is closed before the file chooser is opened.
1532
+ def expect_file_chooser(predicate: nil, timeout: nil, &block)
1533
+ wrap_impl(@impl.expect_file_chooser(predicate: unwrap_impl(predicate), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
1534
+ end
1535
+
1536
+ # Returns when the `expression` returns a truthy value. It resolves to a JSHandle of the truthy value.
1501
1537
  #
1502
- # The `waitForFunction` can be used to observe viewport size change:
1538
+ # The [`method: Page.waitForFunction`] can be used to observe viewport size change:
1503
1539
  #
1504
1540
  #
1505
1541
  # ```js
@@ -1523,7 +1559,7 @@ module Playwright
1523
1559
  # webkit = playwright.webkit
1524
1560
  # browser = await webkit.launch()
1525
1561
  # page = await browser.new_page()
1526
- # await page.evaluate("window.x = 0; setTimeout(() => { window.x = 100 }, 1000);", force_expr=True)
1562
+ # await page.evaluate("window.x = 0; setTimeout(() => { window.x = 100 }, 1000);")
1527
1563
  # await page.wait_for_function("() => window.x > 0")
1528
1564
  # await browser.close()
1529
1565
  #
@@ -1540,7 +1576,7 @@ module Playwright
1540
1576
  # webkit = playwright.webkit
1541
1577
  # browser = webkit.launch()
1542
1578
  # page = browser.new_page()
1543
- # page.evaluate("window.x = 0; setTimeout(() => { window.x = 100 }, 1000);", force_expr=True)
1579
+ # page.evaluate("window.x = 0; setTimeout(() => { window.x = 100 }, 1000);")
1544
1580
  # page.wait_for_function("() => window.x > 0")
1545
1581
  # browser.close()
1546
1582
  #
@@ -1567,8 +1603,8 @@ module Playwright
1567
1603
  # ```
1568
1604
  #
1569
1605
  # Shortcut for main frame's [`method: Frame.waitForFunction`].
1570
- def wait_for_function(pageFunction, arg: nil, polling: nil, timeout: nil)
1571
- wrap_impl(@impl.wait_for_function(unwrap_impl(pageFunction), arg: unwrap_impl(arg), polling: unwrap_impl(polling), timeout: unwrap_impl(timeout)))
1606
+ def wait_for_function(expression, arg: nil, polling: nil, timeout: nil)
1607
+ wrap_impl(@impl.wait_for_function(unwrap_impl(expression), arg: unwrap_impl(arg), polling: unwrap_impl(polling), timeout: unwrap_impl(timeout)))
1572
1608
  end
1573
1609
 
1574
1610
  # Returns when the required load state has been reached.
@@ -1661,6 +1697,13 @@ module Playwright
1661
1697
  wrap_impl(@impl.expect_navigation(timeout: unwrap_impl(timeout), url: unwrap_impl(url), waitUntil: unwrap_impl(waitUntil), &wrap_block_call(block)))
1662
1698
  end
1663
1699
 
1700
+ # Performs action and waits for a popup `Page`. If predicate is provided, it passes [Popup] value into the `predicate`
1701
+ # function and waits for `predicate(page)` to return a truthy value. Will throw an error if the page is closed before the
1702
+ # popup event is fired.
1703
+ def expect_popup(predicate: nil, timeout: nil, &block)
1704
+ wrap_impl(@impl.expect_popup(predicate: unwrap_impl(predicate), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
1705
+ end
1706
+
1664
1707
  # Waits for the matching request and returns it.
1665
1708
  #
1666
1709
  #
@@ -1784,7 +1827,7 @@ module Playwright
1784
1827
  # run(playwright)
1785
1828
  # ```
1786
1829
  def wait_for_selector(selector, state: nil, timeout: nil)
1787
- raise NotImplementedError.new('wait_for_selector is not implemented yet.')
1830
+ wrap_impl(@impl.wait_for_selector(unwrap_impl(selector), state: unwrap_impl(state), timeout: unwrap_impl(timeout)))
1788
1831
  end
1789
1832
 
1790
1833
  # Waits for the given `timeout` in milliseconds.
@@ -1813,6 +1856,13 @@ module Playwright
1813
1856
  raise NotImplementedError.new('wait_for_timeout is not implemented yet.')
1814
1857
  end
1815
1858
 
1859
+ # Performs action and waits for a new `Worker`. If predicate is provided, it passes `Worker` value into the `predicate`
1860
+ # function and waits for `predicate(worker)` to return a truthy value. Will throw an error if the page is closed before
1861
+ # the worker event is fired.
1862
+ def expect_worker(predicate: nil, timeout: nil)
1863
+ raise NotImplementedError.new('expect_worker is not implemented yet.')
1864
+ end
1865
+
1816
1866
  # This method returns all of the dedicated [WebWorkers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API)
1817
1867
  # associated with the page.
1818
1868
  #
@@ -1821,9 +1871,13 @@ module Playwright
1821
1871
  raise NotImplementedError.new('workers is not implemented yet.')
1822
1872
  end
1823
1873
 
1824
- # @nodoc
1825
- def after_initialize
1826
- wrap_impl(@impl.after_initialize)
1874
+ # > NOTE: In most cases, you should use [`method: Page.waitForEvent`].
1875
+ #
1876
+ # Waits for given `event` to fire. If predicate is provided, it passes event's value into the `predicate` function and
1877
+ # waits for `predicate(event)` to return a truthy value. Will throw an error if the socket is closed before the `event` is
1878
+ # fired.
1879
+ def wait_for_event(event, predicate: nil, timeout: nil)
1880
+ raise NotImplementedError.new('wait_for_event is not implemented yet.')
1827
1881
  end
1828
1882
 
1829
1883
  # @nodoc
@@ -1833,20 +1887,24 @@ module Playwright
1833
1887
 
1834
1888
  # -- inherited from EventEmitter --
1835
1889
  # @nodoc
1836
- def on(event, callback)
1837
- wrap_impl(@impl.on(unwrap_impl(event), unwrap_impl(callback)))
1890
+ def off(event, callback)
1891
+ event_emitter_proxy.off(event, callback)
1838
1892
  end
1839
1893
 
1840
1894
  # -- inherited from EventEmitter --
1841
1895
  # @nodoc
1842
- def off(event, callback)
1843
- wrap_impl(@impl.off(unwrap_impl(event), unwrap_impl(callback)))
1896
+ def once(event, callback)
1897
+ event_emitter_proxy.once(event, callback)
1844
1898
  end
1845
1899
 
1846
1900
  # -- inherited from EventEmitter --
1847
1901
  # @nodoc
1848
- def once(event, callback)
1849
- wrap_impl(@impl.once(unwrap_impl(event), unwrap_impl(callback)))
1902
+ def on(event, callback)
1903
+ event_emitter_proxy.on(event, callback)
1904
+ end
1905
+
1906
+ private def event_emitter_proxy
1907
+ @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
1850
1908
  end
1851
1909
  end
1852
1910
  end