playwright-ruby-client 1.14.beta2 → 1.15.beta2
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.
- checksums.yaml +4 -4
- data/README.md +10 -14
- data/documentation/docs/api/accessibility.md +16 -17
- data/documentation/docs/api/browser.md +4 -0
- data/documentation/docs/api/browser_context.md +5 -1
- data/documentation/docs/api/browser_type.md +2 -0
- data/documentation/docs/api/element_handle.md +30 -5
- data/documentation/docs/api/experimental/android.md +15 -2
- data/documentation/docs/api/experimental/android_device.md +2 -0
- data/documentation/docs/api/frame.md +86 -104
- data/documentation/docs/api/locator.md +69 -40
- data/documentation/docs/api/mouse.md +3 -4
- data/documentation/docs/api/page.md +38 -7
- data/documentation/docs/api/request.md +42 -20
- data/documentation/docs/api/response.md +18 -1
- data/documentation/docs/api/selectors.md +29 -3
- data/documentation/docs/api/tracing.md +51 -16
- data/documentation/docs/api/worker.md +12 -11
- data/documentation/docs/article/getting_started.md +10 -1
- data/documentation/docs/article/guides/download_playwright_driver.md +9 -0
- data/documentation/docs/article/guides/inspector.md +1 -1
- data/documentation/docs/article/guides/playwright_on_alpine_linux.md +56 -3
- data/documentation/docs/article/guides/rails_integration.md +4 -2
- data/documentation/docs/article/guides/rails_integration_with_null_driver.md +86 -0
- data/documentation/docs/article/guides/recording_video.md +1 -1
- data/documentation/docs/article/guides/semi_automation.md +2 -2
- data/documentation/docs/article/guides/use_storage_state.md +78 -0
- data/documentation/docs/include/api_coverage.md +11 -0
- data/documentation/docusaurus.config.js +1 -0
- data/documentation/package.json +2 -2
- data/documentation/src/pages/index.js +0 -1
- data/documentation/static/img/playwright-ruby-client.png +0 -0
- data/documentation/yarn.lock +625 -549
- data/lib/playwright/channel.rb +36 -2
- data/lib/playwright/channel_owners/artifact.rb +6 -2
- data/lib/playwright/channel_owners/browser.rb +4 -0
- data/lib/playwright/channel_owners/browser_context.rb +21 -14
- data/lib/playwright/channel_owners/browser_type.rb +0 -1
- data/lib/playwright/channel_owners/element_handle.rb +10 -2
- data/lib/playwright/channel_owners/frame.rb +8 -0
- data/lib/playwright/channel_owners/page.rb +20 -4
- data/lib/playwright/channel_owners/playwright.rb +9 -0
- data/lib/playwright/channel_owners/request.rb +46 -25
- data/lib/playwright/channel_owners/response.rb +41 -5
- data/lib/playwright/connection.rb +8 -11
- data/lib/playwright/http_headers.rb +9 -4
- data/lib/playwright/locator_impl.rb +11 -3
- data/lib/playwright/{route_handler_entry.rb → route_handler.rb} +30 -2
- data/lib/playwright/tracing_impl.rb +18 -7
- data/lib/playwright/transport.rb +2 -0
- data/lib/playwright/utils.rb +8 -1
- data/lib/playwright/version.rb +2 -2
- data/lib/playwright/web_socket_transport.rb +2 -0
- data/lib/playwright.rb +45 -5
- data/lib/playwright_api/android.rb +21 -8
- data/lib/playwright_api/android_device.rb +11 -9
- data/lib/playwright_api/browser.rb +12 -8
- data/lib/playwright_api/browser_context.rb +12 -8
- data/lib/playwright_api/browser_type.rb +9 -7
- data/lib/playwright_api/cdp_session.rb +6 -6
- data/lib/playwright_api/console_message.rb +6 -6
- data/lib/playwright_api/dialog.rb +6 -6
- data/lib/playwright_api/element_handle.rb +31 -8
- data/lib/playwright_api/frame.rb +35 -12
- data/lib/playwright_api/js_handle.rb +6 -6
- data/lib/playwright_api/locator.rb +41 -2
- data/lib/playwright_api/page.rb +43 -15
- data/lib/playwright_api/playwright.rb +6 -6
- data/lib/playwright_api/request.rb +29 -7
- data/lib/playwright_api/response.rb +23 -7
- data/lib/playwright_api/route.rb +6 -6
- data/lib/playwright_api/selectors.rb +38 -7
- data/lib/playwright_api/tracing.rb +33 -4
- data/lib/playwright_api/web_socket.rb +6 -6
- data/lib/playwright_api/worker.rb +8 -8
- metadata +7 -4
|
@@ -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
|
|
393
|
-
event_emitter_proxy.
|
|
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
|
|
399
|
-
event_emitter_proxy.
|
|
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
|
|
405
|
-
event_emitter_proxy.
|
|
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
|
|
150
|
-
event_emitter_proxy.
|
|
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
|
|
156
|
-
event_emitter_proxy.
|
|
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
|
|
162
|
-
event_emitter_proxy.
|
|
163
|
+
def on(event, callback)
|
|
164
|
+
event_emitter_proxy.on(event, callback)
|
|
163
165
|
end
|
|
164
166
|
|
|
165
167
|
private def event_emitter_proxy
|
|
@@ -35,20 +35,20 @@ module Playwright
|
|
|
35
35
|
|
|
36
36
|
# -- inherited from EventEmitter --
|
|
37
37
|
# @nodoc
|
|
38
|
-
def
|
|
39
|
-
event_emitter_proxy.
|
|
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
|
|
45
|
-
event_emitter_proxy.
|
|
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
|
|
51
|
-
event_emitter_proxy.
|
|
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
|
|
29
|
-
event_emitter_proxy.
|
|
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
|
|
35
|
-
event_emitter_proxy.
|
|
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
|
|
41
|
-
event_emitter_proxy.
|
|
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
|
|
64
|
-
event_emitter_proxy.
|
|
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
|
|
70
|
-
event_emitter_proxy.
|
|
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
|
|
76
|
-
event_emitter_proxy.
|
|
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
|
|
535
|
-
event_emitter_proxy.
|
|
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
|
|
541
|
-
event_emitter_proxy.
|
|
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
|
|
547
|
-
event_emitter_proxy.
|
|
569
|
+
def on(event, callback)
|
|
570
|
+
event_emitter_proxy.on(event, callback)
|
|
548
571
|
end
|
|
549
572
|
|
|
550
573
|
private def event_emitter_proxy
|
data/lib/playwright_api/frame.rb
CHANGED
|
@@ -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
|
-
#
|
|
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
|
-
#
|
|
343
|
-
#
|
|
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:
|
|
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
|
|
746
|
-
event_emitter_proxy.
|
|
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
|
|
752
|
-
event_emitter_proxy.
|
|
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
|
|
758
|
-
event_emitter_proxy.
|
|
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
|
|
94
|
-
event_emitter_proxy.
|
|
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
|
|
100
|
-
event_emitter_proxy.
|
|
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
|
|
106
|
-
event_emitter_proxy.
|
|
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.
|
|
@@ -197,8 +213,8 @@ module Playwright
|
|
|
197
213
|
# The method finds all elements matching the specified locator and passes an array of matched elements as a first argument
|
|
198
214
|
# to `expression`. Returns the result of `expression` invocation.
|
|
199
215
|
#
|
|
200
|
-
# If `expression` returns a [Promise], then [`Locator.evaluateAll`] would wait for the promise to resolve and
|
|
201
|
-
# value.
|
|
216
|
+
# If `expression` returns a [Promise], then [`method: Locator.evaluateAll`] would wait for the promise to resolve and
|
|
217
|
+
# return its value.
|
|
202
218
|
#
|
|
203
219
|
# Examples:
|
|
204
220
|
#
|
|
@@ -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
|
#
|
data/lib/playwright_api/page.rb
CHANGED
|
@@ -284,8 +284,8 @@ module Playwright
|
|
|
284
284
|
# # → False
|
|
285
285
|
# page.evaluate("matchMedia('(prefers-color-scheme: no-preference)').matches")
|
|
286
286
|
# ```
|
|
287
|
-
def emulate_media(colorScheme: nil, media: nil, reducedMotion: nil)
|
|
288
|
-
wrap_impl(@impl.emulate_media(colorScheme: unwrap_impl(colorScheme), media: unwrap_impl(media), reducedMotion: unwrap_impl(reducedMotion)))
|
|
287
|
+
def emulate_media(colorScheme: nil, forcedColors: nil, media: nil, reducedMotion: nil)
|
|
288
|
+
wrap_impl(@impl.emulate_media(colorScheme: unwrap_impl(colorScheme), forcedColors: unwrap_impl(forcedColors), media: unwrap_impl(media), reducedMotion: unwrap_impl(reducedMotion)))
|
|
289
289
|
end
|
|
290
290
|
|
|
291
291
|
# The method finds an element matching the specified selector within the page and passes it as a first argument to
|
|
@@ -562,18 +562,18 @@ module Playwright
|
|
|
562
562
|
# Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
|
|
563
563
|
# last redirect.
|
|
564
564
|
#
|
|
565
|
-
#
|
|
565
|
+
# The method will throw an error if:
|
|
566
566
|
# - there's an SSL error (e.g. in case of self-signed certificates).
|
|
567
567
|
# - target URL is invalid.
|
|
568
568
|
# - the `timeout` is exceeded during navigation.
|
|
569
569
|
# - the remote server does not respond or is unreachable.
|
|
570
570
|
# - the main resource failed to load.
|
|
571
571
|
#
|
|
572
|
-
#
|
|
572
|
+
# The method will not throw an error when any valid HTTP status code is returned by the remote server, including 404 "Not
|
|
573
573
|
# Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling
|
|
574
574
|
# [`method: Response.status`].
|
|
575
575
|
#
|
|
576
|
-
# > NOTE:
|
|
576
|
+
# > NOTE: The method either throws an error or returns a main resource response. The only exceptions are navigation to
|
|
577
577
|
# `about:blank` or navigation to the same URL with a different hash, which would succeed and return `null`.
|
|
578
578
|
# > NOTE: Headless mode doesn't support navigation to a PDF document. See the
|
|
579
579
|
# [upstream issue](https://bugs.chromium.org/p/chromium/issues/detail?id=761295).
|
|
@@ -662,8 +662,6 @@ module Playwright
|
|
|
662
662
|
# element immediately before performing an action, so a series of actions on the same locator can in fact be performed on
|
|
663
663
|
# different DOM elements. That would happen if the DOM structure between those actions has changed.
|
|
664
664
|
#
|
|
665
|
-
# Note that locator always implies visibility, so it will always be locating visible elements.
|
|
666
|
-
#
|
|
667
665
|
# Shortcut for main frame's [`method: Frame.locator`].
|
|
668
666
|
def locator(selector)
|
|
669
667
|
wrap_impl(@impl.locator(unwrap_impl(selector)))
|
|
@@ -820,6 +818,9 @@ module Playwright
|
|
|
820
818
|
# Once routing is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
|
|
821
819
|
#
|
|
822
820
|
# > NOTE: The handler will only be called for the first url if the response is a redirect.
|
|
821
|
+
# > NOTE: [`method: Page.route`] will not intercept requests intercepted by Service Worker. See
|
|
822
|
+
# [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using
|
|
823
|
+
# request interception. Via `await context.addInitScript(() => delete window.navigator.serviceWorker);`
|
|
823
824
|
#
|
|
824
825
|
# An example of a naive handler that aborts all image requests:
|
|
825
826
|
#
|
|
@@ -857,8 +858,8 @@ module Playwright
|
|
|
857
858
|
# To remove a route with its handler you can use [`method: Page.unroute`].
|
|
858
859
|
#
|
|
859
860
|
# > NOTE: Enabling routing disables http cache.
|
|
860
|
-
def route(url, handler)
|
|
861
|
-
wrap_impl(@impl.route(unwrap_impl(url), unwrap_impl(handler)))
|
|
861
|
+
def route(url, handler, times: nil)
|
|
862
|
+
wrap_impl(@impl.route(unwrap_impl(url), unwrap_impl(handler), times: unwrap_impl(times)))
|
|
862
863
|
end
|
|
863
864
|
|
|
864
865
|
# Returns the buffer with the captured screenshot.
|
|
@@ -907,6 +908,33 @@ module Playwright
|
|
|
907
908
|
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)))
|
|
908
909
|
end
|
|
909
910
|
|
|
911
|
+
# This method checks or unchecks an element matching `selector` by performing the following steps:
|
|
912
|
+
# 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
|
913
|
+
# 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws.
|
|
914
|
+
# 1. If the element already has the right checked state, this method returns immediately.
|
|
915
|
+
# 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the
|
|
916
|
+
# element is detached during the checks, the whole action is retried.
|
|
917
|
+
# 1. Scroll the element into view if needed.
|
|
918
|
+
# 1. Use [`property: Page.mouse`] to click in the center of the element.
|
|
919
|
+
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
|
920
|
+
# 1. Ensure that the element is now checked or unchecked. If not, this method throws.
|
|
921
|
+
#
|
|
922
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
|
|
923
|
+
# zero timeout disables this.
|
|
924
|
+
#
|
|
925
|
+
# Shortcut for main frame's [`method: Frame.setChecked`].
|
|
926
|
+
def set_checked(
|
|
927
|
+
selector,
|
|
928
|
+
checked,
|
|
929
|
+
force: nil,
|
|
930
|
+
noWaitAfter: nil,
|
|
931
|
+
position: nil,
|
|
932
|
+
strict: nil,
|
|
933
|
+
timeout: nil,
|
|
934
|
+
trial: nil)
|
|
935
|
+
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)))
|
|
936
|
+
end
|
|
937
|
+
|
|
910
938
|
def set_content(html, timeout: nil, waitUntil: nil)
|
|
911
939
|
wrap_impl(@impl.set_content(unwrap_impl(html), timeout: unwrap_impl(timeout), waitUntil: unwrap_impl(waitUntil)))
|
|
912
940
|
end
|
|
@@ -1354,20 +1382,20 @@ module Playwright
|
|
|
1354
1382
|
|
|
1355
1383
|
# -- inherited from EventEmitter --
|
|
1356
1384
|
# @nodoc
|
|
1357
|
-
def
|
|
1358
|
-
event_emitter_proxy.
|
|
1385
|
+
def off(event, callback)
|
|
1386
|
+
event_emitter_proxy.off(event, callback)
|
|
1359
1387
|
end
|
|
1360
1388
|
|
|
1361
1389
|
# -- inherited from EventEmitter --
|
|
1362
1390
|
# @nodoc
|
|
1363
|
-
def
|
|
1364
|
-
event_emitter_proxy.
|
|
1391
|
+
def once(event, callback)
|
|
1392
|
+
event_emitter_proxy.once(event, callback)
|
|
1365
1393
|
end
|
|
1366
1394
|
|
|
1367
1395
|
# -- inherited from EventEmitter --
|
|
1368
1396
|
# @nodoc
|
|
1369
|
-
def
|
|
1370
|
-
event_emitter_proxy.
|
|
1397
|
+
def on(event, callback)
|
|
1398
|
+
event_emitter_proxy.on(event, callback)
|
|
1371
1399
|
end
|
|
1372
1400
|
|
|
1373
1401
|
private def event_emitter_proxy
|