playwright-ruby-client 0.8.1 → 1.14.beta3
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/documentation/docs/api/accessibility.md +51 -1
- data/documentation/docs/api/browser_context.md +28 -0
- data/documentation/docs/api/download.md +97 -0
- data/documentation/docs/api/element_handle.md +28 -3
- data/documentation/docs/api/experimental/android.md +15 -2
- data/documentation/docs/api/frame.md +116 -114
- data/documentation/docs/api/locator.md +650 -0
- data/documentation/docs/api/mouse.md +3 -4
- data/documentation/docs/api/page.md +109 -19
- data/documentation/docs/api/request.md +15 -19
- data/documentation/docs/api/touchscreen.md +8 -0
- data/documentation/docs/api/tracing.md +13 -12
- data/documentation/docs/api/worker.md +37 -0
- data/documentation/docs/article/guides/inspector.md +31 -0
- data/documentation/docs/article/guides/playwright_on_alpine_linux.md +1 -1
- data/documentation/docs/article/guides/semi_automation.md +1 -1
- data/documentation/docs/include/api_coverage.md +70 -14
- data/lib/playwright.rb +0 -1
- data/lib/playwright/accessibility_impl.rb +50 -0
- data/lib/playwright/channel_owners/browser_context.rb +70 -0
- data/lib/playwright/channel_owners/frame.rb +79 -33
- data/lib/playwright/channel_owners/page.rb +133 -42
- data/lib/playwright/channel_owners/request.rb +8 -8
- data/lib/playwright/channel_owners/worker.rb +23 -0
- data/lib/playwright/{download.rb → download_impl.rb} +1 -1
- data/lib/playwright/javascript/expression.rb +5 -4
- data/lib/playwright/locator_impl.rb +314 -0
- data/lib/playwright/timeout_settings.rb +4 -4
- data/lib/playwright/touchscreen_impl.rb +7 -0
- data/lib/playwright/tracing_impl.rb +9 -8
- data/lib/playwright/version.rb +2 -2
- data/lib/playwright_api/accessibility.rb +1 -1
- data/lib/playwright_api/android.rb +21 -8
- data/lib/playwright_api/android_device.rb +6 -6
- data/lib/playwright_api/browser.rb +6 -6
- data/lib/playwright_api/browser_context.rb +16 -11
- data/lib/playwright_api/browser_type.rb +6 -6
- 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/download.rb +70 -0
- data/lib/playwright_api/element_handle.rb +34 -20
- data/lib/playwright_api/frame.rb +85 -53
- data/lib/playwright_api/js_handle.rb +6 -6
- data/lib/playwright_api/locator.rb +509 -0
- data/lib/playwright_api/page.rb +91 -57
- data/lib/playwright_api/playwright.rb +6 -6
- data/lib/playwright_api/request.rb +6 -6
- data/lib/playwright_api/response.rb +6 -6
- data/lib/playwright_api/route.rb +6 -6
- data/lib/playwright_api/selectors.rb +6 -6
- data/lib/playwright_api/touchscreen.rb +1 -1
- data/lib/playwright_api/web_socket.rb +6 -6
- data/lib/playwright_api/worker.rb +16 -6
- metadata +13 -6
@@ -172,12 +172,6 @@ module Playwright
|
|
172
172
|
wrap_impl(@impl.tree)
|
173
173
|
end
|
174
174
|
|
175
|
-
# -- inherited from EventEmitter --
|
176
|
-
# @nodoc
|
177
|
-
def off(event, callback)
|
178
|
-
event_emitter_proxy.off(event, callback)
|
179
|
-
end
|
180
|
-
|
181
175
|
# -- inherited from EventEmitter --
|
182
176
|
# @nodoc
|
183
177
|
def once(event, callback)
|
@@ -190,6 +184,12 @@ module Playwright
|
|
190
184
|
event_emitter_proxy.on(event, callback)
|
191
185
|
end
|
192
186
|
|
187
|
+
# -- inherited from EventEmitter --
|
188
|
+
# @nodoc
|
189
|
+
def off(event, callback)
|
190
|
+
event_emitter_proxy.off(event, callback)
|
191
|
+
end
|
192
|
+
|
193
193
|
private def event_emitter_proxy
|
194
194
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
195
195
|
end
|
@@ -162,12 +162,6 @@ module Playwright
|
|
162
162
|
wrap_impl(@impl.version)
|
163
163
|
end
|
164
164
|
|
165
|
-
# -- inherited from EventEmitter --
|
166
|
-
# @nodoc
|
167
|
-
def off(event, callback)
|
168
|
-
event_emitter_proxy.off(event, callback)
|
169
|
-
end
|
170
|
-
|
171
165
|
# -- inherited from EventEmitter --
|
172
166
|
# @nodoc
|
173
167
|
def once(event, callback)
|
@@ -180,6 +174,12 @@ module Playwright
|
|
180
174
|
event_emitter_proxy.on(event, callback)
|
181
175
|
end
|
182
176
|
|
177
|
+
# -- inherited from EventEmitter --
|
178
|
+
# @nodoc
|
179
|
+
def off(event, callback)
|
180
|
+
event_emitter_proxy.off(event, callback)
|
181
|
+
end
|
182
|
+
|
183
183
|
private def event_emitter_proxy
|
184
184
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
185
185
|
end
|
@@ -59,7 +59,7 @@ module Playwright
|
|
59
59
|
#
|
60
60
|
# All existing background pages in the context.
|
61
61
|
def background_pages
|
62
|
-
|
62
|
+
wrap_impl(@impl.background_pages)
|
63
63
|
end
|
64
64
|
|
65
65
|
# Returns the browser instance of the context. If it was launched as a persistent context null gets returned.
|
@@ -268,7 +268,7 @@ module Playwright
|
|
268
268
|
#
|
269
269
|
# All existing service workers in the context.
|
270
270
|
def service_workers
|
271
|
-
|
271
|
+
wrap_impl(@impl.service_workers)
|
272
272
|
end
|
273
273
|
|
274
274
|
# This setting will change the default maximum navigation time for the following methods and related shortcuts:
|
@@ -325,7 +325,7 @@ module Playwright
|
|
325
325
|
|
326
326
|
# Returns storage state for this browser context, contains current cookies and local storage snapshot.
|
327
327
|
def storage_state(path: nil)
|
328
|
-
|
328
|
+
wrap_impl(@impl.storage_state(path: unwrap_impl(path)))
|
329
329
|
end
|
330
330
|
|
331
331
|
# Removes a route created with [`method: BrowserContext.route`]. When `handler` is not specified, removes all routes for
|
@@ -362,6 +362,11 @@ module Playwright
|
|
362
362
|
raise NotImplementedError.new('wait_for_event is not implemented yet.')
|
363
363
|
end
|
364
364
|
|
365
|
+
# @nodoc
|
366
|
+
def enable_debug_console!
|
367
|
+
wrap_impl(@impl.enable_debug_console!)
|
368
|
+
end
|
369
|
+
|
365
370
|
# @nodoc
|
366
371
|
def browser=(req)
|
367
372
|
wrap_impl(@impl.browser=(unwrap_impl(req)))
|
@@ -372,20 +377,14 @@ module Playwright
|
|
372
377
|
wrap_impl(@impl.owner_page=(unwrap_impl(req)))
|
373
378
|
end
|
374
379
|
|
375
|
-
# @nodoc
|
376
|
-
def options=(req)
|
377
|
-
wrap_impl(@impl.options=(unwrap_impl(req)))
|
378
|
-
end
|
379
|
-
|
380
380
|
# @nodoc
|
381
381
|
def pause
|
382
382
|
wrap_impl(@impl.pause)
|
383
383
|
end
|
384
384
|
|
385
|
-
# -- inherited from EventEmitter --
|
386
385
|
# @nodoc
|
387
|
-
def
|
388
|
-
|
386
|
+
def options=(req)
|
387
|
+
wrap_impl(@impl.options=(unwrap_impl(req)))
|
389
388
|
end
|
390
389
|
|
391
390
|
# -- inherited from EventEmitter --
|
@@ -400,6 +399,12 @@ module Playwright
|
|
400
399
|
event_emitter_proxy.on(event, callback)
|
401
400
|
end
|
402
401
|
|
402
|
+
# -- inherited from EventEmitter --
|
403
|
+
# @nodoc
|
404
|
+
def off(event, callback)
|
405
|
+
event_emitter_proxy.off(event, callback)
|
406
|
+
end
|
407
|
+
|
403
408
|
private def event_emitter_proxy
|
404
409
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
405
410
|
end
|
@@ -144,12 +144,6 @@ module Playwright
|
|
144
144
|
wrap_impl(@impl.name)
|
145
145
|
end
|
146
146
|
|
147
|
-
# -- inherited from EventEmitter --
|
148
|
-
# @nodoc
|
149
|
-
def off(event, callback)
|
150
|
-
event_emitter_proxy.off(event, callback)
|
151
|
-
end
|
152
|
-
|
153
147
|
# -- inherited from EventEmitter --
|
154
148
|
# @nodoc
|
155
149
|
def once(event, callback)
|
@@ -162,6 +156,12 @@ module Playwright
|
|
162
156
|
event_emitter_proxy.on(event, callback)
|
163
157
|
end
|
164
158
|
|
159
|
+
# -- inherited from EventEmitter --
|
160
|
+
# @nodoc
|
161
|
+
def off(event, callback)
|
162
|
+
event_emitter_proxy.off(event, callback)
|
163
|
+
end
|
164
|
+
|
165
165
|
private def event_emitter_proxy
|
166
166
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
167
167
|
end
|
@@ -33,12 +33,6 @@ module Playwright
|
|
33
33
|
wrap_impl(@impl.send_message(unwrap_impl(method), params: unwrap_impl(params)))
|
34
34
|
end
|
35
35
|
|
36
|
-
# -- inherited from EventEmitter --
|
37
|
-
# @nodoc
|
38
|
-
def off(event, callback)
|
39
|
-
event_emitter_proxy.off(event, callback)
|
40
|
-
end
|
41
|
-
|
42
36
|
# -- inherited from EventEmitter --
|
43
37
|
# @nodoc
|
44
38
|
def once(event, callback)
|
@@ -51,6 +45,12 @@ module Playwright
|
|
51
45
|
event_emitter_proxy.on(event, callback)
|
52
46
|
end
|
53
47
|
|
48
|
+
# -- inherited from EventEmitter --
|
49
|
+
# @nodoc
|
50
|
+
def off(event, callback)
|
51
|
+
event_emitter_proxy.off(event, callback)
|
52
|
+
end
|
53
|
+
|
54
54
|
private def event_emitter_proxy
|
55
55
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
56
56
|
end
|
@@ -23,12 +23,6 @@ module Playwright
|
|
23
23
|
wrap_impl(@impl.type)
|
24
24
|
end
|
25
25
|
|
26
|
-
# -- inherited from EventEmitter --
|
27
|
-
# @nodoc
|
28
|
-
def off(event, callback)
|
29
|
-
event_emitter_proxy.off(event, callback)
|
30
|
-
end
|
31
|
-
|
32
26
|
# -- inherited from EventEmitter --
|
33
27
|
# @nodoc
|
34
28
|
def once(event, callback)
|
@@ -41,6 +35,12 @@ module Playwright
|
|
41
35
|
event_emitter_proxy.on(event, callback)
|
42
36
|
end
|
43
37
|
|
38
|
+
# -- inherited from EventEmitter --
|
39
|
+
# @nodoc
|
40
|
+
def off(event, callback)
|
41
|
+
event_emitter_proxy.off(event, callback)
|
42
|
+
end
|
43
|
+
|
44
44
|
private def event_emitter_proxy
|
45
45
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
46
46
|
end
|
@@ -58,12 +58,6 @@ module Playwright
|
|
58
58
|
wrap_impl(@impl.accept_async(promptText: unwrap_impl(promptText)))
|
59
59
|
end
|
60
60
|
|
61
|
-
# -- inherited from EventEmitter --
|
62
|
-
# @nodoc
|
63
|
-
def off(event, callback)
|
64
|
-
event_emitter_proxy.off(event, callback)
|
65
|
-
end
|
66
|
-
|
67
61
|
# -- inherited from EventEmitter --
|
68
62
|
# @nodoc
|
69
63
|
def once(event, callback)
|
@@ -76,6 +70,12 @@ module Playwright
|
|
76
70
|
event_emitter_proxy.on(event, callback)
|
77
71
|
end
|
78
72
|
|
73
|
+
# -- inherited from EventEmitter --
|
74
|
+
# @nodoc
|
75
|
+
def off(event, callback)
|
76
|
+
event_emitter_proxy.off(event, callback)
|
77
|
+
end
|
78
|
+
|
79
79
|
private def event_emitter_proxy
|
80
80
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
81
81
|
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Playwright
|
2
|
+
# `Download` objects are dispatched by page via the [`event: Page.download`] event.
|
3
|
+
#
|
4
|
+
# All the downloaded files belonging to the browser context are deleted when the browser context is closed.
|
5
|
+
#
|
6
|
+
# Download event is emitted once the download starts. Download path becomes available once download completes:
|
7
|
+
#
|
8
|
+
# ```python sync
|
9
|
+
# with page.expect_download() as download_info:
|
10
|
+
# page.click("a")
|
11
|
+
# download = download_info.value
|
12
|
+
# # wait for download to complete
|
13
|
+
# path = download.path()
|
14
|
+
# ```
|
15
|
+
#
|
16
|
+
# > NOTE: Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the
|
17
|
+
# downloaded content. If `acceptDownloads` is not set, download events are emitted, but the actual download is not
|
18
|
+
# performed and user has no access to the downloaded files.
|
19
|
+
class Download < PlaywrightApi
|
20
|
+
|
21
|
+
# Cancels a download. Will not fail if the download is already finished or canceled. Upon successful cancellations,
|
22
|
+
# `download.failure()` would resolve to `'canceled'`.
|
23
|
+
def cancel
|
24
|
+
wrap_impl(@impl.cancel)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Deletes the downloaded file. Will wait for the download to finish if necessary.
|
28
|
+
def delete
|
29
|
+
wrap_impl(@impl.delete)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Returns download error if any. Will wait for the download to finish if necessary.
|
33
|
+
def failure
|
34
|
+
wrap_impl(@impl.failure)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Get the page that the download belongs to.
|
38
|
+
def page
|
39
|
+
wrap_impl(@impl.page)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Returns path to the downloaded file in case of successful download. The method will wait for the download to finish if
|
43
|
+
# necessary. The method throws when connected remotely.
|
44
|
+
#
|
45
|
+
# Note that the download's file name is a random GUID, use [`method: Download.suggestedFilename`] to get suggested file
|
46
|
+
# name.
|
47
|
+
def path
|
48
|
+
wrap_impl(@impl.path)
|
49
|
+
end
|
50
|
+
|
51
|
+
# Copy the download to a user-specified path. It is safe to call this method while the download is still in progress. Will
|
52
|
+
# wait for the download to finish if necessary.
|
53
|
+
def save_as(path)
|
54
|
+
wrap_impl(@impl.save_as(unwrap_impl(path)))
|
55
|
+
end
|
56
|
+
|
57
|
+
# Returns suggested filename for this download. It is typically computed by the browser from the
|
58
|
+
# [`Content-Disposition`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition) response header
|
59
|
+
# or the `download` attribute. See the spec on [whatwg](https://html.spec.whatwg.org/#downloading-resources). Different
|
60
|
+
# browsers can use different logic for computing it.
|
61
|
+
def suggested_filename
|
62
|
+
wrap_impl(@impl.suggested_filename)
|
63
|
+
end
|
64
|
+
|
65
|
+
# Returns downloaded url.
|
66
|
+
def url
|
67
|
+
wrap_impl(@impl.url)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -7,19 +7,8 @@ module Playwright
|
|
7
7
|
# method.
|
8
8
|
#
|
9
9
|
# ```python sync
|
10
|
-
#
|
11
|
-
#
|
12
|
-
# def run(playwright):
|
13
|
-
# chromium = playwright.chromium
|
14
|
-
# browser = chromium.launch()
|
15
|
-
# page = browser.new_page()
|
16
|
-
# page.goto("https://example.com")
|
17
|
-
# href_element = page.query_selector("a")
|
18
|
-
# href_element.click()
|
19
|
-
# # ...
|
20
|
-
#
|
21
|
-
# with sync_playwright() as playwright:
|
22
|
-
# run(playwright)
|
10
|
+
# href_element = page.query_selector("a")
|
11
|
+
# href_element.click()
|
23
12
|
# ```
|
24
13
|
#
|
25
14
|
# ElementHandle prevents DOM element from garbage collection unless the handle is disposed with
|
@@ -27,6 +16,31 @@ module Playwright
|
|
27
16
|
#
|
28
17
|
# ElementHandle instances can be used as an argument in [`method: Page.evalOnSelector`] and [`method: Page.evaluate`]
|
29
18
|
# methods.
|
19
|
+
#
|
20
|
+
# > NOTE: In most cases, you would want to use the `Locator` object instead. You should only use `ElementHandle` if you
|
21
|
+
# want to retain a handle to a particular DOM Node that you intend to pass into [`method: Page.evaluate`] as an argument.
|
22
|
+
#
|
23
|
+
# The difference between the `Locator` and ElementHandle is that the ElementHandle points to a particular element, while
|
24
|
+
# `Locator` captures the logic of how to retrieve an element.
|
25
|
+
#
|
26
|
+
# In the example below, handle points to a particular DOM element on page. If that element changes text or is used by
|
27
|
+
# React to render an entirely different component, handle is still pointing to that very DOM element. This can lead to
|
28
|
+
# unexpected behaviors.
|
29
|
+
#
|
30
|
+
# ```python sync
|
31
|
+
# handle = page.query_selector("text=Submit")
|
32
|
+
# handle.hover()
|
33
|
+
# handle.click()
|
34
|
+
# ```
|
35
|
+
#
|
36
|
+
# With the locator, every time the `element` is used, up-to-date DOM element is located in the page using the selector. So
|
37
|
+
# in the snippet below, underlying DOM element is going to be located twice.
|
38
|
+
#
|
39
|
+
# ```python sync
|
40
|
+
# locator = page.locator("text=Submit")
|
41
|
+
# locator.hover()
|
42
|
+
# locator.click()
|
43
|
+
# ```
|
30
44
|
class ElementHandle < JSHandle
|
31
45
|
|
32
46
|
# This method returns the bounding box of the element, or `null` if the element is not visible. The bounding box is
|
@@ -254,7 +268,7 @@ module Playwright
|
|
254
268
|
wrap_impl(@impl.inner_text)
|
255
269
|
end
|
256
270
|
|
257
|
-
# Returns `input.value` for `<input>` or `<textarea>` element. Throws for non-input elements.
|
271
|
+
# Returns `input.value` for `<input>` or `<textarea>` or `<select>` element. Throws for non-input elements.
|
258
272
|
def input_value(timeout: nil)
|
259
273
|
wrap_impl(@impl.input_value(timeout: unwrap_impl(timeout)))
|
260
274
|
end
|
@@ -515,12 +529,6 @@ module Playwright
|
|
515
529
|
wrap_impl(@impl.wait_for_selector(unwrap_impl(selector), state: unwrap_impl(state), timeout: unwrap_impl(timeout)))
|
516
530
|
end
|
517
531
|
|
518
|
-
# -- inherited from EventEmitter --
|
519
|
-
# @nodoc
|
520
|
-
def off(event, callback)
|
521
|
-
event_emitter_proxy.off(event, callback)
|
522
|
-
end
|
523
|
-
|
524
532
|
# -- inherited from EventEmitter --
|
525
533
|
# @nodoc
|
526
534
|
def once(event, callback)
|
@@ -533,6 +541,12 @@ module Playwright
|
|
533
541
|
event_emitter_proxy.on(event, callback)
|
534
542
|
end
|
535
543
|
|
544
|
+
# -- inherited from EventEmitter --
|
545
|
+
# @nodoc
|
546
|
+
def off(event, callback)
|
547
|
+
event_emitter_proxy.off(event, callback)
|
548
|
+
end
|
549
|
+
|
536
550
|
private def event_emitter_proxy
|
537
551
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
538
552
|
end
|
data/lib/playwright_api/frame.rb
CHANGED
@@ -65,9 +65,10 @@ module Playwright
|
|
65
65
|
force: nil,
|
66
66
|
noWaitAfter: nil,
|
67
67
|
position: nil,
|
68
|
+
strict: nil,
|
68
69
|
timeout: nil,
|
69
70
|
trial: nil)
|
70
|
-
wrap_impl(@impl.check(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
71
|
+
wrap_impl(@impl.check(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
71
72
|
end
|
72
73
|
|
73
74
|
def child_frames
|
@@ -93,9 +94,10 @@ module Playwright
|
|
93
94
|
modifiers: nil,
|
94
95
|
noWaitAfter: nil,
|
95
96
|
position: nil,
|
97
|
+
strict: nil,
|
96
98
|
timeout: nil,
|
97
99
|
trial: nil)
|
98
|
-
wrap_impl(@impl.click(unwrap_impl(selector), button: unwrap_impl(button), clickCount: unwrap_impl(clickCount), delay: unwrap_impl(delay), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
100
|
+
wrap_impl(@impl.click(unwrap_impl(selector), button: unwrap_impl(button), clickCount: unwrap_impl(clickCount), delay: unwrap_impl(delay), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
99
101
|
end
|
100
102
|
|
101
103
|
# Gets the full HTML contents of the frame, including the doctype.
|
@@ -124,9 +126,10 @@ module Playwright
|
|
124
126
|
modifiers: nil,
|
125
127
|
noWaitAfter: nil,
|
126
128
|
position: nil,
|
129
|
+
strict: nil,
|
127
130
|
timeout: nil,
|
128
131
|
trial: nil)
|
129
|
-
wrap_impl(@impl.dblclick(unwrap_impl(selector), button: unwrap_impl(button), delay: unwrap_impl(delay), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
132
|
+
wrap_impl(@impl.dblclick(unwrap_impl(selector), button: unwrap_impl(button), delay: unwrap_impl(delay), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
130
133
|
end
|
131
134
|
|
132
135
|
# The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element,
|
@@ -156,8 +159,13 @@ module Playwright
|
|
156
159
|
# data_transfer = frame.evaluate_handle("new DataTransfer()")
|
157
160
|
# frame.dispatch_event("#source", "dragstart", { "dataTransfer": data_transfer })
|
158
161
|
# ```
|
159
|
-
def dispatch_event(
|
160
|
-
|
162
|
+
def dispatch_event(
|
163
|
+
selector,
|
164
|
+
type,
|
165
|
+
eventInit: nil,
|
166
|
+
strict: nil,
|
167
|
+
timeout: nil)
|
168
|
+
wrap_impl(@impl.dispatch_event(unwrap_impl(selector), unwrap_impl(type), eventInit: unwrap_impl(eventInit), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
161
169
|
end
|
162
170
|
|
163
171
|
def drag_and_drop(
|
@@ -165,9 +173,12 @@ module Playwright
|
|
165
173
|
target,
|
166
174
|
force: nil,
|
167
175
|
noWaitAfter: nil,
|
176
|
+
sourcePosition: nil,
|
177
|
+
strict: nil,
|
178
|
+
targetPosition: nil,
|
168
179
|
timeout: nil,
|
169
180
|
trial: nil)
|
170
|
-
wrap_impl(@impl.drag_and_drop(unwrap_impl(source), unwrap_impl(target), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
181
|
+
wrap_impl(@impl.drag_and_drop(unwrap_impl(source), unwrap_impl(target), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), sourcePosition: unwrap_impl(sourcePosition), strict: unwrap_impl(strict), targetPosition: unwrap_impl(targetPosition), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
171
182
|
end
|
172
183
|
|
173
184
|
# Returns the return value of `expression`.
|
@@ -186,8 +197,8 @@ module Playwright
|
|
186
197
|
# preload_href = frame.eval_on_selector("link[rel=preload]", "el => el.href")
|
187
198
|
# html = frame.eval_on_selector(".main-container", "(e, suffix) => e.outerHTML + suffix", "hello")
|
188
199
|
# ```
|
189
|
-
def eval_on_selector(selector, expression, arg: nil)
|
190
|
-
wrap_impl(@impl.eval_on_selector(unwrap_impl(selector), unwrap_impl(expression), arg: unwrap_impl(arg)))
|
200
|
+
def eval_on_selector(selector, expression, arg: nil, strict: nil)
|
201
|
+
wrap_impl(@impl.eval_on_selector(unwrap_impl(selector), unwrap_impl(expression), arg: unwrap_impl(arg), strict: unwrap_impl(strict)))
|
191
202
|
end
|
192
203
|
|
193
204
|
# Returns the return value of `expression`.
|
@@ -286,14 +297,15 @@ module Playwright
|
|
286
297
|
value,
|
287
298
|
force: nil,
|
288
299
|
noWaitAfter: nil,
|
300
|
+
strict: nil,
|
289
301
|
timeout: nil)
|
290
|
-
wrap_impl(@impl.fill(unwrap_impl(selector), unwrap_impl(value), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
302
|
+
wrap_impl(@impl.fill(unwrap_impl(selector), unwrap_impl(value), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
291
303
|
end
|
292
304
|
|
293
305
|
# This method fetches an element with `selector` and focuses it. If there's no element matching `selector`, the method
|
294
306
|
# waits until a matching element appears in the DOM.
|
295
|
-
def focus(selector, timeout: nil)
|
296
|
-
wrap_impl(@impl.focus(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
|
307
|
+
def focus(selector, strict: nil, timeout: nil)
|
308
|
+
wrap_impl(@impl.focus(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
297
309
|
end
|
298
310
|
|
299
311
|
# Returns the `frame` or `iframe` element handle which corresponds to this frame.
|
@@ -313,8 +325,8 @@ module Playwright
|
|
313
325
|
end
|
314
326
|
|
315
327
|
# Returns element attribute value.
|
316
|
-
def get_attribute(selector, name, timeout: nil)
|
317
|
-
wrap_impl(@impl.get_attribute(unwrap_impl(selector), unwrap_impl(name), timeout: unwrap_impl(timeout)))
|
328
|
+
def get_attribute(selector, name, strict: nil, timeout: nil)
|
329
|
+
wrap_impl(@impl.get_attribute(unwrap_impl(selector), unwrap_impl(name), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
318
330
|
end
|
319
331
|
|
320
332
|
# Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
|
@@ -354,29 +366,30 @@ module Playwright
|
|
354
366
|
force: nil,
|
355
367
|
modifiers: nil,
|
356
368
|
position: nil,
|
369
|
+
strict: nil,
|
357
370
|
timeout: nil,
|
358
371
|
trial: nil)
|
359
|
-
wrap_impl(@impl.hover(unwrap_impl(selector), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
372
|
+
wrap_impl(@impl.hover(unwrap_impl(selector), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), position: unwrap_impl(position), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
360
373
|
end
|
361
374
|
|
362
375
|
# Returns `element.innerHTML`.
|
363
|
-
def inner_html(selector, timeout: nil)
|
364
|
-
wrap_impl(@impl.inner_html(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
|
376
|
+
def inner_html(selector, strict: nil, timeout: nil)
|
377
|
+
wrap_impl(@impl.inner_html(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
365
378
|
end
|
366
379
|
|
367
380
|
# Returns `element.innerText`.
|
368
|
-
def inner_text(selector, timeout: nil)
|
369
|
-
wrap_impl(@impl.inner_text(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
|
381
|
+
def inner_text(selector, strict: nil, timeout: nil)
|
382
|
+
wrap_impl(@impl.inner_text(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
370
383
|
end
|
371
384
|
|
372
|
-
# Returns `input.value` for the selected `<input>` or `<textarea>` element. Throws for non-input elements.
|
373
|
-
def input_value(selector, timeout: nil)
|
374
|
-
wrap_impl(@impl.input_value(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
|
385
|
+
# Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element. Throws for non-input elements.
|
386
|
+
def input_value(selector, strict: nil, timeout: nil)
|
387
|
+
wrap_impl(@impl.input_value(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
375
388
|
end
|
376
389
|
|
377
390
|
# Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
|
378
|
-
def checked?(selector, timeout: nil)
|
379
|
-
wrap_impl(@impl.checked?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
|
391
|
+
def checked?(selector, strict: nil, timeout: nil)
|
392
|
+
wrap_impl(@impl.checked?(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
380
393
|
end
|
381
394
|
|
382
395
|
# Returns `true` if the frame has been detached, or `false` otherwise.
|
@@ -385,30 +398,39 @@ module Playwright
|
|
385
398
|
end
|
386
399
|
|
387
400
|
# Returns whether the element is disabled, the opposite of [enabled](./actionability.md#enabled).
|
388
|
-
def disabled?(selector, timeout: nil)
|
389
|
-
wrap_impl(@impl.disabled?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
|
401
|
+
def disabled?(selector, strict: nil, timeout: nil)
|
402
|
+
wrap_impl(@impl.disabled?(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
390
403
|
end
|
391
404
|
|
392
405
|
# Returns whether the element is [editable](./actionability.md#editable).
|
393
|
-
def editable?(selector, timeout: nil)
|
394
|
-
wrap_impl(@impl.editable?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
|
406
|
+
def editable?(selector, strict: nil, timeout: nil)
|
407
|
+
wrap_impl(@impl.editable?(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
395
408
|
end
|
396
409
|
|
397
410
|
# Returns whether the element is [enabled](./actionability.md#enabled).
|
398
|
-
def enabled?(selector, timeout: nil)
|
399
|
-
wrap_impl(@impl.enabled?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
|
411
|
+
def enabled?(selector, strict: nil, timeout: nil)
|
412
|
+
wrap_impl(@impl.enabled?(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
400
413
|
end
|
401
414
|
|
402
415
|
# Returns whether the element is hidden, the opposite of [visible](./actionability.md#visible). `selector` that does not
|
403
416
|
# match any elements is considered hidden.
|
404
|
-
def hidden?(selector, timeout: nil)
|
405
|
-
wrap_impl(@impl.hidden?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
|
417
|
+
def hidden?(selector, strict: nil, timeout: nil)
|
418
|
+
wrap_impl(@impl.hidden?(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
406
419
|
end
|
407
420
|
|
408
421
|
# Returns whether the element is [visible](./actionability.md#visible). `selector` that does not match any elements is
|
409
422
|
# considered not visible.
|
410
|
-
def visible?(selector, timeout: nil)
|
411
|
-
wrap_impl(@impl.visible?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
|
423
|
+
def visible?(selector, strict: nil, timeout: nil)
|
424
|
+
wrap_impl(@impl.visible?(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
425
|
+
end
|
426
|
+
|
427
|
+
# The method returns an element locator that can be used to perform actions in the frame. Locator is resolved to the
|
428
|
+
# element immediately before performing an action, so a series of actions on the same locator can in fact be performed on
|
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
|
+
def locator(selector)
|
433
|
+
wrap_impl(@impl.locator(unwrap_impl(selector)))
|
412
434
|
end
|
413
435
|
|
414
436
|
# Returns frame's name attribute as specified in the tag.
|
@@ -451,16 +473,17 @@ module Playwright
|
|
451
473
|
key,
|
452
474
|
delay: nil,
|
453
475
|
noWaitAfter: nil,
|
476
|
+
strict: nil,
|
454
477
|
timeout: nil)
|
455
|
-
wrap_impl(@impl.press(unwrap_impl(selector), unwrap_impl(key), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
478
|
+
wrap_impl(@impl.press(unwrap_impl(selector), unwrap_impl(key), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
456
479
|
end
|
457
480
|
|
458
481
|
# Returns the ElementHandle pointing to the frame element.
|
459
482
|
#
|
460
483
|
# The method finds an element matching the specified selector within the frame. See
|
461
484
|
# [Working with selectors](./selectors.md) for more details. If no elements match the selector, returns `null`.
|
462
|
-
def query_selector(selector)
|
463
|
-
wrap_impl(@impl.query_selector(unwrap_impl(selector)))
|
485
|
+
def query_selector(selector, strict: nil)
|
486
|
+
wrap_impl(@impl.query_selector(unwrap_impl(selector), strict: unwrap_impl(strict)))
|
464
487
|
end
|
465
488
|
|
466
489
|
# Returns the ElementHandles pointing to the frame elements.
|
@@ -498,8 +521,9 @@ module Playwright
|
|
498
521
|
label: nil,
|
499
522
|
force: nil,
|
500
523
|
noWaitAfter: nil,
|
524
|
+
strict: nil,
|
501
525
|
timeout: nil)
|
502
|
-
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), timeout: unwrap_impl(timeout)))
|
526
|
+
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)))
|
503
527
|
end
|
504
528
|
|
505
529
|
def set_content(html, timeout: nil, waitUntil: nil)
|
@@ -512,8 +536,13 @@ module Playwright
|
|
512
536
|
#
|
513
537
|
# Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
|
514
538
|
# are resolved relative to the the current working directory. For empty array, clears the selected files.
|
515
|
-
def set_input_files(
|
516
|
-
|
539
|
+
def set_input_files(
|
540
|
+
selector,
|
541
|
+
files,
|
542
|
+
noWaitAfter: nil,
|
543
|
+
strict: nil,
|
544
|
+
timeout: nil)
|
545
|
+
wrap_impl(@impl.set_input_files(unwrap_impl(selector), unwrap_impl(files), noWaitAfter: unwrap_impl(noWaitAfter), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
517
546
|
end
|
518
547
|
|
519
548
|
# This method taps an element matching `selector` by performing the following steps:
|
@@ -534,14 +563,15 @@ module Playwright
|
|
534
563
|
modifiers: nil,
|
535
564
|
noWaitAfter: nil,
|
536
565
|
position: nil,
|
566
|
+
strict: nil,
|
537
567
|
timeout: nil,
|
538
568
|
trial: nil)
|
539
|
-
wrap_impl(@impl.tap_point(unwrap_impl(selector), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
569
|
+
wrap_impl(@impl.tap_point(unwrap_impl(selector), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
540
570
|
end
|
541
571
|
|
542
572
|
# Returns `element.textContent`.
|
543
|
-
def text_content(selector, timeout: nil)
|
544
|
-
wrap_impl(@impl.text_content(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
|
573
|
+
def text_content(selector, strict: nil, timeout: nil)
|
574
|
+
wrap_impl(@impl.text_content(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
545
575
|
end
|
546
576
|
|
547
577
|
# Returns the page title.
|
@@ -563,8 +593,9 @@ module Playwright
|
|
563
593
|
text,
|
564
594
|
delay: nil,
|
565
595
|
noWaitAfter: nil,
|
596
|
+
strict: nil,
|
566
597
|
timeout: nil)
|
567
|
-
wrap_impl(@impl.type(unwrap_impl(selector), unwrap_impl(text), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
598
|
+
wrap_impl(@impl.type(unwrap_impl(selector), unwrap_impl(text), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
568
599
|
end
|
569
600
|
|
570
601
|
# This method checks an element matching `selector` by performing the following steps:
|
@@ -585,9 +616,10 @@ module Playwright
|
|
585
616
|
force: nil,
|
586
617
|
noWaitAfter: nil,
|
587
618
|
position: nil,
|
619
|
+
strict: nil,
|
588
620
|
timeout: nil,
|
589
621
|
trial: nil)
|
590
|
-
wrap_impl(@impl.uncheck(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
622
|
+
wrap_impl(@impl.uncheck(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
591
623
|
end
|
592
624
|
|
593
625
|
# Returns frame's url.
|
@@ -681,8 +713,8 @@ module Playwright
|
|
681
713
|
# with sync_playwright() as playwright:
|
682
714
|
# run(playwright)
|
683
715
|
# ```
|
684
|
-
def wait_for_selector(selector, state: nil, timeout: nil)
|
685
|
-
wrap_impl(@impl.wait_for_selector(unwrap_impl(selector), state: unwrap_impl(state), timeout: unwrap_impl(timeout)))
|
716
|
+
def wait_for_selector(selector, state: nil, strict: nil, timeout: nil)
|
717
|
+
wrap_impl(@impl.wait_for_selector(unwrap_impl(selector), state: unwrap_impl(state), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
686
718
|
end
|
687
719
|
|
688
720
|
# Waits for the given `timeout` in milliseconds.
|
@@ -690,7 +722,7 @@ module Playwright
|
|
690
722
|
# Note that `frame.waitForTimeout()` should only be used for debugging. Tests using the timer in production are going to
|
691
723
|
# be flaky. Use signals such as network events, selectors becoming visible and others instead.
|
692
724
|
def wait_for_timeout(timeout)
|
693
|
-
|
725
|
+
wrap_impl(@impl.wait_for_timeout(unwrap_impl(timeout)))
|
694
726
|
end
|
695
727
|
|
696
728
|
# Waits for the frame to navigate to the given URL.
|
@@ -708,12 +740,6 @@ module Playwright
|
|
708
740
|
wrap_impl(@impl.detached=(unwrap_impl(req)))
|
709
741
|
end
|
710
742
|
|
711
|
-
# -- inherited from EventEmitter --
|
712
|
-
# @nodoc
|
713
|
-
def off(event, callback)
|
714
|
-
event_emitter_proxy.off(event, callback)
|
715
|
-
end
|
716
|
-
|
717
743
|
# -- inherited from EventEmitter --
|
718
744
|
# @nodoc
|
719
745
|
def once(event, callback)
|
@@ -726,6 +752,12 @@ module Playwright
|
|
726
752
|
event_emitter_proxy.on(event, callback)
|
727
753
|
end
|
728
754
|
|
755
|
+
# -- inherited from EventEmitter --
|
756
|
+
# @nodoc
|
757
|
+
def off(event, callback)
|
758
|
+
event_emitter_proxy.off(event, callback)
|
759
|
+
end
|
760
|
+
|
729
761
|
private def event_emitter_proxy
|
730
762
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
731
763
|
end
|