playwright-ruby-client 1.14.beta1 → 1.15.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/documentation/docs/api/accessibility.md +16 -17
- data/documentation/docs/api/browser.md +2 -0
- data/documentation/docs/api/browser_type.md +1 -0
- data/documentation/docs/api/element_handle.md +4 -5
- data/documentation/docs/api/experimental/android.md +15 -2
- data/documentation/docs/api/experimental/android_device.md +1 -0
- data/documentation/docs/api/frame.md +62 -106
- data/documentation/docs/api/locator.md +41 -41
- data/documentation/docs/api/mouse.md +3 -4
- data/documentation/docs/api/page.md +6 -6
- data/documentation/docs/api/request.md +15 -19
- data/documentation/docs/api/selectors.md +29 -3
- data/documentation/docs/api/tracing.md +13 -12
- data/documentation/docs/api/worker.md +12 -11
- data/documentation/docs/article/guides/inspector.md +1 -1
- 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/article/guides/use_storage_state.md +78 -0
- data/lib/playwright.rb +44 -4
- data/lib/playwright/channel_owners/browser_type.rb +0 -1
- data/lib/playwright/channel_owners/frame.rb +5 -0
- data/lib/playwright/channel_owners/page.rb +4 -0
- data/lib/playwright/channel_owners/playwright.rb +9 -0
- data/lib/playwright/channel_owners/request.rb +8 -8
- data/lib/playwright/connection.rb +3 -8
- data/lib/playwright/locator_impl.rb +3 -3
- data/lib/playwright/tracing_impl.rb +9 -8
- data/lib/playwright/utils.rb +0 -1
- data/lib/playwright/version.rb +2 -2
- data/lib/playwright_api/android.rb +21 -8
- data/lib/playwright_api/android_device.rb +8 -7
- data/lib/playwright_api/browser.rb +10 -8
- data/lib/playwright_api/browser_context.rb +6 -6
- data/lib/playwright_api/browser_type.rb +8 -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 +7 -7
- data/lib/playwright_api/frame.rb +14 -14
- data/lib/playwright_api/js_handle.rb +6 -6
- data/lib/playwright_api/locator.rb +16 -3
- data/lib/playwright_api/page.rb +13 -13
- 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 +38 -7
- data/lib/playwright_api/web_socket.rb +6 -6
- data/lib/playwright_api/worker.rb +6 -6
- metadata +4 -3
@@ -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 once(event, callback)
|
39
|
-
event_emitter_proxy.once(event, callback)
|
40
|
-
end
|
41
|
-
|
42
36
|
# -- inherited from EventEmitter --
|
43
37
|
# @nodoc
|
44
38
|
def on(event, callback)
|
@@ -51,6 +45,12 @@ module Playwright
|
|
51
45
|
event_emitter_proxy.off(event, callback)
|
52
46
|
end
|
53
47
|
|
48
|
+
# -- inherited from EventEmitter --
|
49
|
+
# @nodoc
|
50
|
+
def once(event, callback)
|
51
|
+
event_emitter_proxy.once(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 once(event, callback)
|
29
|
-
event_emitter_proxy.once(event, callback)
|
30
|
-
end
|
31
|
-
|
32
26
|
# -- inherited from EventEmitter --
|
33
27
|
# @nodoc
|
34
28
|
def on(event, callback)
|
@@ -41,6 +35,12 @@ module Playwright
|
|
41
35
|
event_emitter_proxy.off(event, callback)
|
42
36
|
end
|
43
37
|
|
38
|
+
# -- inherited from EventEmitter --
|
39
|
+
# @nodoc
|
40
|
+
def once(event, callback)
|
41
|
+
event_emitter_proxy.once(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 once(event, callback)
|
64
|
-
event_emitter_proxy.once(event, callback)
|
65
|
-
end
|
66
|
-
|
67
61
|
# -- inherited from EventEmitter --
|
68
62
|
# @nodoc
|
69
63
|
def on(event, callback)
|
@@ -76,6 +70,12 @@ module Playwright
|
|
76
70
|
event_emitter_proxy.off(event, callback)
|
77
71
|
end
|
78
72
|
|
73
|
+
# -- inherited from EventEmitter --
|
74
|
+
# @nodoc
|
75
|
+
def once(event, callback)
|
76
|
+
event_emitter_proxy.once(event, callback)
|
77
|
+
end
|
78
|
+
|
79
79
|
private def event_emitter_proxy
|
80
80
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
81
81
|
end
|
@@ -268,7 +268,7 @@ module Playwright
|
|
268
268
|
wrap_impl(@impl.inner_text)
|
269
269
|
end
|
270
270
|
|
271
|
-
# 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.
|
272
272
|
def input_value(timeout: nil)
|
273
273
|
wrap_impl(@impl.input_value(timeout: unwrap_impl(timeout)))
|
274
274
|
end
|
@@ -529,12 +529,6 @@ module Playwright
|
|
529
529
|
wrap_impl(@impl.wait_for_selector(unwrap_impl(selector), state: unwrap_impl(state), timeout: unwrap_impl(timeout)))
|
530
530
|
end
|
531
531
|
|
532
|
-
# -- inherited from EventEmitter --
|
533
|
-
# @nodoc
|
534
|
-
def once(event, callback)
|
535
|
-
event_emitter_proxy.once(event, callback)
|
536
|
-
end
|
537
|
-
|
538
532
|
# -- inherited from EventEmitter --
|
539
533
|
# @nodoc
|
540
534
|
def on(event, callback)
|
@@ -547,6 +541,12 @@ module Playwright
|
|
547
541
|
event_emitter_proxy.off(event, callback)
|
548
542
|
end
|
549
543
|
|
544
|
+
# -- inherited from EventEmitter --
|
545
|
+
# @nodoc
|
546
|
+
def once(event, callback)
|
547
|
+
event_emitter_proxy.once(event, callback)
|
548
|
+
end
|
549
|
+
|
550
550
|
private def event_emitter_proxy
|
551
551
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
552
552
|
end
|
data/lib/playwright_api/frame.rb
CHANGED
@@ -173,10 +173,12 @@ module Playwright
|
|
173
173
|
target,
|
174
174
|
force: nil,
|
175
175
|
noWaitAfter: nil,
|
176
|
+
sourcePosition: nil,
|
176
177
|
strict: nil,
|
178
|
+
targetPosition: nil,
|
177
179
|
timeout: nil,
|
178
180
|
trial: nil)
|
179
|
-
wrap_impl(@impl.drag_and_drop(unwrap_impl(source), unwrap_impl(target), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), strict: unwrap_impl(strict), 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)))
|
180
182
|
end
|
181
183
|
|
182
184
|
# Returns the return value of `expression`.
|
@@ -330,18 +332,18 @@ module Playwright
|
|
330
332
|
# Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
|
331
333
|
# last redirect.
|
332
334
|
#
|
333
|
-
#
|
335
|
+
# The method will throw an error if:
|
334
336
|
# - there's an SSL error (e.g. in case of self-signed certificates).
|
335
337
|
# - target URL is invalid.
|
336
338
|
# - the `timeout` is exceeded during navigation.
|
337
339
|
# - the remote server does not respond or is unreachable.
|
338
340
|
# - the main resource failed to load.
|
339
341
|
#
|
340
|
-
#
|
341
|
-
#
|
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
|
342
344
|
# [`method: Response.status`].
|
343
345
|
#
|
344
|
-
# > NOTE:
|
346
|
+
# > NOTE: The method either throws an error or returns a main resource response. The only exceptions are navigation to
|
345
347
|
# `about:blank` or navigation to the same URL with a different hash, which would succeed and return `null`.
|
346
348
|
# > NOTE: Headless mode doesn't support navigation to a PDF document. See the
|
347
349
|
# [upstream issue](https://bugs.chromium.org/p/chromium/issues/detail?id=761295).
|
@@ -380,7 +382,7 @@ module Playwright
|
|
380
382
|
wrap_impl(@impl.inner_text(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
381
383
|
end
|
382
384
|
|
383
|
-
# Returns `input.value` for the selected `<input>` or `<textarea>` element. Throws for non-input elements.
|
385
|
+
# Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element. Throws for non-input elements.
|
384
386
|
def input_value(selector, strict: nil, timeout: nil)
|
385
387
|
wrap_impl(@impl.input_value(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
386
388
|
end
|
@@ -425,8 +427,6 @@ module Playwright
|
|
425
427
|
# The method returns an element locator that can be used to perform actions in the frame. Locator is resolved to the
|
426
428
|
# element immediately before performing an action, so a series of actions on the same locator can in fact be performed on
|
427
429
|
# different DOM elements. That would happen if the DOM structure between those actions has changed.
|
428
|
-
#
|
429
|
-
# Note that locator always implies visibility, so it will always be locating visible elements.
|
430
430
|
def locator(selector)
|
431
431
|
wrap_impl(@impl.locator(unwrap_impl(selector)))
|
432
432
|
end
|
@@ -738,12 +738,6 @@ module Playwright
|
|
738
738
|
wrap_impl(@impl.detached=(unwrap_impl(req)))
|
739
739
|
end
|
740
740
|
|
741
|
-
# -- inherited from EventEmitter --
|
742
|
-
# @nodoc
|
743
|
-
def once(event, callback)
|
744
|
-
event_emitter_proxy.once(event, callback)
|
745
|
-
end
|
746
|
-
|
747
741
|
# -- inherited from EventEmitter --
|
748
742
|
# @nodoc
|
749
743
|
def on(event, callback)
|
@@ -756,6 +750,12 @@ module Playwright
|
|
756
750
|
event_emitter_proxy.off(event, callback)
|
757
751
|
end
|
758
752
|
|
753
|
+
# -- inherited from EventEmitter --
|
754
|
+
# @nodoc
|
755
|
+
def once(event, callback)
|
756
|
+
event_emitter_proxy.once(event, callback)
|
757
|
+
end
|
758
|
+
|
759
759
|
private def event_emitter_proxy
|
760
760
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
761
761
|
end
|
@@ -88,12 +88,6 @@ module Playwright
|
|
88
88
|
wrap_impl(@impl.to_s)
|
89
89
|
end
|
90
90
|
|
91
|
-
# -- inherited from EventEmitter --
|
92
|
-
# @nodoc
|
93
|
-
def once(event, callback)
|
94
|
-
event_emitter_proxy.once(event, callback)
|
95
|
-
end
|
96
|
-
|
97
91
|
# -- inherited from EventEmitter --
|
98
92
|
# @nodoc
|
99
93
|
def on(event, callback)
|
@@ -106,6 +100,12 @@ module Playwright
|
|
106
100
|
event_emitter_proxy.off(event, callback)
|
107
101
|
end
|
108
102
|
|
103
|
+
# -- inherited from EventEmitter --
|
104
|
+
# @nodoc
|
105
|
+
def once(event, callback)
|
106
|
+
event_emitter_proxy.once(event, callback)
|
107
|
+
end
|
108
|
+
|
109
109
|
private def event_emitter_proxy
|
110
110
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
111
111
|
end
|
@@ -28,6 +28,19 @@ 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
|
+
# ```
|
31
44
|
class Locator < PlaywrightApi
|
32
45
|
|
33
46
|
# Returns an array of `node.innerText` values for all matching nodes.
|
@@ -197,8 +210,8 @@ module Playwright
|
|
197
210
|
# The method finds all elements matching the specified locator and passes an array of matched elements as a first argument
|
198
211
|
# to `expression`. Returns the result of `expression` invocation.
|
199
212
|
#
|
200
|
-
# If `expression` returns a [Promise], then [`Locator.evaluateAll`] would wait for the promise to resolve and
|
201
|
-
# value.
|
213
|
+
# If `expression` returns a [Promise], then [`method: Locator.evaluateAll`] would wait for the promise to resolve and
|
214
|
+
# return its value.
|
202
215
|
#
|
203
216
|
# Examples:
|
204
217
|
#
|
@@ -282,7 +295,7 @@ module Playwright
|
|
282
295
|
wrap_impl(@impl.inner_text(timeout: unwrap_impl(timeout)))
|
283
296
|
end
|
284
297
|
|
285
|
-
# Returns `input.value` for `<input>` or `<textarea>` element. Throws for non-input elements.
|
298
|
+
# Returns `input.value` for `<input>` or `<textarea>` or `<select>` element. Throws for non-input elements.
|
286
299
|
def input_value(timeout: nil)
|
287
300
|
wrap_impl(@impl.input_value(timeout: unwrap_impl(timeout)))
|
288
301
|
end
|
data/lib/playwright_api/page.rb
CHANGED
@@ -246,10 +246,12 @@ module Playwright
|
|
246
246
|
target,
|
247
247
|
force: nil,
|
248
248
|
noWaitAfter: nil,
|
249
|
+
sourcePosition: nil,
|
249
250
|
strict: nil,
|
251
|
+
targetPosition: nil,
|
250
252
|
timeout: nil,
|
251
253
|
trial: nil)
|
252
|
-
wrap_impl(@impl.drag_and_drop(unwrap_impl(source), unwrap_impl(target), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
254
|
+
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)))
|
253
255
|
end
|
254
256
|
|
255
257
|
# This method changes the `CSS media type` through the `media` argument, and/or the `'prefers-colors-scheme'` media
|
@@ -560,18 +562,18 @@ module Playwright
|
|
560
562
|
# Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
|
561
563
|
# last redirect.
|
562
564
|
#
|
563
|
-
#
|
565
|
+
# The method will throw an error if:
|
564
566
|
# - there's an SSL error (e.g. in case of self-signed certificates).
|
565
567
|
# - target URL is invalid.
|
566
568
|
# - the `timeout` is exceeded during navigation.
|
567
569
|
# - the remote server does not respond or is unreachable.
|
568
570
|
# - the main resource failed to load.
|
569
571
|
#
|
570
|
-
#
|
572
|
+
# The method will not throw an error when any valid HTTP status code is returned by the remote server, including 404 "Not
|
571
573
|
# Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling
|
572
574
|
# [`method: Response.status`].
|
573
575
|
#
|
574
|
-
# > NOTE:
|
576
|
+
# > NOTE: The method either throws an error or returns a main resource response. The only exceptions are navigation to
|
575
577
|
# `about:blank` or navigation to the same URL with a different hash, which would succeed and return `null`.
|
576
578
|
# > NOTE: Headless mode doesn't support navigation to a PDF document. See the
|
577
579
|
# [upstream issue](https://bugs.chromium.org/p/chromium/issues/detail?id=761295).
|
@@ -614,7 +616,7 @@ module Playwright
|
|
614
616
|
wrap_impl(@impl.inner_text(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
615
617
|
end
|
616
618
|
|
617
|
-
# Returns `input.value` for the selected `<input>` or `<textarea>` element. Throws for non-input elements.
|
619
|
+
# Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element. Throws for non-input elements.
|
618
620
|
def input_value(selector, strict: nil, timeout: nil)
|
619
621
|
wrap_impl(@impl.input_value(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
620
622
|
end
|
@@ -660,8 +662,6 @@ module Playwright
|
|
660
662
|
# element immediately before performing an action, so a series of actions on the same locator can in fact be performed on
|
661
663
|
# different DOM elements. That would happen if the DOM structure between those actions has changed.
|
662
664
|
#
|
663
|
-
# Note that locator always implies visibility, so it will always be locating visible elements.
|
664
|
-
#
|
665
665
|
# Shortcut for main frame's [`method: Frame.locator`].
|
666
666
|
def locator(selector)
|
667
667
|
wrap_impl(@impl.locator(unwrap_impl(selector)))
|
@@ -1350,12 +1350,6 @@ module Playwright
|
|
1350
1350
|
wrap_impl(@impl.guid)
|
1351
1351
|
end
|
1352
1352
|
|
1353
|
-
# -- inherited from EventEmitter --
|
1354
|
-
# @nodoc
|
1355
|
-
def once(event, callback)
|
1356
|
-
event_emitter_proxy.once(event, callback)
|
1357
|
-
end
|
1358
|
-
|
1359
1353
|
# -- inherited from EventEmitter --
|
1360
1354
|
# @nodoc
|
1361
1355
|
def on(event, callback)
|
@@ -1368,6 +1362,12 @@ module Playwright
|
|
1368
1362
|
event_emitter_proxy.off(event, callback)
|
1369
1363
|
end
|
1370
1364
|
|
1365
|
+
# -- inherited from EventEmitter --
|
1366
|
+
# @nodoc
|
1367
|
+
def once(event, callback)
|
1368
|
+
event_emitter_proxy.once(event, callback)
|
1369
|
+
end
|
1370
|
+
|
1371
1371
|
private def event_emitter_proxy
|
1372
1372
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
1373
1373
|
end
|
@@ -91,12 +91,6 @@ module Playwright
|
|
91
91
|
wrap_impl(@impl.electron)
|
92
92
|
end
|
93
93
|
|
94
|
-
# -- inherited from EventEmitter --
|
95
|
-
# @nodoc
|
96
|
-
def once(event, callback)
|
97
|
-
event_emitter_proxy.once(event, callback)
|
98
|
-
end
|
99
|
-
|
100
94
|
# -- inherited from EventEmitter --
|
101
95
|
# @nodoc
|
102
96
|
def on(event, callback)
|
@@ -109,6 +103,12 @@ module Playwright
|
|
109
103
|
event_emitter_proxy.off(event, callback)
|
110
104
|
end
|
111
105
|
|
106
|
+
# -- inherited from EventEmitter --
|
107
|
+
# @nodoc
|
108
|
+
def once(event, callback)
|
109
|
+
event_emitter_proxy.once(event, callback)
|
110
|
+
end
|
111
|
+
|
112
112
|
private def event_emitter_proxy
|
113
113
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
114
114
|
end
|
@@ -128,12 +128,6 @@ module Playwright
|
|
128
128
|
wrap_impl(@impl.url)
|
129
129
|
end
|
130
130
|
|
131
|
-
# -- inherited from EventEmitter --
|
132
|
-
# @nodoc
|
133
|
-
def once(event, callback)
|
134
|
-
event_emitter_proxy.once(event, callback)
|
135
|
-
end
|
136
|
-
|
137
131
|
# -- inherited from EventEmitter --
|
138
132
|
# @nodoc
|
139
133
|
def on(event, callback)
|
@@ -146,6 +140,12 @@ module Playwright
|
|
146
140
|
event_emitter_proxy.off(event, callback)
|
147
141
|
end
|
148
142
|
|
143
|
+
# -- inherited from EventEmitter --
|
144
|
+
# @nodoc
|
145
|
+
def once(event, callback)
|
146
|
+
event_emitter_proxy.once(event, callback)
|
147
|
+
end
|
148
|
+
|
149
149
|
private def event_emitter_proxy
|
150
150
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
151
151
|
end
|
@@ -74,12 +74,6 @@ module Playwright
|
|
74
74
|
wrap_impl(@impl.ok?)
|
75
75
|
end
|
76
76
|
|
77
|
-
# -- inherited from EventEmitter --
|
78
|
-
# @nodoc
|
79
|
-
def once(event, callback)
|
80
|
-
event_emitter_proxy.once(event, callback)
|
81
|
-
end
|
82
|
-
|
83
77
|
# -- inherited from EventEmitter --
|
84
78
|
# @nodoc
|
85
79
|
def on(event, callback)
|
@@ -92,6 +86,12 @@ module Playwright
|
|
92
86
|
event_emitter_proxy.off(event, callback)
|
93
87
|
end
|
94
88
|
|
89
|
+
# -- inherited from EventEmitter --
|
90
|
+
# @nodoc
|
91
|
+
def once(event, callback)
|
92
|
+
event_emitter_proxy.once(event, callback)
|
93
|
+
end
|
94
|
+
|
95
95
|
private def event_emitter_proxy
|
96
96
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
97
97
|
end
|
data/lib/playwright_api/route.rb
CHANGED
@@ -56,12 +56,6 @@ module Playwright
|
|
56
56
|
wrap_impl(@impl.request)
|
57
57
|
end
|
58
58
|
|
59
|
-
# -- inherited from EventEmitter --
|
60
|
-
# @nodoc
|
61
|
-
def once(event, callback)
|
62
|
-
event_emitter_proxy.once(event, callback)
|
63
|
-
end
|
64
|
-
|
65
59
|
# -- inherited from EventEmitter --
|
66
60
|
# @nodoc
|
67
61
|
def on(event, callback)
|
@@ -74,6 +68,12 @@ module Playwright
|
|
74
68
|
event_emitter_proxy.off(event, callback)
|
75
69
|
end
|
76
70
|
|
71
|
+
# -- inherited from EventEmitter --
|
72
|
+
# @nodoc
|
73
|
+
def once(event, callback)
|
74
|
+
event_emitter_proxy.once(event, callback)
|
75
|
+
end
|
76
|
+
|
77
77
|
private def event_emitter_proxy
|
78
78
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
79
79
|
end
|
@@ -6,18 +6,43 @@ module Playwright
|
|
6
6
|
# An example of registering selector engine that queries elements based on a tag name:
|
7
7
|
#
|
8
8
|
# ```python sync
|
9
|
-
#
|
9
|
+
# from playwright.sync_api import sync_playwright
|
10
|
+
#
|
11
|
+
# def run(playwright):
|
12
|
+
# tag_selector = """
|
13
|
+
# {
|
14
|
+
# // Returns the first element matching given selector in the root's subtree.
|
15
|
+
# query(root, selector) {
|
16
|
+
# return root.querySelector(selector);
|
17
|
+
# },
|
18
|
+
# // Returns all elements matching given selector in the root's subtree.
|
19
|
+
# queryAll(root, selector) {
|
20
|
+
# return Array.from(root.querySelectorAll(selector));
|
21
|
+
# }
|
22
|
+
# }"""
|
23
|
+
#
|
24
|
+
# # Register the engine. Selectors will be prefixed with "tag=".
|
25
|
+
# playwright.selectors.register("tag", tag_selector)
|
26
|
+
# browser = playwright.chromium.launch()
|
27
|
+
# page = browser.new_page()
|
28
|
+
# page.set_content('<div><button>Click me</button></div>')
|
29
|
+
#
|
30
|
+
# # Use the selector prefixed with its name.
|
31
|
+
# button = page.query_selector('tag=button')
|
32
|
+
# # Combine it with other selector engines.
|
33
|
+
# page.click('tag=div >> text="Click me"')
|
34
|
+
# # Can use it in any methods supporting selectors.
|
35
|
+
# button_count = page.eval_on_selector_all('tag=button', 'buttons => buttons.length')
|
36
|
+
# print(button_count)
|
37
|
+
# browser.close()
|
38
|
+
#
|
39
|
+
# with sync_playwright() as playwright:
|
40
|
+
# run(playwright)
|
10
41
|
# ```
|
11
42
|
def register(name, contentScript: nil, path: nil, script: nil)
|
12
43
|
wrap_impl(@impl.register(unwrap_impl(name), contentScript: unwrap_impl(contentScript), path: unwrap_impl(path), script: unwrap_impl(script)))
|
13
44
|
end
|
14
45
|
|
15
|
-
# -- inherited from EventEmitter --
|
16
|
-
# @nodoc
|
17
|
-
def once(event, callback)
|
18
|
-
event_emitter_proxy.once(event, callback)
|
19
|
-
end
|
20
|
-
|
21
46
|
# -- inherited from EventEmitter --
|
22
47
|
# @nodoc
|
23
48
|
def on(event, callback)
|
@@ -30,6 +55,12 @@ module Playwright
|
|
30
55
|
event_emitter_proxy.off(event, callback)
|
31
56
|
end
|
32
57
|
|
58
|
+
# -- inherited from EventEmitter --
|
59
|
+
# @nodoc
|
60
|
+
def once(event, callback)
|
61
|
+
event_emitter_proxy.once(event, callback)
|
62
|
+
end
|
63
|
+
|
33
64
|
private def event_emitter_proxy
|
34
65
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
35
66
|
end
|