playwright-ruby-client 1.14.beta3 → 1.15.beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -14
  3. data/documentation/docs/api/browser.md +4 -0
  4. data/documentation/docs/api/browser_context.md +5 -1
  5. data/documentation/docs/api/browser_type.md +2 -0
  6. data/documentation/docs/api/element_handle.md +30 -5
  7. data/documentation/docs/api/experimental/android_device.md +2 -0
  8. data/documentation/docs/api/frame.md +32 -6
  9. data/documentation/docs/api/locator.md +67 -38
  10. data/documentation/docs/api/mouse.md +11 -0
  11. data/documentation/docs/api/page.md +38 -7
  12. data/documentation/docs/api/request.md +34 -1
  13. data/documentation/docs/api/response.md +37 -2
  14. data/documentation/docs/api/selectors.md +29 -3
  15. data/documentation/docs/api/tracing.md +42 -8
  16. data/documentation/docs/api/worker.md +12 -11
  17. data/documentation/docs/article/getting_started.md +10 -1
  18. data/documentation/docs/article/guides/download_playwright_driver.md +9 -0
  19. data/documentation/docs/article/guides/inspector.md +1 -1
  20. data/documentation/docs/article/guides/playwright_on_alpine_linux.md +56 -3
  21. data/documentation/docs/article/guides/rails_integration.md +4 -2
  22. data/documentation/docs/article/guides/rails_integration_with_null_driver.md +86 -0
  23. data/documentation/docs/article/guides/recording_video.md +1 -1
  24. data/documentation/docs/article/guides/semi_automation.md +2 -2
  25. data/documentation/docs/article/guides/use_storage_state.md +78 -0
  26. data/documentation/docs/include/api_coverage.md +15 -0
  27. data/documentation/docusaurus.config.js +1 -0
  28. data/documentation/package.json +2 -2
  29. data/documentation/src/pages/index.js +0 -1
  30. data/documentation/static/img/playwright-ruby-client.png +0 -0
  31. data/documentation/yarn.lock +625 -549
  32. data/lib/playwright/channel.rb +36 -2
  33. data/lib/playwright/channel_owners/artifact.rb +6 -2
  34. data/lib/playwright/channel_owners/browser.rb +4 -0
  35. data/lib/playwright/channel_owners/browser_context.rb +21 -14
  36. data/lib/playwright/channel_owners/browser_type.rb +0 -1
  37. data/lib/playwright/channel_owners/element_handle.rb +10 -2
  38. data/lib/playwright/channel_owners/frame.rb +8 -0
  39. data/lib/playwright/channel_owners/page.rb +20 -4
  40. data/lib/playwright/channel_owners/playwright.rb +9 -0
  41. data/lib/playwright/channel_owners/request.rb +53 -17
  42. data/lib/playwright/channel_owners/response.rb +48 -5
  43. data/lib/playwright/connection.rb +8 -11
  44. data/lib/playwright/http_headers.rb +0 -6
  45. data/lib/playwright/locator_impl.rb +8 -0
  46. data/lib/playwright/mouse_impl.rb +9 -0
  47. data/lib/playwright/raw_headers.rb +61 -0
  48. data/lib/playwright/{route_handler_entry.rb → route_handler.rb} +30 -2
  49. data/lib/playwright/tracing_impl.rb +18 -7
  50. data/lib/playwright/transport.rb +2 -0
  51. data/lib/playwright/utils.rb +8 -1
  52. data/lib/playwright/version.rb +2 -2
  53. data/lib/playwright/web_socket_transport.rb +2 -0
  54. data/lib/playwright.rb +46 -5
  55. data/lib/playwright_api/android.rb +6 -6
  56. data/lib/playwright_api/android_device.rb +11 -9
  57. data/lib/playwright_api/browser.rb +12 -8
  58. data/lib/playwright_api/browser_context.rb +12 -8
  59. data/lib/playwright_api/browser_type.rb +9 -7
  60. data/lib/playwright_api/cdp_session.rb +7 -7
  61. data/lib/playwright_api/console_message.rb +6 -6
  62. data/lib/playwright_api/dialog.rb +6 -6
  63. data/lib/playwright_api/element_handle.rb +31 -8
  64. data/lib/playwright_api/frame.rb +35 -12
  65. data/lib/playwright_api/js_handle.rb +6 -6
  66. data/lib/playwright_api/locator.rb +39 -0
  67. data/lib/playwright_api/mouse.rb +8 -0
  68. data/lib/playwright_api/page.rb +43 -15
  69. data/lib/playwright_api/playwright.rb +6 -6
  70. data/lib/playwright_api/request.rb +33 -7
  71. data/lib/playwright_api/response.rb +31 -8
  72. data/lib/playwright_api/route.rb +6 -6
  73. data/lib/playwright_api/selectors.rb +38 -7
  74. data/lib/playwright_api/tracing.rb +33 -4
  75. data/lib/playwright_api/web_socket.rb +6 -6
  76. data/lib/playwright_api/worker.rb +8 -8
  77. metadata +8 -4
@@ -70,6 +70,7 @@ module Playwright
70
70
  colorScheme: nil,
71
71
  deviceScaleFactor: nil,
72
72
  extraHTTPHeaders: nil,
73
+ forcedColors: nil,
73
74
  geolocation: nil,
74
75
  hasTouch: nil,
75
76
  httpCredentials: nil,
@@ -88,11 +89,12 @@ module Playwright
88
89
  reducedMotion: nil,
89
90
  screen: nil,
90
91
  storageState: nil,
92
+ strictSelectors: nil,
91
93
  timezoneId: nil,
92
94
  userAgent: nil,
93
95
  viewport: nil,
94
96
  &block)
95
- wrap_impl(@impl.new_context(acceptDownloads: unwrap_impl(acceptDownloads), baseURL: unwrap_impl(baseURL), 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), reducedMotion: unwrap_impl(reducedMotion), screen: unwrap_impl(screen), storageState: unwrap_impl(storageState), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
97
+ wrap_impl(@impl.new_context(acceptDownloads: unwrap_impl(acceptDownloads), baseURL: unwrap_impl(baseURL), bypassCSP: unwrap_impl(bypassCSP), colorScheme: unwrap_impl(colorScheme), deviceScaleFactor: unwrap_impl(deviceScaleFactor), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), forcedColors: unwrap_impl(forcedColors), 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), reducedMotion: unwrap_impl(reducedMotion), screen: unwrap_impl(screen), storageState: unwrap_impl(storageState), strictSelectors: unwrap_impl(strictSelectors), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
96
98
  end
97
99
 
98
100
  # Creates a new page in a new browser context. Closing this page will close the context as well.
@@ -107,6 +109,7 @@ module Playwright
107
109
  colorScheme: nil,
108
110
  deviceScaleFactor: nil,
109
111
  extraHTTPHeaders: nil,
112
+ forcedColors: nil,
110
113
  geolocation: nil,
111
114
  hasTouch: nil,
112
115
  httpCredentials: nil,
@@ -125,11 +128,12 @@ module Playwright
125
128
  reducedMotion: nil,
126
129
  screen: nil,
127
130
  storageState: nil,
131
+ strictSelectors: nil,
128
132
  timezoneId: nil,
129
133
  userAgent: nil,
130
134
  viewport: nil,
131
135
  &block)
132
- wrap_impl(@impl.new_page(acceptDownloads: unwrap_impl(acceptDownloads), baseURL: unwrap_impl(baseURL), 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), reducedMotion: unwrap_impl(reducedMotion), screen: unwrap_impl(screen), storageState: unwrap_impl(storageState), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
136
+ wrap_impl(@impl.new_page(acceptDownloads: unwrap_impl(acceptDownloads), baseURL: unwrap_impl(baseURL), bypassCSP: unwrap_impl(bypassCSP), colorScheme: unwrap_impl(colorScheme), deviceScaleFactor: unwrap_impl(deviceScaleFactor), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), forcedColors: unwrap_impl(forcedColors), 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), reducedMotion: unwrap_impl(reducedMotion), screen: unwrap_impl(screen), storageState: unwrap_impl(storageState), strictSelectors: unwrap_impl(strictSelectors), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
133
137
  end
134
138
 
135
139
  # > NOTE: This API controls [Chromium Tracing](https://www.chromium.org/developers/how-tos/trace-event-profiling-tool)
@@ -164,20 +168,20 @@ module Playwright
164
168
 
165
169
  # -- inherited from EventEmitter --
166
170
  # @nodoc
167
- def once(event, callback)
168
- event_emitter_proxy.once(event, callback)
171
+ def off(event, callback)
172
+ event_emitter_proxy.off(event, callback)
169
173
  end
170
174
 
171
175
  # -- inherited from EventEmitter --
172
176
  # @nodoc
173
- def on(event, callback)
174
- event_emitter_proxy.on(event, callback)
177
+ def once(event, callback)
178
+ event_emitter_proxy.once(event, callback)
175
179
  end
176
180
 
177
181
  # -- inherited from EventEmitter --
178
182
  # @nodoc
179
- def off(event, callback)
180
- event_emitter_proxy.off(event, callback)
183
+ def on(event, callback)
184
+ event_emitter_proxy.on(event, callback)
181
185
  end
182
186
 
183
187
  private def event_emitter_proxy
@@ -220,6 +220,10 @@ module Playwright
220
220
  # Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
221
221
  # is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
222
222
  #
223
+ # > NOTE: [`method: Page.route`] will not intercept requests intercepted by Service Worker. See
224
+ # [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using
225
+ # request interception. Via `await context.addInitScript(() => delete window.navigator.serviceWorker);`
226
+ #
223
227
  # An example of a naive handler that aborts all image requests:
224
228
  #
225
229
  # ```python sync
@@ -260,8 +264,8 @@ module Playwright
260
264
  # To remove a route with its handler you can use [`method: BrowserContext.unroute`].
261
265
  #
262
266
  # > NOTE: Enabling routing disables http cache.
263
- def route(url, handler)
264
- wrap_impl(@impl.route(unwrap_impl(url), unwrap_impl(handler)))
267
+ def route(url, handler, times: nil)
268
+ wrap_impl(@impl.route(unwrap_impl(url), unwrap_impl(handler), times: unwrap_impl(times)))
265
269
  end
266
270
 
267
271
  # > NOTE: Service workers are only supported on Chromium-based browsers.
@@ -389,20 +393,20 @@ module Playwright
389
393
 
390
394
  # -- inherited from EventEmitter --
391
395
  # @nodoc
392
- def once(event, callback)
393
- event_emitter_proxy.once(event, callback)
396
+ def off(event, callback)
397
+ event_emitter_proxy.off(event, callback)
394
398
  end
395
399
 
396
400
  # -- inherited from EventEmitter --
397
401
  # @nodoc
398
- def on(event, callback)
399
- event_emitter_proxy.on(event, callback)
402
+ def once(event, callback)
403
+ event_emitter_proxy.once(event, callback)
400
404
  end
401
405
 
402
406
  # -- inherited from EventEmitter --
403
407
  # @nodoc
404
- def off(event, callback)
405
- event_emitter_proxy.off(event, callback)
408
+ def on(event, callback)
409
+ event_emitter_proxy.on(event, callback)
406
410
  end
407
411
 
408
412
  private def event_emitter_proxy
@@ -107,6 +107,7 @@ module Playwright
107
107
  env: nil,
108
108
  executablePath: nil,
109
109
  extraHTTPHeaders: nil,
110
+ forcedColors: nil,
110
111
  geolocation: nil,
111
112
  handleSIGHUP: nil,
112
113
  handleSIGINT: nil,
@@ -130,13 +131,14 @@ module Playwright
130
131
  reducedMotion: nil,
131
132
  screen: nil,
132
133
  slowMo: nil,
134
+ strictSelectors: nil,
133
135
  timeout: nil,
134
136
  timezoneId: nil,
135
137
  tracesDir: nil,
136
138
  userAgent: nil,
137
139
  viewport: nil,
138
140
  &block)
139
- wrap_impl(@impl.launch_persistent_context(unwrap_impl(userDataDir), acceptDownloads: unwrap_impl(acceptDownloads), args: unwrap_impl(args), baseURL: unwrap_impl(baseURL), bypassCSP: unwrap_impl(bypassCSP), channel: unwrap_impl(channel), chromiumSandbox: unwrap_impl(chromiumSandbox), colorScheme: unwrap_impl(colorScheme), deviceScaleFactor: unwrap_impl(deviceScaleFactor), devtools: unwrap_impl(devtools), downloadsPath: unwrap_impl(downloadsPath), env: unwrap_impl(env), executablePath: unwrap_impl(executablePath), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), geolocation: unwrap_impl(geolocation), handleSIGHUP: unwrap_impl(handleSIGHUP), handleSIGINT: unwrap_impl(handleSIGINT), handleSIGTERM: unwrap_impl(handleSIGTERM), hasTouch: unwrap_impl(hasTouch), headless: unwrap_impl(headless), httpCredentials: unwrap_impl(httpCredentials), ignoreDefaultArgs: unwrap_impl(ignoreDefaultArgs), 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), reducedMotion: unwrap_impl(reducedMotion), screen: unwrap_impl(screen), slowMo: unwrap_impl(slowMo), timeout: unwrap_impl(timeout), timezoneId: unwrap_impl(timezoneId), tracesDir: unwrap_impl(tracesDir), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
141
+ wrap_impl(@impl.launch_persistent_context(unwrap_impl(userDataDir), acceptDownloads: unwrap_impl(acceptDownloads), args: unwrap_impl(args), baseURL: unwrap_impl(baseURL), bypassCSP: unwrap_impl(bypassCSP), channel: unwrap_impl(channel), chromiumSandbox: unwrap_impl(chromiumSandbox), colorScheme: unwrap_impl(colorScheme), deviceScaleFactor: unwrap_impl(deviceScaleFactor), devtools: unwrap_impl(devtools), downloadsPath: unwrap_impl(downloadsPath), env: unwrap_impl(env), executablePath: unwrap_impl(executablePath), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), forcedColors: unwrap_impl(forcedColors), geolocation: unwrap_impl(geolocation), handleSIGHUP: unwrap_impl(handleSIGHUP), handleSIGINT: unwrap_impl(handleSIGINT), handleSIGTERM: unwrap_impl(handleSIGTERM), hasTouch: unwrap_impl(hasTouch), headless: unwrap_impl(headless), httpCredentials: unwrap_impl(httpCredentials), ignoreDefaultArgs: unwrap_impl(ignoreDefaultArgs), 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), reducedMotion: unwrap_impl(reducedMotion), screen: unwrap_impl(screen), slowMo: unwrap_impl(slowMo), strictSelectors: unwrap_impl(strictSelectors), timeout: unwrap_impl(timeout), timezoneId: unwrap_impl(timezoneId), tracesDir: unwrap_impl(tracesDir), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
140
142
  end
141
143
 
142
144
  # Returns browser name. For example: `'chromium'`, `'webkit'` or `'firefox'`.
@@ -146,20 +148,20 @@ module Playwright
146
148
 
147
149
  # -- inherited from EventEmitter --
148
150
  # @nodoc
149
- def once(event, callback)
150
- event_emitter_proxy.once(event, callback)
151
+ def off(event, callback)
152
+ event_emitter_proxy.off(event, callback)
151
153
  end
152
154
 
153
155
  # -- inherited from EventEmitter --
154
156
  # @nodoc
155
- def on(event, callback)
156
- event_emitter_proxy.on(event, callback)
157
+ def once(event, callback)
158
+ event_emitter_proxy.once(event, callback)
157
159
  end
158
160
 
159
161
  # -- inherited from EventEmitter --
160
162
  # @nodoc
161
- def off(event, callback)
162
- event_emitter_proxy.off(event, callback)
163
+ def on(event, callback)
164
+ event_emitter_proxy.on(event, callback)
163
165
  end
164
166
 
165
167
  private def event_emitter_proxy
@@ -12,7 +12,7 @@ module Playwright
12
12
  # https://github.com/aslushnikov/getting-started-with-cdp/blob/master/README.md
13
13
  #
14
14
  # ```python sync
15
- # client = page.context().new_cdp_session(page)
15
+ # client = page.context.new_cdp_session(page)
16
16
  # client.send("Animation.enable")
17
17
  # client.on("Animation.animationCreated", lambda: print("animation created!"))
18
18
  # response = client.send("Animation.getPlaybackRate")
@@ -35,20 +35,20 @@ module Playwright
35
35
 
36
36
  # -- inherited from EventEmitter --
37
37
  # @nodoc
38
- def once(event, callback)
39
- event_emitter_proxy.once(event, callback)
38
+ def off(event, callback)
39
+ event_emitter_proxy.off(event, callback)
40
40
  end
41
41
 
42
42
  # -- inherited from EventEmitter --
43
43
  # @nodoc
44
- def on(event, callback)
45
- event_emitter_proxy.on(event, callback)
44
+ def once(event, callback)
45
+ event_emitter_proxy.once(event, callback)
46
46
  end
47
47
 
48
48
  # -- inherited from EventEmitter --
49
49
  # @nodoc
50
- def off(event, callback)
51
- event_emitter_proxy.off(event, callback)
50
+ def on(event, callback)
51
+ event_emitter_proxy.on(event, callback)
52
52
  end
53
53
 
54
54
  private def event_emitter_proxy
@@ -25,20 +25,20 @@ module Playwright
25
25
 
26
26
  # -- inherited from EventEmitter --
27
27
  # @nodoc
28
- def once(event, callback)
29
- event_emitter_proxy.once(event, callback)
28
+ def off(event, callback)
29
+ event_emitter_proxy.off(event, callback)
30
30
  end
31
31
 
32
32
  # -- inherited from EventEmitter --
33
33
  # @nodoc
34
- def on(event, callback)
35
- event_emitter_proxy.on(event, callback)
34
+ def once(event, callback)
35
+ event_emitter_proxy.once(event, callback)
36
36
  end
37
37
 
38
38
  # -- inherited from EventEmitter --
39
39
  # @nodoc
40
- def off(event, callback)
41
- event_emitter_proxy.off(event, callback)
40
+ def on(event, callback)
41
+ event_emitter_proxy.on(event, callback)
42
42
  end
43
43
 
44
44
  private def event_emitter_proxy
@@ -60,20 +60,20 @@ module Playwright
60
60
 
61
61
  # -- inherited from EventEmitter --
62
62
  # @nodoc
63
- def once(event, callback)
64
- event_emitter_proxy.once(event, callback)
63
+ def off(event, callback)
64
+ event_emitter_proxy.off(event, callback)
65
65
  end
66
66
 
67
67
  # -- inherited from EventEmitter --
68
68
  # @nodoc
69
- def on(event, callback)
70
- event_emitter_proxy.on(event, callback)
69
+ def once(event, callback)
70
+ event_emitter_proxy.once(event, callback)
71
71
  end
72
72
 
73
73
  # -- inherited from EventEmitter --
74
74
  # @nodoc
75
- def off(event, callback)
76
- event_emitter_proxy.off(event, callback)
75
+ def on(event, callback)
76
+ event_emitter_proxy.on(event, callback)
77
77
  end
78
78
 
79
79
  private def event_emitter_proxy
@@ -412,6 +412,29 @@ module Playwright
412
412
  wrap_impl(@impl.select_text(force: unwrap_impl(force), timeout: unwrap_impl(timeout)))
413
413
  end
414
414
 
415
+ # This method checks or unchecks an element by performing the following steps:
416
+ # 1. Ensure that element is a checkbox or a radio input. If not, this method throws.
417
+ # 1. If the element already has the right checked state, this method returns immediately.
418
+ # 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the
419
+ # element is detached during the checks, the whole action is retried.
420
+ # 1. Scroll the element into view if needed.
421
+ # 1. Use [`property: Page.mouse`] to click in the center of the element.
422
+ # 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
423
+ # 1. Ensure that the element is now checked or unchecked. If not, this method throws.
424
+ #
425
+ # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
426
+ # zero timeout disables this.
427
+ def set_checked(
428
+ checked,
429
+ force: nil,
430
+ noWaitAfter: nil,
431
+ position: nil,
432
+ timeout: nil,
433
+ trial: nil)
434
+ wrap_impl(@impl.set_checked(unwrap_impl(checked), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
435
+ end
436
+ alias_method :checked=, :set_checked
437
+
415
438
  # This method expects `elementHandle` to point to an
416
439
  # [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
417
440
  #
@@ -525,26 +548,26 @@ module Playwright
525
548
  # ```
526
549
  #
527
550
  # > NOTE: This method does not work across navigations, use [`method: Page.waitForSelector`] instead.
528
- def wait_for_selector(selector, state: nil, timeout: nil)
529
- wrap_impl(@impl.wait_for_selector(unwrap_impl(selector), state: unwrap_impl(state), timeout: unwrap_impl(timeout)))
551
+ def wait_for_selector(selector, state: nil, strict: nil, timeout: nil)
552
+ wrap_impl(@impl.wait_for_selector(unwrap_impl(selector), state: unwrap_impl(state), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
530
553
  end
531
554
 
532
555
  # -- inherited from EventEmitter --
533
556
  # @nodoc
534
- def once(event, callback)
535
- event_emitter_proxy.once(event, callback)
557
+ def off(event, callback)
558
+ event_emitter_proxy.off(event, callback)
536
559
  end
537
560
 
538
561
  # -- inherited from EventEmitter --
539
562
  # @nodoc
540
- def on(event, callback)
541
- event_emitter_proxy.on(event, callback)
563
+ def once(event, callback)
564
+ event_emitter_proxy.once(event, callback)
542
565
  end
543
566
 
544
567
  # -- inherited from EventEmitter --
545
568
  # @nodoc
546
- def off(event, callback)
547
- event_emitter_proxy.off(event, callback)
569
+ def on(event, callback)
570
+ event_emitter_proxy.on(event, callback)
548
571
  end
549
572
 
550
573
  private def event_emitter_proxy
@@ -332,18 +332,18 @@ module Playwright
332
332
  # Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
333
333
  # last redirect.
334
334
  #
335
- # `frame.goto` will throw an error if:
335
+ # The method will throw an error if:
336
336
  # - there's an SSL error (e.g. in case of self-signed certificates).
337
337
  # - target URL is invalid.
338
338
  # - the `timeout` is exceeded during navigation.
339
339
  # - the remote server does not respond or is unreachable.
340
340
  # - the main resource failed to load.
341
341
  #
342
- # `frame.goto` will not throw an error when any valid HTTP status code is returned by the remote server, including 404
343
- # "Not Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling
342
+ # The method will not throw an error when any valid HTTP status code is returned by the remote server, including 404 "Not
343
+ # Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling
344
344
  # [`method: Response.status`].
345
345
  #
346
- # > NOTE: `frame.goto` either throws an error or returns a main resource response. The only exceptions are navigation to
346
+ # > NOTE: The method either throws an error or returns a main resource response. The only exceptions are navigation to
347
347
  # `about:blank` or navigation to the same URL with a different hash, which would succeed and return `null`.
348
348
  # > NOTE: Headless mode doesn't support navigation to a PDF document. See the
349
349
  # [upstream issue](https://bugs.chromium.org/p/chromium/issues/detail?id=761295).
@@ -427,8 +427,6 @@ module Playwright
427
427
  # The method returns an element locator that can be used to perform actions in the frame. Locator is resolved to the
428
428
  # element immediately before performing an action, so a series of actions on the same locator can in fact be performed on
429
429
  # different DOM elements. That would happen if the DOM structure between those actions has changed.
430
- #
431
- # Note that locator always implies visibility, so it will always be locating visible elements.
432
430
  def locator(selector)
433
431
  wrap_impl(@impl.locator(unwrap_impl(selector)))
434
432
  end
@@ -526,6 +524,31 @@ module Playwright
526
524
  wrap_impl(@impl.select_option(unwrap_impl(selector), element: unwrap_impl(element), index: unwrap_impl(index), value: unwrap_impl(value), label: unwrap_impl(label), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
527
525
  end
528
526
 
527
+ # This method checks or unchecks an element matching `selector` by performing the following steps:
528
+ # 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
529
+ # 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws.
530
+ # 1. If the element already has the right checked state, this method returns immediately.
531
+ # 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the
532
+ # element is detached during the checks, the whole action is retried.
533
+ # 1. Scroll the element into view if needed.
534
+ # 1. Use [`property: Page.mouse`] to click in the center of the element.
535
+ # 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
536
+ # 1. Ensure that the element is now checked or unchecked. If not, this method throws.
537
+ #
538
+ # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
539
+ # zero timeout disables this.
540
+ def set_checked(
541
+ selector,
542
+ checked,
543
+ force: nil,
544
+ noWaitAfter: nil,
545
+ position: nil,
546
+ strict: nil,
547
+ timeout: nil,
548
+ trial: nil)
549
+ wrap_impl(@impl.set_checked(unwrap_impl(selector), unwrap_impl(checked), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
550
+ end
551
+
529
552
  def set_content(html, timeout: nil, waitUntil: nil)
530
553
  wrap_impl(@impl.set_content(unwrap_impl(html), timeout: unwrap_impl(timeout), waitUntil: unwrap_impl(waitUntil)))
531
554
  end
@@ -742,20 +765,20 @@ module Playwright
742
765
 
743
766
  # -- inherited from EventEmitter --
744
767
  # @nodoc
745
- def once(event, callback)
746
- event_emitter_proxy.once(event, callback)
768
+ def off(event, callback)
769
+ event_emitter_proxy.off(event, callback)
747
770
  end
748
771
 
749
772
  # -- inherited from EventEmitter --
750
773
  # @nodoc
751
- def on(event, callback)
752
- event_emitter_proxy.on(event, callback)
774
+ def once(event, callback)
775
+ event_emitter_proxy.once(event, callback)
753
776
  end
754
777
 
755
778
  # -- inherited from EventEmitter --
756
779
  # @nodoc
757
- def off(event, callback)
758
- event_emitter_proxy.off(event, callback)
780
+ def on(event, callback)
781
+ event_emitter_proxy.on(event, callback)
759
782
  end
760
783
 
761
784
  private def event_emitter_proxy
@@ -90,20 +90,20 @@ module Playwright
90
90
 
91
91
  # -- inherited from EventEmitter --
92
92
  # @nodoc
93
- def once(event, callback)
94
- event_emitter_proxy.once(event, callback)
93
+ def off(event, callback)
94
+ event_emitter_proxy.off(event, callback)
95
95
  end
96
96
 
97
97
  # -- inherited from EventEmitter --
98
98
  # @nodoc
99
- def on(event, callback)
100
- event_emitter_proxy.on(event, callback)
99
+ def once(event, callback)
100
+ event_emitter_proxy.once(event, callback)
101
101
  end
102
102
 
103
103
  # -- inherited from EventEmitter --
104
104
  # @nodoc
105
- def off(event, callback)
106
- event_emitter_proxy.off(event, callback)
105
+ def on(event, callback)
106
+ event_emitter_proxy.on(event, callback)
107
107
  end
108
108
 
109
109
  private def event_emitter_proxy
@@ -28,6 +28,22 @@ module Playwright
28
28
  # locator.hover()
29
29
  # locator.click()
30
30
  # ```
31
+ #
32
+ # **Strictness**
33
+ #
34
+ # Locators are strict. This means that all operations on locators that imply some target DOM element will throw if more
35
+ # than one element matches given selector.
36
+ #
37
+ # ```python sync
38
+ # # Throws if there are several buttons in DOM:
39
+ # page.locator('button').click()
40
+ #
41
+ # # Works because we explicitly tell locator to pick the first element:
42
+ # page.locator('button').first.click()
43
+ #
44
+ # # Works because count knows what to do with multiple matches:
45
+ # page.locator('button').count()
46
+ # ```
31
47
  class Locator < PlaywrightApi
32
48
 
33
49
  # Returns an array of `node.innerText` values for all matching nodes.
@@ -422,6 +438,29 @@ module Playwright
422
438
  wrap_impl(@impl.select_text(force: unwrap_impl(force), timeout: unwrap_impl(timeout)))
423
439
  end
424
440
 
441
+ # This method checks or unchecks an element by performing the following steps:
442
+ # 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws.
443
+ # 1. If the element already has the right checked state, this method returns immediately.
444
+ # 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the
445
+ # element is detached during the checks, the whole action is retried.
446
+ # 1. Scroll the element into view if needed.
447
+ # 1. Use [`property: Page.mouse`] to click in the center of the element.
448
+ # 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
449
+ # 1. Ensure that the element is now checked or unchecked. If not, this method throws.
450
+ #
451
+ # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
452
+ # zero timeout disables this.
453
+ def set_checked(
454
+ checked,
455
+ force: nil,
456
+ noWaitAfter: nil,
457
+ position: nil,
458
+ timeout: nil,
459
+ trial: nil)
460
+ wrap_impl(@impl.set_checked(unwrap_impl(checked), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
461
+ end
462
+ alias_method :checked=, :set_checked
463
+
425
464
  # This method expects `element` to point to an
426
465
  # [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
427
466
  #