playwright-ruby-client 0.0.8 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -1,25 +1,29 @@
1
1
  module Playwright
2
- # @nodoc
3
2
  class AndroidInput < PlaywrightApi
4
3
 
5
- # @nodoc
6
- def type(text)
7
- wrap_impl(@impl.type(unwrap_impl(text)))
8
- end
9
-
10
- # @nodoc
11
- def tap_point(point)
12
- wrap_impl(@impl.tap_point(unwrap_impl(point)))
4
+ # Performs a drag between `from` and `to` points.
5
+ def drag(from, to, steps)
6
+ wrap_impl(@impl.drag(unwrap_impl(from), unwrap_impl(to), unwrap_impl(steps)))
13
7
  end
14
8
 
15
- # @nodoc
9
+ # Presses the `key`.
16
10
  def press(key)
17
11
  wrap_impl(@impl.press(unwrap_impl(key)))
18
12
  end
19
13
 
20
- # @nodoc
21
- def drag(from, to, steps)
22
- wrap_impl(@impl.drag(unwrap_impl(from), unwrap_impl(to), unwrap_impl(steps)))
14
+ # Swipes following the path defined by `segments`.
15
+ def swipe(from, segments, steps)
16
+ raise NotImplementedError.new('swipe is not implemented yet.')
17
+ end
18
+
19
+ # Taps at the specified `point`.
20
+ def tap_point(point)
21
+ wrap_impl(@impl.tap_point(unwrap_impl(point)))
22
+ end
23
+
24
+ # Types `text` into currently focused widget.
25
+ def type(text)
26
+ wrap_impl(@impl.type(unwrap_impl(text)))
23
27
  end
24
28
  end
25
29
  end
@@ -0,0 +1,16 @@
1
+ module Playwright
2
+ # `AndroidSocket` is a way to communicate with a process launched on the `AndroidDevice`. Use
3
+ # [`method: AndroidDevice.open`] to open a socket.
4
+ class AndroidSocket < PlaywrightApi
5
+
6
+ # Closes the socket.
7
+ def close
8
+ raise NotImplementedError.new('close is not implemented yet.')
9
+ end
10
+
11
+ # Writes some `data` to the socket.
12
+ def write(data)
13
+ raise NotImplementedError.new('write is not implemented yet.')
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,21 @@
1
+ module Playwright
2
+ # `AndroidWebView` represents a WebView open on the `AndroidDevice`. WebView is usually obtained using
3
+ # [`method: AndroidDevice.webView`].
4
+ class AndroidWebView < PlaywrightApi
5
+
6
+ # Connects to the WebView and returns a regular Playwright `Page` to interact with.
7
+ def page
8
+ raise NotImplementedError.new('page is not implemented yet.')
9
+ end
10
+
11
+ # WebView process PID.
12
+ def pid
13
+ raise NotImplementedError.new('pid is not implemented yet.')
14
+ end
15
+
16
+ # WebView package identifier.
17
+ def pkg
18
+ raise NotImplementedError.new('pkg is not implemented yet.')
19
+ end
20
+ end
21
+ end
@@ -2,22 +2,31 @@ module Playwright
2
2
  # @nodoc
3
3
  class BindingCall < PlaywrightApi
4
4
 
5
- # -- inherited from EventEmitter --
6
5
  # @nodoc
7
- def on(event, callback)
8
- wrap_impl(@impl.on(unwrap_impl(event), unwrap_impl(callback)))
6
+ def name
7
+ wrap_impl(@impl.name)
9
8
  end
10
9
 
11
10
  # -- inherited from EventEmitter --
12
11
  # @nodoc
13
12
  def off(event, callback)
14
- wrap_impl(@impl.off(unwrap_impl(event), unwrap_impl(callback)))
13
+ event_emitter_proxy.off(event, callback)
15
14
  end
16
15
 
17
16
  # -- inherited from EventEmitter --
18
17
  # @nodoc
19
18
  def once(event, callback)
20
- wrap_impl(@impl.once(unwrap_impl(event), unwrap_impl(callback)))
19
+ event_emitter_proxy.once(event, callback)
20
+ end
21
+
22
+ # -- inherited from EventEmitter --
23
+ # @nodoc
24
+ def on(event, callback)
25
+ event_emitter_proxy.on(event, callback)
26
+ end
27
+
28
+ private def event_emitter_proxy
29
+ @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
21
30
  end
22
31
  end
23
32
  end
@@ -1,7 +1,7 @@
1
1
  module Playwright
2
2
  # - extends: [EventEmitter]
3
3
  #
4
- # A Browser is created via [`method: BrowserType.launch`]. An example of using a `Browser` to create a [Page]:
4
+ # A Browser is created via [`method: BrowserType.launch`]. An example of using a `Browser` to create a `Page`:
5
5
  #
6
6
  #
7
7
  # ```js
@@ -135,20 +135,20 @@ module Playwright
135
135
  isMobile: nil,
136
136
  javaScriptEnabled: nil,
137
137
  locale: nil,
138
- logger: nil,
138
+ noViewport: nil,
139
139
  offline: nil,
140
140
  permissions: nil,
141
141
  proxy: nil,
142
- recordHar: nil,
143
- recordVideo: nil,
142
+ record_har_omit_content: nil,
143
+ record_har_path: nil,
144
+ record_video_dir: nil,
145
+ record_video_size: nil,
144
146
  storageState: nil,
145
147
  timezoneId: nil,
146
148
  userAgent: nil,
147
- videoSize: nil,
148
- videosPath: nil,
149
149
  viewport: nil,
150
150
  &block)
151
- wrap_impl(@impl.new_context(acceptDownloads: unwrap_impl(acceptDownloads), bypassCSP: unwrap_impl(bypassCSP), colorScheme: unwrap_impl(colorScheme), deviceScaleFactor: unwrap_impl(deviceScaleFactor), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), geolocation: unwrap_impl(geolocation), hasTouch: unwrap_impl(hasTouch), httpCredentials: unwrap_impl(httpCredentials), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), isMobile: unwrap_impl(isMobile), javaScriptEnabled: unwrap_impl(javaScriptEnabled), locale: unwrap_impl(locale), logger: unwrap_impl(logger), offline: unwrap_impl(offline), permissions: unwrap_impl(permissions), proxy: unwrap_impl(proxy), recordHar: unwrap_impl(recordHar), recordVideo: unwrap_impl(recordVideo), storageState: unwrap_impl(storageState), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), videoSize: unwrap_impl(videoSize), videosPath: unwrap_impl(videosPath), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
151
+ wrap_impl(@impl.new_context(acceptDownloads: unwrap_impl(acceptDownloads), bypassCSP: unwrap_impl(bypassCSP), colorScheme: unwrap_impl(colorScheme), deviceScaleFactor: unwrap_impl(deviceScaleFactor), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), geolocation: unwrap_impl(geolocation), hasTouch: unwrap_impl(hasTouch), httpCredentials: unwrap_impl(httpCredentials), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), isMobile: unwrap_impl(isMobile), javaScriptEnabled: unwrap_impl(javaScriptEnabled), locale: unwrap_impl(locale), noViewport: unwrap_impl(noViewport), offline: unwrap_impl(offline), permissions: unwrap_impl(permissions), proxy: unwrap_impl(proxy), record_har_omit_content: unwrap_impl(record_har_omit_content), record_har_path: unwrap_impl(record_har_path), record_video_dir: unwrap_impl(record_video_dir), record_video_size: unwrap_impl(record_video_size), storageState: unwrap_impl(storageState), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
152
152
  end
153
153
 
154
154
  # Creates a new page in a new browser context. Closing this page will close the context as well.
@@ -169,19 +169,19 @@ module Playwright
169
169
  isMobile: nil,
170
170
  javaScriptEnabled: nil,
171
171
  locale: nil,
172
- logger: nil,
172
+ noViewport: nil,
173
173
  offline: nil,
174
174
  permissions: nil,
175
175
  proxy: nil,
176
- recordHar: nil,
177
- recordVideo: nil,
176
+ record_har_omit_content: nil,
177
+ record_har_path: nil,
178
+ record_video_dir: nil,
179
+ record_video_size: nil,
178
180
  storageState: nil,
179
181
  timezoneId: nil,
180
182
  userAgent: nil,
181
- videoSize: nil,
182
- videosPath: nil,
183
183
  viewport: nil)
184
- wrap_impl(@impl.new_page(acceptDownloads: unwrap_impl(acceptDownloads), bypassCSP: unwrap_impl(bypassCSP), colorScheme: unwrap_impl(colorScheme), deviceScaleFactor: unwrap_impl(deviceScaleFactor), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), geolocation: unwrap_impl(geolocation), hasTouch: unwrap_impl(hasTouch), httpCredentials: unwrap_impl(httpCredentials), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), isMobile: unwrap_impl(isMobile), javaScriptEnabled: unwrap_impl(javaScriptEnabled), locale: unwrap_impl(locale), logger: unwrap_impl(logger), offline: unwrap_impl(offline), permissions: unwrap_impl(permissions), proxy: unwrap_impl(proxy), recordHar: unwrap_impl(recordHar), recordVideo: unwrap_impl(recordVideo), storageState: unwrap_impl(storageState), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), videoSize: unwrap_impl(videoSize), videosPath: unwrap_impl(videosPath), viewport: unwrap_impl(viewport)))
184
+ wrap_impl(@impl.new_page(acceptDownloads: unwrap_impl(acceptDownloads), bypassCSP: unwrap_impl(bypassCSP), colorScheme: unwrap_impl(colorScheme), deviceScaleFactor: unwrap_impl(deviceScaleFactor), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), geolocation: unwrap_impl(geolocation), hasTouch: unwrap_impl(hasTouch), httpCredentials: unwrap_impl(httpCredentials), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), isMobile: unwrap_impl(isMobile), javaScriptEnabled: unwrap_impl(javaScriptEnabled), locale: unwrap_impl(locale), noViewport: unwrap_impl(noViewport), offline: unwrap_impl(offline), permissions: unwrap_impl(permissions), proxy: unwrap_impl(proxy), record_har_omit_content: unwrap_impl(record_har_omit_content), record_har_path: unwrap_impl(record_har_path), record_video_dir: unwrap_impl(record_video_dir), record_video_size: unwrap_impl(record_video_size), storageState: unwrap_impl(storageState), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport)))
185
185
  end
186
186
 
187
187
  # Returns the browser version.
@@ -189,27 +189,26 @@ module Playwright
189
189
  wrap_impl(@impl.version)
190
190
  end
191
191
 
192
+ # -- inherited from EventEmitter --
192
193
  # @nodoc
193
- def after_initialize
194
- wrap_impl(@impl.after_initialize)
194
+ def off(event, callback)
195
+ event_emitter_proxy.off(event, callback)
195
196
  end
196
197
 
197
198
  # -- inherited from EventEmitter --
198
199
  # @nodoc
199
- def on(event, callback)
200
- wrap_impl(@impl.on(unwrap_impl(event), unwrap_impl(callback)))
200
+ def once(event, callback)
201
+ event_emitter_proxy.once(event, callback)
201
202
  end
202
203
 
203
204
  # -- inherited from EventEmitter --
204
205
  # @nodoc
205
- def off(event, callback)
206
- wrap_impl(@impl.off(unwrap_impl(event), unwrap_impl(callback)))
206
+ def on(event, callback)
207
+ event_emitter_proxy.on(event, callback)
207
208
  end
208
209
 
209
- # -- inherited from EventEmitter --
210
- # @nodoc
211
- def once(event, callback)
212
- wrap_impl(@impl.once(unwrap_impl(event), unwrap_impl(callback)))
210
+ private def event_emitter_proxy
211
+ @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
213
212
  end
214
213
  end
215
214
  end
@@ -57,7 +57,7 @@ module Playwright
57
57
  # browser_context.add_cookies([cookie_object1, cookie_object2])
58
58
  # ```
59
59
  def add_cookies(cookies)
60
- raise NotImplementedError.new('add_cookies is not implemented yet.')
60
+ wrap_impl(@impl.add_cookies(unwrap_impl(cookies)))
61
61
  end
62
62
 
63
63
  # Adds a script which would be evaluated in one of the following scenarios:
@@ -96,18 +96,18 @@ module Playwright
96
96
  #
97
97
  # > NOTE: The order of evaluation of multiple scripts installed via [`method: BrowserContext.addInitScript`] and
98
98
  # [`method: Page.addInitScript`] is not defined.
99
- def add_init_script(script, arg: nil)
100
- raise NotImplementedError.new('add_init_script is not implemented yet.')
99
+ def add_init_script(path: nil, script: nil)
100
+ wrap_impl(@impl.add_init_script(path: unwrap_impl(path), script: unwrap_impl(script)))
101
101
  end
102
102
 
103
103
  # Returns the browser instance of the context. If it was launched as a persistent context null gets returned.
104
104
  def browser
105
- raise NotImplementedError.new('browser is not implemented yet.')
105
+ wrap_impl(@impl.browser)
106
106
  end
107
107
 
108
108
  # Clears context cookies.
109
109
  def clear_cookies
110
- raise NotImplementedError.new('clear_cookies is not implemented yet.')
110
+ wrap_impl(@impl.clear_cookies)
111
111
  end
112
112
 
113
113
  # Clears all permission overrides for the browser context.
@@ -134,7 +134,7 @@ module Playwright
134
134
  # context.clear_permissions()
135
135
  # ```
136
136
  def clear_permissions
137
- raise NotImplementedError.new('clear_permissions is not implemented yet.')
137
+ wrap_impl(@impl.clear_permissions)
138
138
  end
139
139
 
140
140
  # Closes the browser context. All the pages that belong to the browser context will be closed.
@@ -147,7 +147,7 @@ module Playwright
147
147
  # If no URLs are specified, this method returns all cookies. If URLs are specified, only cookies that affect those URLs
148
148
  # are returned.
149
149
  def cookies(urls: nil)
150
- raise NotImplementedError.new('cookies is not implemented yet.')
150
+ wrap_impl(@impl.cookies(urls: unwrap_impl(urls)))
151
151
  end
152
152
 
153
153
  # The method adds a function called `name` on the `window` object of every frame in every page in the context. When
@@ -278,7 +278,7 @@ module Playwright
278
278
  # """)
279
279
  # ```
280
280
  def expose_binding(name, callback, handle: nil)
281
- raise NotImplementedError.new('expose_binding is not implemented yet.')
281
+ wrap_impl(@impl.expose_binding(unwrap_impl(name), unwrap_impl(callback), handle: unwrap_impl(handle)))
282
282
  end
283
283
 
284
284
  # The method adds a function called `name` on the `window` object of every frame in every page in the context. When
@@ -379,13 +379,13 @@ module Playwright
379
379
  # run(playwright)
380
380
  # ```
381
381
  def expose_function(name, callback)
382
- raise NotImplementedError.new('expose_function is not implemented yet.')
382
+ wrap_impl(@impl.expose_function(unwrap_impl(name), unwrap_impl(callback)))
383
383
  end
384
384
 
385
385
  # Grants specified permissions to the browser context. Only grants corresponding permissions to the given origin if
386
386
  # specified.
387
387
  def grant_permissions(permissions, origin: nil)
388
- raise NotImplementedError.new('grant_permissions is not implemented yet.')
388
+ wrap_impl(@impl.grant_permissions(unwrap_impl(permissions), origin: unwrap_impl(origin)))
389
389
  end
390
390
 
391
391
  # Creates a new page in the browser context.
@@ -464,7 +464,7 @@ module Playwright
464
464
  #
465
465
  # > NOTE: Enabling routing disables http cache.
466
466
  def route(url, handler)
467
- raise NotImplementedError.new('route is not implemented yet.')
467
+ wrap_impl(@impl.route(unwrap_impl(url), unwrap_impl(handler)))
468
468
  end
469
469
 
470
470
  # This setting will change the default maximum navigation time for the following methods and related shortcuts:
@@ -478,7 +478,7 @@ module Playwright
478
478
  # > NOTE: [`method: Page.setDefaultNavigationTimeout`] and [`method: Page.setDefaultTimeout`] take priority over
479
479
  # [`method: BrowserContext.setDefaultNavigationTimeout`].
480
480
  def set_default_navigation_timeout(timeout)
481
- raise NotImplementedError.new('set_default_navigation_timeout is not implemented yet.')
481
+ wrap_impl(@impl.set_default_navigation_timeout(unwrap_impl(timeout)))
482
482
  end
483
483
  alias_method :default_navigation_timeout=, :set_default_navigation_timeout
484
484
 
@@ -487,7 +487,7 @@ module Playwright
487
487
  # > NOTE: [`method: Page.setDefaultNavigationTimeout`], [`method: Page.setDefaultTimeout`] and
488
488
  # [`method: BrowserContext.setDefaultNavigationTimeout`] take priority over [`method: BrowserContext.setDefaultTimeout`].
489
489
  def set_default_timeout(timeout)
490
- raise NotImplementedError.new('set_default_timeout is not implemented yet.')
490
+ wrap_impl(@impl.set_default_timeout(unwrap_impl(timeout)))
491
491
  end
492
492
  alias_method :default_timeout=, :set_default_timeout
493
493
 
@@ -497,7 +497,7 @@ module Playwright
497
497
  #
498
498
  # > NOTE: [`method: BrowserContext.setExtraHTTPHeaders`] does not guarantee the order of headers in the outgoing requests.
499
499
  def set_extra_http_headers(headers)
500
- raise NotImplementedError.new('set_extra_http_headers is not implemented yet.')
500
+ wrap_impl(@impl.set_extra_http_headers(unwrap_impl(headers)))
501
501
  end
502
502
  alias_method :extra_http_headers=, :set_extra_http_headers
503
503
 
@@ -519,18 +519,12 @@ module Playwright
519
519
  # > NOTE: Consider using [`method: BrowserContext.grantPermissions`] to grant permissions for the browser context pages to
520
520
  # read its geolocation.
521
521
  def set_geolocation(geolocation)
522
- raise NotImplementedError.new('set_geolocation is not implemented yet.')
522
+ wrap_impl(@impl.set_geolocation(unwrap_impl(geolocation)))
523
523
  end
524
524
  alias_method :geolocation=, :set_geolocation
525
525
 
526
- # **DEPRECATED** Browsers may cache credentials after successful authentication. Create a new browser context instead.
527
- def set_http_credentials(httpCredentials)
528
- raise NotImplementedError.new('set_http_credentials is not implemented yet.')
529
- end
530
- alias_method :http_credentials=, :set_http_credentials
531
-
532
526
  def set_offline(offline)
533
- raise NotImplementedError.new('set_offline is not implemented yet.')
527
+ wrap_impl(@impl.set_offline(unwrap_impl(offline)))
534
528
  end
535
529
  alias_method :offline=, :set_offline
536
530
 
@@ -542,7 +536,7 @@ module Playwright
542
536
  # Removes a route created with [`method: BrowserContext.route`]. When `handler` is not specified, removes all routes for
543
537
  # the `url`.
544
538
  def unroute(url, handler: nil)
545
- raise NotImplementedError.new('unroute is not implemented yet.')
539
+ wrap_impl(@impl.unroute(unwrap_impl(url), handler: unwrap_impl(handler)))
546
540
  end
547
541
 
548
542
  # Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy
@@ -567,18 +561,29 @@ module Playwright
567
561
  # page.click("button")
568
562
  # page = event_info.value
569
563
  # ```
570
- def expect_event(event, optionsOrPredicate: nil)
571
- raise NotImplementedError.new('expect_event is not implemented yet.')
564
+ def expect_event(event, predicate: nil, timeout: nil, &block)
565
+ wrap_impl(@impl.expect_event(unwrap_impl(event), predicate: unwrap_impl(predicate), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
572
566
  end
573
567
 
574
- # @nodoc
575
- def browser=(req)
576
- wrap_impl(@impl.browser=(unwrap_impl(req)))
568
+ # Performs action and waits for a new `Page` to be created in the context. If predicate is provided, it passes `Page`
569
+ # value into the `predicate` function and waits for `predicate(event)` to return a truthy value. Will throw an error if
570
+ # the context closes before new `Page` is created.
571
+ def expect_page(predicate: nil, timeout: nil)
572
+ wrap_impl(@impl.expect_page(predicate: unwrap_impl(predicate), timeout: unwrap_impl(timeout)))
573
+ end
574
+
575
+ # > NOTE: In most cases, you should use [`method: BrowserContext.waitForEvent`].
576
+ #
577
+ # Waits for given `event` to fire. If predicate is provided, it passes event's value into the `predicate` function and
578
+ # waits for `predicate(event)` to return a truthy value. Will throw an error if the socket is closed before the `event` is
579
+ # fired.
580
+ def wait_for_event(event, predicate: nil, timeout: nil)
581
+ raise NotImplementedError.new('wait_for_event is not implemented yet.')
577
582
  end
578
583
 
579
584
  # @nodoc
580
- def after_initialize
581
- wrap_impl(@impl.after_initialize)
585
+ def browser=(req)
586
+ wrap_impl(@impl.browser=(unwrap_impl(req)))
582
587
  end
583
588
 
584
589
  # @nodoc
@@ -591,22 +596,31 @@ module Playwright
591
596
  wrap_impl(@impl.options=(unwrap_impl(req)))
592
597
  end
593
598
 
594
- # -- inherited from EventEmitter --
595
599
  # @nodoc
596
- def on(event, callback)
597
- wrap_impl(@impl.on(unwrap_impl(event), unwrap_impl(callback)))
600
+ def pause
601
+ wrap_impl(@impl.pause)
598
602
  end
599
603
 
600
604
  # -- inherited from EventEmitter --
601
605
  # @nodoc
602
606
  def off(event, callback)
603
- wrap_impl(@impl.off(unwrap_impl(event), unwrap_impl(callback)))
607
+ event_emitter_proxy.off(event, callback)
604
608
  end
605
609
 
606
610
  # -- inherited from EventEmitter --
607
611
  # @nodoc
608
612
  def once(event, callback)
609
- wrap_impl(@impl.once(unwrap_impl(event), unwrap_impl(callback)))
613
+ event_emitter_proxy.once(event, callback)
614
+ end
615
+
616
+ # -- inherited from EventEmitter --
617
+ # @nodoc
618
+ def on(event, callback)
619
+ event_emitter_proxy.on(event, callback)
620
+ end
621
+
622
+ private def event_emitter_proxy
623
+ @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
610
624
  end
611
625
  end
612
626
  end
@@ -49,11 +49,6 @@ module Playwright
49
49
  # ```
50
50
  class BrowserType < PlaywrightApi
51
51
 
52
- # This methods attaches Playwright to an existing browser instance.
53
- def connect(params)
54
- raise NotImplementedError.new('connect is not implemented yet.')
55
- end
56
-
57
52
  # A path where Playwright expects to find a bundled browser executable.
58
53
  def executable_path
59
54
  wrap_impl(@impl.executable_path)
@@ -82,19 +77,19 @@ module Playwright
82
77
  # )
83
78
  # ```
84
79
  #
85
- # > **Chromium-only** Playwright can also be used to control the Chrome browser, but it works best with the version of
86
- # Chromium it is bundled with. There is no guarantee it will work with any other version. Use `executablePath` option with
87
- # extreme caution.
80
+ # > **Chromium-only** Playwright can also be used to control the Google Chrome or Microsoft Edge browsers, but it works
81
+ # best with the version of Chromium it is bundled with. There is no guarantee it will work with any other version. Use
82
+ # `executablePath` option with extreme caution.
88
83
  # >
89
84
  # > If Google Chrome (rather than Chromium) is preferred, a
90
85
  # [Chrome Canary](https://www.google.com/chrome/browser/canary.html) or
91
86
  # [Dev Channel](https://www.chromium.org/getting-involved/dev-channel) build is suggested.
92
87
  # >
93
- # > In [`method: BrowserType.launch`] above, any mention of Chromium also applies to Chrome.
94
- # >
95
- # > See [`this article`](https://www.howtogeek.com/202825/what%E2%80%99s-the-difference-between-chromium-and-chrome/) for
96
- # a description of the differences between Chromium and Chrome.
97
- # [`This article`](https://chromium.googlesource.com/chromium/src/+/lkgr/docs/chromium_browser_vs_google_chrome.md)
88
+ # > Stock browsers like Google Chrome and Microsoft Edge are suitable for tests that require proprietary media codecs for
89
+ # video playback. See
90
+ # [this article](https://www.howtogeek.com/202825/what%E2%80%99s-the-difference-between-chromium-and-chrome/) for other
91
+ # differences between Chromium and Chrome.
92
+ # [This article](https://chromium.googlesource.com/chromium/src/+/lkgr/docs/chromium_browser_vs_google_chrome.md)
98
93
  # describes some differences for Linux users.
99
94
  def launch(
100
95
  args: nil,
@@ -109,12 +104,11 @@ module Playwright
109
104
  handleSIGTERM: nil,
110
105
  headless: nil,
111
106
  ignoreDefaultArgs: nil,
112
- logger: nil,
113
107
  proxy: nil,
114
108
  slowMo: nil,
115
109
  timeout: nil,
116
110
  &block)
117
- wrap_impl(@impl.launch(args: unwrap_impl(args), chromiumSandbox: unwrap_impl(chromiumSandbox), devtools: unwrap_impl(devtools), downloadsPath: unwrap_impl(downloadsPath), env: unwrap_impl(env), executablePath: unwrap_impl(executablePath), firefoxUserPrefs: unwrap_impl(firefoxUserPrefs), handleSIGHUP: unwrap_impl(handleSIGHUP), handleSIGINT: unwrap_impl(handleSIGINT), handleSIGTERM: unwrap_impl(handleSIGTERM), headless: unwrap_impl(headless), ignoreDefaultArgs: unwrap_impl(ignoreDefaultArgs), logger: unwrap_impl(logger), proxy: unwrap_impl(proxy), slowMo: unwrap_impl(slowMo), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
111
+ wrap_impl(@impl.launch(args: unwrap_impl(args), chromiumSandbox: unwrap_impl(chromiumSandbox), devtools: unwrap_impl(devtools), downloadsPath: unwrap_impl(downloadsPath), env: unwrap_impl(env), executablePath: unwrap_impl(executablePath), firefoxUserPrefs: unwrap_impl(firefoxUserPrefs), handleSIGHUP: unwrap_impl(handleSIGHUP), handleSIGINT: unwrap_impl(handleSIGINT), handleSIGTERM: unwrap_impl(handleSIGTERM), headless: unwrap_impl(headless), ignoreDefaultArgs: unwrap_impl(ignoreDefaultArgs), proxy: unwrap_impl(proxy), slowMo: unwrap_impl(slowMo), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
118
112
  end
119
113
 
120
114
  # Returns the persistent browser context instance.
@@ -146,60 +140,22 @@ module Playwright
146
140
  isMobile: nil,
147
141
  javaScriptEnabled: nil,
148
142
  locale: nil,
149
- logger: nil,
143
+ noViewport: nil,
150
144
  offline: nil,
151
145
  permissions: nil,
152
146
  proxy: nil,
153
- recordHar: nil,
154
- recordVideo: nil,
147
+ record_har_omit_content: nil,
148
+ record_har_path: nil,
149
+ record_video_dir: nil,
150
+ record_video_size: nil,
155
151
  slowMo: nil,
156
152
  timeout: nil,
157
153
  timezoneId: nil,
158
154
  userAgent: nil,
159
- videoSize: nil,
160
- videosPath: nil,
161
155
  viewport: nil)
162
156
  raise NotImplementedError.new('launch_persistent_context is not implemented yet.')
163
157
  end
164
158
 
165
- # Returns the browser app instance.
166
- #
167
- # Launches browser server that client can connect to. An example of launching a browser executable and connecting to it
168
- # later:
169
- #
170
- #
171
- # ```js
172
- # const { chromium } = require('playwright'); // Or 'webkit' or 'firefox'.
173
- #
174
- # (async () => {
175
- # const browserServer = await chromium.launchServer();
176
- # const wsEndpoint = browserServer.wsEndpoint();
177
- # // Use web socket endpoint later to establish a connection.
178
- # const browser = await chromium.connect({ wsEndpoint });
179
- # // Close browser instance.
180
- # await browserServer.close();
181
- # })();
182
- # ```
183
- def launch_server(
184
- args: nil,
185
- chromiumSandbox: nil,
186
- devtools: nil,
187
- downloadsPath: nil,
188
- env: nil,
189
- executablePath: nil,
190
- firefoxUserPrefs: nil,
191
- handleSIGHUP: nil,
192
- handleSIGINT: nil,
193
- handleSIGTERM: nil,
194
- headless: nil,
195
- ignoreDefaultArgs: nil,
196
- logger: nil,
197
- port: nil,
198
- proxy: nil,
199
- timeout: nil)
200
- raise NotImplementedError.new('launch_server is not implemented yet.')
201
- end
202
-
203
159
  # Returns browser name. For example: `'chromium'`, `'webkit'` or `'firefox'`.
204
160
  def name
205
161
  wrap_impl(@impl.name)
@@ -207,20 +163,24 @@ module Playwright
207
163
 
208
164
  # -- inherited from EventEmitter --
209
165
  # @nodoc
210
- def on(event, callback)
211
- wrap_impl(@impl.on(unwrap_impl(event), unwrap_impl(callback)))
166
+ def off(event, callback)
167
+ event_emitter_proxy.off(event, callback)
212
168
  end
213
169
 
214
170
  # -- inherited from EventEmitter --
215
171
  # @nodoc
216
- def off(event, callback)
217
- wrap_impl(@impl.off(unwrap_impl(event), unwrap_impl(callback)))
172
+ def once(event, callback)
173
+ event_emitter_proxy.once(event, callback)
218
174
  end
219
175
 
220
176
  # -- inherited from EventEmitter --
221
177
  # @nodoc
222
- def once(event, callback)
223
- wrap_impl(@impl.once(unwrap_impl(event), unwrap_impl(callback)))
178
+ def on(event, callback)
179
+ event_emitter_proxy.on(event, callback)
180
+ end
181
+
182
+ private def event_emitter_proxy
183
+ @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
224
184
  end
225
185
  end
226
186
  end