playwright-ruby-client 0.0.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +117 -5
- data/docs/api_coverage.md +359 -0
- data/lib/playwright.rb +6 -2
- data/lib/playwright/android_input_impl.rb +23 -0
- data/lib/playwright/api_implementation.rb +18 -0
- data/lib/playwright/channel.rb +7 -0
- data/lib/playwright/channel_owner.rb +6 -7
- data/lib/playwright/channel_owners/android.rb +10 -1
- data/lib/playwright/channel_owners/android_device.rb +163 -0
- data/lib/playwright/channel_owners/browser.rb +14 -14
- data/lib/playwright/channel_owners/browser_context.rb +10 -2
- data/lib/playwright/channel_owners/download.rb +27 -0
- data/lib/playwright/channel_owners/element_handle.rb +243 -1
- data/lib/playwright/channel_owners/frame.rb +269 -22
- data/lib/playwright/channel_owners/js_handle.rb +51 -0
- data/lib/playwright/channel_owners/page.rb +379 -34
- data/lib/playwright/channel_owners/request.rb +9 -1
- data/lib/playwright/channel_owners/webkit_browser.rb +1 -1
- data/lib/playwright/connection.rb +9 -6
- data/lib/playwright/errors.rb +2 -2
- data/lib/playwright/event_emitter.rb +8 -1
- data/lib/playwright/event_emitter_proxy.rb +49 -0
- data/lib/playwright/file_chooser_impl.rb +23 -0
- data/lib/playwright/http_headers.rb +20 -0
- data/lib/playwright/input_files.rb +42 -0
- data/lib/playwright/javascript/expression.rb +15 -0
- data/lib/playwright/javascript/function.rb +15 -0
- data/lib/playwright/javascript/value_parser.rb +1 -1
- data/lib/playwright/javascript/value_serializer.rb +11 -11
- data/lib/playwright/{input_types/keyboard.rb → keyboard_impl.rb} +6 -2
- data/lib/playwright/mouse_impl.rb +7 -0
- data/lib/playwright/playwright_api.rb +66 -19
- data/lib/playwright/select_option_values.rb +42 -0
- data/lib/playwright/timeout_settings.rb +1 -1
- data/lib/playwright/touchscreen_impl.rb +7 -0
- data/lib/playwright/utils.rb +18 -0
- data/lib/playwright/version.rb +1 -1
- data/lib/playwright/wait_helper.rb +1 -1
- data/lib/playwright_api/android.rb +32 -0
- data/lib/playwright_api/android_device.rb +77 -0
- data/lib/playwright_api/android_input.rb +25 -0
- data/lib/playwright_api/binding_call.rb +10 -6
- data/lib/playwright_api/browser.rb +22 -22
- data/lib/playwright_api/browser_context.rb +31 -22
- data/lib/playwright_api/browser_type.rb +16 -56
- data/lib/playwright_api/chromium_browser_context.rb +10 -8
- data/lib/playwright_api/console_message.rb +9 -10
- data/lib/playwright_api/dialog.rb +7 -3
- data/lib/playwright_api/download.rb +28 -11
- data/lib/playwright_api/element_handle.rb +139 -127
- data/lib/playwright_api/file_chooser.rb +17 -9
- data/lib/playwright_api/frame.rb +148 -148
- data/lib/playwright_api/js_handle.rb +26 -22
- data/lib/playwright_api/keyboard.rb +6 -6
- data/lib/playwright_api/page.rb +215 -179
- data/lib/playwright_api/playwright.rb +34 -46
- data/lib/playwright_api/request.rb +7 -8
- data/lib/playwright_api/response.rb +10 -6
- data/lib/playwright_api/selectors.rb +13 -9
- data/lib/playwright_api/web_socket.rb +10 -1
- data/lib/playwright_api/worker.rb +13 -13
- data/playwright.gemspec +1 -0
- metadata +32 -6
- data/lib/playwright/input_type.rb +0 -19
- data/lib/playwright/input_types/mouse.rb +0 -4
- data/lib/playwright/input_types/touchscreen.rb +0 -4
@@ -22,13 +22,13 @@ module Playwright
|
|
22
22
|
# [`method: JSHandle.dispose`]. JSHandles are auto-disposed when their origin frame gets navigated or the parent context
|
23
23
|
# gets destroyed.
|
24
24
|
#
|
25
|
-
# JSHandle instances can be used as an argument in [`method: Page
|
25
|
+
# JSHandle instances can be used as an argument in [`method: Page.evalOnSelector`], [`method: Page.evaluate`] and
|
26
26
|
# [`method: Page.evaluateHandle`] methods.
|
27
27
|
class JSHandle < PlaywrightApi
|
28
28
|
|
29
29
|
# Returns either `null` or the object handle itself, if the object handle is an instance of `ElementHandle`.
|
30
30
|
def as_element
|
31
|
-
|
31
|
+
wrap_impl(@impl.as_element)
|
32
32
|
end
|
33
33
|
|
34
34
|
# The `jsHandle.dispose` method stops referencing the element handle.
|
@@ -36,12 +36,11 @@ module Playwright
|
|
36
36
|
wrap_impl(@impl.dispose)
|
37
37
|
end
|
38
38
|
|
39
|
-
# Returns the return value of `
|
39
|
+
# Returns the return value of `expression`.
|
40
40
|
#
|
41
|
-
# This method passes this handle as the first argument to `
|
41
|
+
# This method passes this handle as the first argument to `expression`.
|
42
42
|
#
|
43
|
-
# If `
|
44
|
-
# value.
|
43
|
+
# If `expression` returns a [Promise], then `handle.evaluate` would wait for the promise to resolve and return its value.
|
45
44
|
#
|
46
45
|
# Examples:
|
47
46
|
#
|
@@ -60,23 +59,23 @@ module Playwright
|
|
60
59
|
# tweet_handle = page.query_selector(".tweet .retweets")
|
61
60
|
# assert tweet_handle.evaluate("node => node.innerText") == "10 retweets"
|
62
61
|
# ```
|
63
|
-
def evaluate(
|
64
|
-
|
62
|
+
def evaluate(expression, arg: nil)
|
63
|
+
wrap_impl(@impl.evaluate(unwrap_impl(expression), arg: unwrap_impl(arg)))
|
65
64
|
end
|
66
65
|
|
67
|
-
# Returns the return value of `
|
66
|
+
# Returns the return value of `expression` as a `JSHandle`.
|
68
67
|
#
|
69
|
-
# This method passes this handle as the first argument to `
|
68
|
+
# This method passes this handle as the first argument to `expression`.
|
70
69
|
#
|
71
70
|
# The only difference between `jsHandle.evaluate` and `jsHandle.evaluateHandle` is that `jsHandle.evaluateHandle` returns
|
72
|
-
#
|
71
|
+
# `JSHandle`.
|
73
72
|
#
|
74
73
|
# If the function passed to the `jsHandle.evaluateHandle` returns a [Promise], then `jsHandle.evaluateHandle` would wait
|
75
74
|
# for the promise to resolve and return its value.
|
76
75
|
#
|
77
76
|
# See [`method: Page.evaluateHandle`] for more details.
|
78
|
-
def evaluate_handle(
|
79
|
-
|
77
|
+
def evaluate_handle(expression, arg: nil)
|
78
|
+
wrap_impl(@impl.evaluate_handle(unwrap_impl(expression), arg: unwrap_impl(arg)))
|
80
79
|
end
|
81
80
|
|
82
81
|
# The method returns a map with **own property names** as keys and JSHandle instances for the property values.
|
@@ -106,12 +105,13 @@ module Playwright
|
|
106
105
|
# handle.dispose()
|
107
106
|
# ```
|
108
107
|
def get_properties
|
109
|
-
|
108
|
+
wrap_impl(@impl.get_properties)
|
110
109
|
end
|
110
|
+
alias_method :properties, :get_properties
|
111
111
|
|
112
112
|
# Fetches a single property from the referenced object.
|
113
113
|
def get_property(propertyName)
|
114
|
-
|
114
|
+
wrap_impl(@impl.get_property(unwrap_impl(propertyName)))
|
115
115
|
end
|
116
116
|
|
117
117
|
# Returns a JSON representation of the object. If the object has a `toJSON` function, it **will not be called**.
|
@@ -119,25 +119,29 @@ module Playwright
|
|
119
119
|
# > NOTE: The method will return an empty JSON object if the referenced object is not stringifiable. It will throw an
|
120
120
|
# error if the object has circular references.
|
121
121
|
def json_value
|
122
|
-
|
122
|
+
wrap_impl(@impl.json_value)
|
123
123
|
end
|
124
124
|
|
125
125
|
# -- inherited from EventEmitter --
|
126
126
|
# @nodoc
|
127
|
-
def
|
128
|
-
|
127
|
+
def once(event, callback)
|
128
|
+
event_emitter_proxy.once(event, callback)
|
129
129
|
end
|
130
130
|
|
131
131
|
# -- inherited from EventEmitter --
|
132
132
|
# @nodoc
|
133
|
-
def
|
134
|
-
|
133
|
+
def on(event, callback)
|
134
|
+
event_emitter_proxy.on(event, callback)
|
135
135
|
end
|
136
136
|
|
137
137
|
# -- inherited from EventEmitter --
|
138
138
|
# @nodoc
|
139
|
-
def
|
140
|
-
|
139
|
+
def off(event, callback)
|
140
|
+
event_emitter_proxy.off(event, callback)
|
141
|
+
end
|
142
|
+
|
143
|
+
private def event_emitter_proxy
|
144
|
+
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
141
145
|
end
|
142
146
|
end
|
143
147
|
end
|
@@ -114,7 +114,7 @@ module Playwright
|
|
114
114
|
#
|
115
115
|
# > NOTE: Modifier keys DO influence `keyboard.down`. Holding down `Shift` will type the text in upper case.
|
116
116
|
def down(key)
|
117
|
-
@impl.down(key)
|
117
|
+
wrap_impl(@impl.down(unwrap_impl(key)))
|
118
118
|
end
|
119
119
|
|
120
120
|
# Dispatches only `input` event, does not emit the `keydown`, `keyup` or `keypress` events.
|
@@ -134,7 +134,7 @@ module Playwright
|
|
134
134
|
#
|
135
135
|
# > NOTE: Modifier keys DO NOT effect `keyboard.insertText`. Holding down `Shift` will not type the text in upper case.
|
136
136
|
def insert_text(text)
|
137
|
-
@impl.insert_text(text)
|
137
|
+
wrap_impl(@impl.insert_text(unwrap_impl(text)))
|
138
138
|
end
|
139
139
|
|
140
140
|
# `key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)
|
@@ -193,7 +193,7 @@ module Playwright
|
|
193
193
|
#
|
194
194
|
# Shortcut for [`method: Keyboard.down`] and [`method: Keyboard.up`].
|
195
195
|
def press(key, delay: nil)
|
196
|
-
@impl.press(key, delay: delay)
|
196
|
+
wrap_impl(@impl.press(unwrap_impl(key), delay: unwrap_impl(delay)))
|
197
197
|
end
|
198
198
|
|
199
199
|
# Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
|
@@ -217,13 +217,13 @@ module Playwright
|
|
217
217
|
# ```
|
218
218
|
#
|
219
219
|
# > NOTE: Modifier keys DO NOT effect `keyboard.type`. Holding down `Shift` will not type the text in upper case.
|
220
|
-
def
|
221
|
-
@impl.
|
220
|
+
def type(text, delay: nil)
|
221
|
+
wrap_impl(@impl.type(unwrap_impl(text), delay: unwrap_impl(delay)))
|
222
222
|
end
|
223
223
|
|
224
224
|
# Dispatches a `keyup` event.
|
225
225
|
def up(key)
|
226
|
-
@impl.up(key)
|
226
|
+
wrap_impl(@impl.up(unwrap_impl(key)))
|
227
227
|
end
|
228
228
|
end
|
229
229
|
end
|
data/lib/playwright_api/page.rb
CHANGED
@@ -2,8 +2,8 @@ module Playwright
|
|
2
2
|
# - extends: [EventEmitter]
|
3
3
|
#
|
4
4
|
# Page provides methods to interact with a single tab in a `Browser`, or an
|
5
|
-
# [extension background page](https://developer.chrome.com/extensions/background_pages) in Chromium. One
|
6
|
-
# instance might have multiple
|
5
|
+
# [extension background page](https://developer.chrome.com/extensions/background_pages) in Chromium. One `Browser`
|
6
|
+
# instance might have multiple `Page` instances.
|
7
7
|
#
|
8
8
|
# This example creates a page, navigates it to a URL, and then saves a screenshot:
|
9
9
|
#
|
@@ -96,12 +96,6 @@ module Playwright
|
|
96
96
|
wrap_impl(@impl.accessibility)
|
97
97
|
end
|
98
98
|
|
99
|
-
# Browser-specific Coverage implementation, only available for Chromium atm. See
|
100
|
-
# `ChromiumCoverage`(#class-chromiumcoverage) for more details.
|
101
|
-
def coverage # property
|
102
|
-
raise NotImplementedError.new('coverage is not implemented yet.')
|
103
|
-
end
|
104
|
-
|
105
99
|
def keyboard # property
|
106
100
|
wrap_impl(@impl.keyboard)
|
107
101
|
end
|
@@ -114,78 +108,6 @@ module Playwright
|
|
114
108
|
wrap_impl(@impl.touchscreen)
|
115
109
|
end
|
116
110
|
|
117
|
-
# The method finds an element matching the specified selector within the page. If no elements match the selector, the
|
118
|
-
# return value resolves to `null`.
|
119
|
-
#
|
120
|
-
# Shortcut for main frame's [`method: Frame.$`].
|
121
|
-
def query_selector(selector)
|
122
|
-
wrap_impl(@impl.query_selector(selector))
|
123
|
-
end
|
124
|
-
|
125
|
-
# The method finds all elements matching the specified selector within the page. If no elements match the selector, the
|
126
|
-
# return value resolves to `[]`.
|
127
|
-
#
|
128
|
-
# Shortcut for main frame's [`method: Frame.$$`].
|
129
|
-
def query_selector_all(selector)
|
130
|
-
wrap_impl(@impl.query_selector_all(selector))
|
131
|
-
end
|
132
|
-
|
133
|
-
# The method finds an element matching the specified selector within the page and passes it as a first argument to
|
134
|
-
# `pageFunction`. If no elements match the selector, the method throws an error. Returns the value of `pageFunction`.
|
135
|
-
#
|
136
|
-
# If `pageFunction` returns a [Promise], then [`method: Page.$eval`] would wait for the promise to resolve and return its
|
137
|
-
# value.
|
138
|
-
#
|
139
|
-
# Examples:
|
140
|
-
#
|
141
|
-
#
|
142
|
-
# ```js
|
143
|
-
# const searchValue = await page.$eval('#search', el => el.value);
|
144
|
-
# const preloadHref = await page.$eval('link[rel=preload]', el => el.href);
|
145
|
-
# const html = await page.$eval('.main-container', (e, suffix) => e.outerHTML + suffix, 'hello');
|
146
|
-
# ```
|
147
|
-
#
|
148
|
-
# ```python async
|
149
|
-
# search_value = await page.eval_on_selector("#search", "el => el.value")
|
150
|
-
# preload_href = await page.eval_on_selector("link[rel=preload]", "el => el.href")
|
151
|
-
# html = await page.eval_on_selector(".main-container", "(e, suffix) => e.outer_html + suffix", "hello")
|
152
|
-
# ```
|
153
|
-
#
|
154
|
-
# ```python sync
|
155
|
-
# search_value = page.eval_on_selector("#search", "el => el.value")
|
156
|
-
# preload_href = page.eval_on_selector("link[rel=preload]", "el => el.href")
|
157
|
-
# html = page.eval_on_selector(".main-container", "(e, suffix) => e.outer_html + suffix", "hello")
|
158
|
-
# ```
|
159
|
-
#
|
160
|
-
# Shortcut for main frame's [`method: Frame.$eval`].
|
161
|
-
def eval_on_selector(selector, pageFunction, arg: nil)
|
162
|
-
wrap_impl(@impl.eval_on_selector(selector, pageFunction, arg: arg))
|
163
|
-
end
|
164
|
-
|
165
|
-
# The method finds all elements matching the specified selector within the page and passes an array of matched elements as
|
166
|
-
# a first argument to `pageFunction`. Returns the result of `pageFunction` invocation.
|
167
|
-
#
|
168
|
-
# If `pageFunction` returns a [Promise], then [`method: Page.$$eval`] would wait for the promise to resolve and return its
|
169
|
-
# value.
|
170
|
-
#
|
171
|
-
# Examples:
|
172
|
-
#
|
173
|
-
#
|
174
|
-
# ```js
|
175
|
-
# const divCounts = await page.$$eval('div', (divs, min) => divs.length >= min, 10);
|
176
|
-
# ```
|
177
|
-
#
|
178
|
-
# ```python async
|
179
|
-
# div_counts = await page.eval_on_selector_all("div", "(divs, min) => divs.length >= min", 10)
|
180
|
-
# ```
|
181
|
-
#
|
182
|
-
# ```python sync
|
183
|
-
# div_counts = page.eval_on_selector_all("div", "(divs, min) => divs.length >= min", 10)
|
184
|
-
# ```
|
185
|
-
def eval_on_selector_all(selector, pageFunction, arg: nil)
|
186
|
-
wrap_impl(@impl.eval_on_selector_all(selector, pageFunction, arg: arg))
|
187
|
-
end
|
188
|
-
|
189
111
|
# Adds a script which would be evaluated in one of the following scenarios:
|
190
112
|
# - Whenever the page is navigated.
|
191
113
|
# - Whenever the child frame is attached or navigated. In this case, the script is evaluated in the context of the newly
|
@@ -220,8 +142,8 @@ module Playwright
|
|
220
142
|
#
|
221
143
|
# > NOTE: The order of evaluation of multiple scripts installed via [`method: BrowserContext.addInitScript`] and
|
222
144
|
# [`method: Page.addInitScript`] is not defined.
|
223
|
-
def add_init_script(
|
224
|
-
|
145
|
+
def add_init_script(path: nil, script: nil)
|
146
|
+
wrap_impl(@impl.add_init_script(path: unwrap_impl(path), script: unwrap_impl(script)))
|
225
147
|
end
|
226
148
|
|
227
149
|
# Adds a `<script>` tag into the page with the desired url or content. Returns the added tag when the script's onload
|
@@ -229,7 +151,7 @@ module Playwright
|
|
229
151
|
#
|
230
152
|
# Shortcut for main frame's [`method: Frame.addScriptTag`].
|
231
153
|
def add_script_tag(content: nil, path: nil, type: nil, url: nil)
|
232
|
-
|
154
|
+
wrap_impl(@impl.add_script_tag(content: unwrap_impl(content), path: unwrap_impl(path), type: unwrap_impl(type), url: unwrap_impl(url)))
|
233
155
|
end
|
234
156
|
|
235
157
|
# Adds a `<link rel="stylesheet">` tag into the page with the desired url or a `<style type="text/css">` tag with the
|
@@ -237,12 +159,12 @@ module Playwright
|
|
237
159
|
#
|
238
160
|
# Shortcut for main frame's [`method: Frame.addStyleTag`].
|
239
161
|
def add_style_tag(content: nil, path: nil, url: nil)
|
240
|
-
|
162
|
+
wrap_impl(@impl.add_style_tag(content: unwrap_impl(content), path: unwrap_impl(path), url: unwrap_impl(url)))
|
241
163
|
end
|
242
164
|
|
243
165
|
# Brings page to front (activates tab).
|
244
166
|
def bring_to_front
|
245
|
-
|
167
|
+
wrap_impl(@impl.bring_to_front)
|
246
168
|
end
|
247
169
|
|
248
170
|
# This method checks an element matching `selector` by performing the following steps:
|
@@ -261,7 +183,7 @@ module Playwright
|
|
261
183
|
#
|
262
184
|
# Shortcut for main frame's [`method: Frame.check`].
|
263
185
|
def check(selector, force: nil, noWaitAfter: nil, timeout: nil)
|
264
|
-
|
186
|
+
wrap_impl(@impl.check(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
265
187
|
end
|
266
188
|
|
267
189
|
# This method clicks an element matching `selector` by performing the following steps:
|
@@ -286,7 +208,7 @@ module Playwright
|
|
286
208
|
noWaitAfter: nil,
|
287
209
|
position: nil,
|
288
210
|
timeout: nil)
|
289
|
-
wrap_impl(@impl.click(selector, button: button, clickCount: clickCount, delay: delay, force: force, modifiers: modifiers, noWaitAfter: noWaitAfter, position: position, timeout: timeout))
|
211
|
+
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)))
|
290
212
|
end
|
291
213
|
|
292
214
|
# If `runBeforeUnload` is `false`, does not run any unload handlers and waits for the page to be closed. If
|
@@ -297,7 +219,7 @@ module Playwright
|
|
297
219
|
# > NOTE: if `runBeforeUnload` is passed as true, a `beforeunload` dialog might be summoned and should be handled manually
|
298
220
|
# via [`event: Page.dialog`] event.
|
299
221
|
def close(runBeforeUnload: nil)
|
300
|
-
wrap_impl(@impl.close(runBeforeUnload: runBeforeUnload))
|
222
|
+
wrap_impl(@impl.close(runBeforeUnload: unwrap_impl(runBeforeUnload)))
|
301
223
|
end
|
302
224
|
|
303
225
|
# Gets the full HTML contents of the page, including the doctype.
|
@@ -334,7 +256,7 @@ module Playwright
|
|
334
256
|
noWaitAfter: nil,
|
335
257
|
position: nil,
|
336
258
|
timeout: nil)
|
337
|
-
|
259
|
+
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)))
|
338
260
|
end
|
339
261
|
|
340
262
|
# The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the elment, `click`
|
@@ -387,7 +309,7 @@ module Playwright
|
|
387
309
|
# page.dispatch_event("#source", "dragstart", { "dataTransfer": data_transfer })
|
388
310
|
# ```
|
389
311
|
def dispatch_event(selector, type, eventInit: nil, timeout: nil)
|
390
|
-
|
312
|
+
wrap_impl(@impl.dispatch_event(unwrap_impl(selector), unwrap_impl(type), eventInit: unwrap_impl(eventInit), timeout: unwrap_impl(timeout)))
|
391
313
|
end
|
392
314
|
|
393
315
|
#
|
@@ -478,20 +400,76 @@ module Playwright
|
|
478
400
|
# # → False
|
479
401
|
# page.evaluate("matchMedia('(prefers-color-scheme: no-preference)').matches")
|
480
402
|
# ```
|
481
|
-
def emulate_media(
|
482
|
-
|
403
|
+
def emulate_media(colorScheme: nil, media: nil)
|
404
|
+
wrap_impl(@impl.emulate_media(colorScheme: unwrap_impl(colorScheme), media: unwrap_impl(media)))
|
483
405
|
end
|
484
406
|
|
485
|
-
#
|
407
|
+
# The method finds an element matching the specified selector within the page and passes it as a first argument to
|
408
|
+
# `expression`. If no elements match the selector, the method throws an error. Returns the value of `expression`.
|
409
|
+
#
|
410
|
+
# If `expression` returns a [Promise], then [`method: Page.evalOnSelector`] would wait for the promise to resolve and
|
411
|
+
# return its value.
|
412
|
+
#
|
413
|
+
# Examples:
|
414
|
+
#
|
415
|
+
#
|
416
|
+
# ```js
|
417
|
+
# const searchValue = await page.$eval('#search', el => el.value);
|
418
|
+
# const preloadHref = await page.$eval('link[rel=preload]', el => el.href);
|
419
|
+
# const html = await page.$eval('.main-container', (e, suffix) => e.outerHTML + suffix, 'hello');
|
420
|
+
# ```
|
421
|
+
#
|
422
|
+
# ```python async
|
423
|
+
# search_value = await page.eval_on_selector("#search", "el => el.value")
|
424
|
+
# preload_href = await page.eval_on_selector("link[rel=preload]", "el => el.href")
|
425
|
+
# html = await page.eval_on_selector(".main-container", "(e, suffix) => e.outer_html + suffix", "hello")
|
426
|
+
# ```
|
427
|
+
#
|
428
|
+
# ```python sync
|
429
|
+
# search_value = page.eval_on_selector("#search", "el => el.value")
|
430
|
+
# preload_href = page.eval_on_selector("link[rel=preload]", "el => el.href")
|
431
|
+
# html = page.eval_on_selector(".main-container", "(e, suffix) => e.outer_html + suffix", "hello")
|
432
|
+
# ```
|
433
|
+
#
|
434
|
+
# Shortcut for main frame's [`method: Frame.evalOnSelector`].
|
435
|
+
def eval_on_selector(selector, expression, arg: nil)
|
436
|
+
wrap_impl(@impl.eval_on_selector(unwrap_impl(selector), unwrap_impl(expression), arg: unwrap_impl(arg)))
|
437
|
+
end
|
438
|
+
|
439
|
+
# The method finds all elements matching the specified selector within the page and passes an array of matched elements as
|
440
|
+
# a first argument to `expression`. Returns the result of `expression` invocation.
|
441
|
+
#
|
442
|
+
# If `expression` returns a [Promise], then [`method: Page.evalOnSelectorAll`] would wait for the promise to resolve and
|
443
|
+
# return its value.
|
444
|
+
#
|
445
|
+
# Examples:
|
446
|
+
#
|
447
|
+
#
|
448
|
+
# ```js
|
449
|
+
# const divCounts = await page.$$eval('div', (divs, min) => divs.length >= min, 10);
|
450
|
+
# ```
|
451
|
+
#
|
452
|
+
# ```python async
|
453
|
+
# div_counts = await page.eval_on_selector_all("div", "(divs, min) => divs.length >= min", 10)
|
454
|
+
# ```
|
455
|
+
#
|
456
|
+
# ```python sync
|
457
|
+
# div_counts = page.eval_on_selector_all("div", "(divs, min) => divs.length >= min", 10)
|
458
|
+
# ```
|
459
|
+
def eval_on_selector_all(selector, expression, arg: nil)
|
460
|
+
wrap_impl(@impl.eval_on_selector_all(unwrap_impl(selector), unwrap_impl(expression), arg: unwrap_impl(arg)))
|
461
|
+
end
|
462
|
+
|
463
|
+
# Returns the value of the `expression` invocation.
|
486
464
|
#
|
487
465
|
# If the function passed to the [`method: Page.evaluate`] returns a [Promise], then [`method: Page.evaluate`] would wait
|
488
466
|
# for the promise to resolve and return its value.
|
489
467
|
#
|
490
|
-
# If the function passed to the [`method: Page.evaluate`] returns a non-[Serializable] value,
|
491
|
-
#
|
492
|
-
#
|
468
|
+
# If the function passed to the [`method: Page.evaluate`] returns a non-[Serializable] value, then
|
469
|
+
# [`method: Page.evaluate`] resolves to `undefined`. Playwright also supports transferring some additional values that are
|
470
|
+
# not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`.
|
493
471
|
#
|
494
|
-
# Passing argument to `
|
472
|
+
# Passing argument to `expression`:
|
495
473
|
#
|
496
474
|
#
|
497
475
|
# ```js
|
@@ -554,14 +532,14 @@ module Playwright
|
|
554
532
|
# ```
|
555
533
|
#
|
556
534
|
# Shortcut for main frame's [`method: Frame.evaluate`].
|
557
|
-
def evaluate(
|
558
|
-
wrap_impl(@impl.evaluate(
|
535
|
+
def evaluate(expression, arg: nil)
|
536
|
+
wrap_impl(@impl.evaluate(unwrap_impl(expression), arg: unwrap_impl(arg)))
|
559
537
|
end
|
560
538
|
|
561
|
-
# Returns the value of the `
|
539
|
+
# Returns the value of the `expression` invocation as a `JSHandle`.
|
562
540
|
#
|
563
541
|
# The only difference between [`method: Page.evaluate`] and [`method: Page.evaluateHandle`] is that
|
564
|
-
# [`method: Page.evaluateHandle`] returns
|
542
|
+
# [`method: Page.evaluateHandle`] returns `JSHandle`.
|
565
543
|
#
|
566
544
|
# If the function passed to the [`method: Page.evaluateHandle`] returns a [Promise], then [`method: Page.evaluateHandle`]
|
567
545
|
# would wait for the promise to resolve and return its value.
|
@@ -573,7 +551,6 @@ module Playwright
|
|
573
551
|
# ```
|
574
552
|
#
|
575
553
|
# ```python async
|
576
|
-
# # FIXME
|
577
554
|
# a_window_handle = await page.evaluate_handle("Promise.resolve(window)")
|
578
555
|
# a_window_handle # handle for the window object.
|
579
556
|
# ```
|
@@ -621,8 +598,8 @@ module Playwright
|
|
621
598
|
# print(result_handle.json_value())
|
622
599
|
# result_handle.dispose()
|
623
600
|
# ```
|
624
|
-
def evaluate_handle(
|
625
|
-
wrap_impl(@impl.evaluate_handle(
|
601
|
+
def evaluate_handle(expression, arg: nil)
|
602
|
+
wrap_impl(@impl.evaluate_handle(unwrap_impl(expression), arg: unwrap_impl(arg)))
|
626
603
|
end
|
627
604
|
|
628
605
|
# The method adds a function called `name` on the `window` object of every frame in this page. When called, the function
|
@@ -755,7 +732,7 @@ module Playwright
|
|
755
732
|
# """)
|
756
733
|
# ```
|
757
734
|
def expose_binding(name, callback, handle: nil)
|
758
|
-
|
735
|
+
wrap_impl(@impl.expose_binding(unwrap_impl(name), unwrap_impl(callback), handle: unwrap_impl(handle)))
|
759
736
|
end
|
760
737
|
|
761
738
|
# The method adds a function called `name` on the `window` object of every frame in the page. When called, the function
|
@@ -854,19 +831,20 @@ module Playwright
|
|
854
831
|
# run(playwright)
|
855
832
|
# ```
|
856
833
|
def expose_function(name, callback)
|
857
|
-
|
834
|
+
wrap_impl(@impl.expose_function(unwrap_impl(name), unwrap_impl(callback)))
|
858
835
|
end
|
859
836
|
|
860
837
|
# This method waits for an element matching `selector`, waits for [actionability](./actionability.md) checks, focuses the
|
861
|
-
# element, fills it and triggers an `input` event after filling. If the element
|
862
|
-
#
|
863
|
-
#
|
838
|
+
# element, fills it and triggers an `input` event after filling. If the element is inside the `<label>` element that has
|
839
|
+
# associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), that control will be
|
840
|
+
# filled instead. If the element to be filled is not an `<input>`, `<textarea>` or `[contenteditable]` element, this
|
841
|
+
# method throws an error. Note that you can pass an empty string to clear the input field.
|
864
842
|
#
|
865
843
|
# To send fine-grained keyboard events, use [`method: Page.type`].
|
866
844
|
#
|
867
845
|
# Shortcut for main frame's [`method: Frame.fill`]
|
868
846
|
def fill(selector, value, noWaitAfter: nil, timeout: nil)
|
869
|
-
|
847
|
+
wrap_impl(@impl.fill(unwrap_impl(selector), unwrap_impl(value), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
870
848
|
end
|
871
849
|
|
872
850
|
# This method fetches an element with `selector` and focuses it. If there's no element matching `selector`, the method
|
@@ -874,7 +852,7 @@ module Playwright
|
|
874
852
|
#
|
875
853
|
# Shortcut for main frame's [`method: Frame.focus`].
|
876
854
|
def focus(selector, timeout: nil)
|
877
|
-
wrap_impl(@impl.focus(selector, timeout: timeout))
|
855
|
+
wrap_impl(@impl.focus(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
|
878
856
|
end
|
879
857
|
|
880
858
|
# Returns frame matching the specified criteria. Either `name` or `url` must be specified.
|
@@ -896,8 +874,8 @@ module Playwright
|
|
896
874
|
# ```py
|
897
875
|
# frame = page.frame(url=r".*domain.*")
|
898
876
|
# ```
|
899
|
-
def frame(
|
900
|
-
wrap_impl(@impl.frame(
|
877
|
+
def frame(name: nil, url: nil)
|
878
|
+
wrap_impl(@impl.frame(name: unwrap_impl(name), url: unwrap_impl(url)))
|
901
879
|
end
|
902
880
|
|
903
881
|
# An array of all frames attached to the page.
|
@@ -907,7 +885,7 @@ module Playwright
|
|
907
885
|
|
908
886
|
# Returns element attribute value.
|
909
887
|
def get_attribute(selector, name, timeout: nil)
|
910
|
-
|
888
|
+
wrap_impl(@impl.get_attribute(unwrap_impl(selector), unwrap_impl(name), timeout: unwrap_impl(timeout)))
|
911
889
|
end
|
912
890
|
|
913
891
|
# Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
|
@@ -915,7 +893,7 @@ module Playwright
|
|
915
893
|
#
|
916
894
|
# Navigate to the previous page in history.
|
917
895
|
def go_back(timeout: nil, waitUntil: nil)
|
918
|
-
|
896
|
+
wrap_impl(@impl.go_back(timeout: unwrap_impl(timeout), waitUntil: unwrap_impl(waitUntil)))
|
919
897
|
end
|
920
898
|
|
921
899
|
# Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
|
@@ -923,7 +901,7 @@ module Playwright
|
|
923
901
|
#
|
924
902
|
# Navigate to the next page in history.
|
925
903
|
def go_forward(timeout: nil, waitUntil: nil)
|
926
|
-
|
904
|
+
wrap_impl(@impl.go_forward(timeout: unwrap_impl(timeout), waitUntil: unwrap_impl(waitUntil)))
|
927
905
|
end
|
928
906
|
|
929
907
|
# Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
|
@@ -947,7 +925,7 @@ module Playwright
|
|
947
925
|
#
|
948
926
|
# Shortcut for main frame's [`method: Frame.goto`]
|
949
927
|
def goto(url, referer: nil, timeout: nil, waitUntil: nil)
|
950
|
-
wrap_impl(@impl.goto(url, referer: referer, timeout: timeout, waitUntil: waitUntil))
|
928
|
+
wrap_impl(@impl.goto(unwrap_impl(url), referer: unwrap_impl(referer), timeout: unwrap_impl(timeout), waitUntil: unwrap_impl(waitUntil)))
|
951
929
|
end
|
952
930
|
|
953
931
|
# This method hovers over an element matching `selector` by performing the following steps:
|
@@ -968,22 +946,22 @@ module Playwright
|
|
968
946
|
modifiers: nil,
|
969
947
|
position: nil,
|
970
948
|
timeout: nil)
|
971
|
-
|
949
|
+
wrap_impl(@impl.hover(unwrap_impl(selector), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
|
972
950
|
end
|
973
951
|
|
974
952
|
# Returns `element.innerHTML`.
|
975
953
|
def inner_html(selector, timeout: nil)
|
976
|
-
|
954
|
+
wrap_impl(@impl.inner_html(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
|
977
955
|
end
|
978
956
|
|
979
957
|
# Returns `element.innerText`.
|
980
958
|
def inner_text(selector, timeout: nil)
|
981
|
-
|
959
|
+
wrap_impl(@impl.inner_text(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
|
982
960
|
end
|
983
961
|
|
984
962
|
# Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
|
985
963
|
def checked?(selector, timeout: nil)
|
986
|
-
|
964
|
+
wrap_impl(@impl.checked?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
|
987
965
|
end
|
988
966
|
|
989
967
|
# Indicates that the page has been closed.
|
@@ -993,27 +971,27 @@ module Playwright
|
|
993
971
|
|
994
972
|
# Returns whether the element is disabled, the opposite of [enabled](./actionability.md#enabled).
|
995
973
|
def disabled?(selector, timeout: nil)
|
996
|
-
|
974
|
+
wrap_impl(@impl.disabled?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
|
997
975
|
end
|
998
976
|
|
999
977
|
# Returns whether the element is [editable](./actionability.md#editable).
|
1000
978
|
def editable?(selector, timeout: nil)
|
1001
|
-
|
979
|
+
wrap_impl(@impl.editable?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
|
1002
980
|
end
|
1003
981
|
|
1004
982
|
# Returns whether the element is [enabled](./actionability.md#enabled).
|
1005
983
|
def enabled?(selector, timeout: nil)
|
1006
|
-
|
984
|
+
wrap_impl(@impl.enabled?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
|
1007
985
|
end
|
1008
986
|
|
1009
987
|
# Returns whether the element is hidden, the opposite of [visible](./actionability.md#visible).
|
1010
988
|
def hidden?(selector, timeout: nil)
|
1011
|
-
|
989
|
+
wrap_impl(@impl.hidden?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
|
1012
990
|
end
|
1013
991
|
|
1014
992
|
# Returns whether the element is [visible](./actionability.md#visible).
|
1015
993
|
def visible?(selector, timeout: nil)
|
1016
|
-
|
994
|
+
wrap_impl(@impl.visible?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
|
1017
995
|
end
|
1018
996
|
|
1019
997
|
# The page's main frame. Page is guaranteed to have a main frame which persists during navigations.
|
@@ -1026,6 +1004,18 @@ module Playwright
|
|
1026
1004
|
wrap_impl(@impl.opener)
|
1027
1005
|
end
|
1028
1006
|
|
1007
|
+
# Pauses script execution. Playwright will stop executing the script and wait for the user to either press 'Resume' button
|
1008
|
+
# in the page overlay or to call `playwright.resume()` in the DevTools console.
|
1009
|
+
#
|
1010
|
+
# User can inspect selectors or perform manual steps while paused. Resume will continue running the original script from
|
1011
|
+
# the place it was paused.
|
1012
|
+
#
|
1013
|
+
# > NOTE: This method requires Playwright to be started in a headed mode, with a falsy [`options: headless`] value in the
|
1014
|
+
# [`method: BrowserType.launch`].
|
1015
|
+
def pause
|
1016
|
+
raise NotImplementedError.new('pause is not implemented yet.')
|
1017
|
+
end
|
1018
|
+
|
1029
1019
|
# Returns the PDF buffer.
|
1030
1020
|
#
|
1031
1021
|
# > NOTE: Generating a pdf is currently only supported in Chromium headless.
|
@@ -1098,7 +1088,7 @@ module Playwright
|
|
1098
1088
|
printBackground: nil,
|
1099
1089
|
scale: nil,
|
1100
1090
|
width: nil)
|
1101
|
-
|
1091
|
+
wrap_impl(@impl.pdf(displayHeaderFooter: unwrap_impl(displayHeaderFooter), footerTemplate: unwrap_impl(footerTemplate), format: unwrap_impl(format), headerTemplate: unwrap_impl(headerTemplate), height: unwrap_impl(height), landscape: unwrap_impl(landscape), margin: unwrap_impl(margin), pageRanges: unwrap_impl(pageRanges), path: unwrap_impl(path), preferCSSPageSize: unwrap_impl(preferCSSPageSize), printBackground: unwrap_impl(printBackground), scale: unwrap_impl(scale), width: unwrap_impl(width)))
|
1102
1092
|
end
|
1103
1093
|
|
1104
1094
|
# Focuses the element, and then uses [`method: Keyboard.down`] and [`method: Keyboard.up`].
|
@@ -1162,13 +1152,29 @@ module Playwright
|
|
1162
1152
|
delay: nil,
|
1163
1153
|
noWaitAfter: nil,
|
1164
1154
|
timeout: nil)
|
1165
|
-
wrap_impl(@impl.press(selector, key, delay: delay, noWaitAfter: noWaitAfter, timeout: timeout))
|
1155
|
+
wrap_impl(@impl.press(unwrap_impl(selector), unwrap_impl(key), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
1156
|
+
end
|
1157
|
+
|
1158
|
+
# The method finds an element matching the specified selector within the page. If no elements match the selector, the
|
1159
|
+
# return value resolves to `null`.
|
1160
|
+
#
|
1161
|
+
# Shortcut for main frame's [`method: Frame.querySelector`].
|
1162
|
+
def query_selector(selector)
|
1163
|
+
wrap_impl(@impl.query_selector(unwrap_impl(selector)))
|
1164
|
+
end
|
1165
|
+
|
1166
|
+
# The method finds all elements matching the specified selector within the page. If no elements match the selector, the
|
1167
|
+
# return value resolves to `[]`.
|
1168
|
+
#
|
1169
|
+
# Shortcut for main frame's [`method: Frame.querySelectorAll`].
|
1170
|
+
def query_selector_all(selector)
|
1171
|
+
wrap_impl(@impl.query_selector_all(unwrap_impl(selector)))
|
1166
1172
|
end
|
1167
1173
|
|
1168
1174
|
# Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
|
1169
1175
|
# last redirect.
|
1170
1176
|
def reload(timeout: nil, waitUntil: nil)
|
1171
|
-
|
1177
|
+
wrap_impl(@impl.reload(timeout: unwrap_impl(timeout), waitUntil: unwrap_impl(waitUntil)))
|
1172
1178
|
end
|
1173
1179
|
|
1174
1180
|
# Routing provides the capability to modify network requests that are made by a page.
|
@@ -1245,7 +1251,7 @@ module Playwright
|
|
1245
1251
|
quality: nil,
|
1246
1252
|
timeout: nil,
|
1247
1253
|
type: nil)
|
1248
|
-
wrap_impl(@impl.screenshot(clip: clip, fullPage: fullPage, omitBackground: omitBackground, path: path, quality: quality, timeout: timeout, type: type))
|
1254
|
+
wrap_impl(@impl.screenshot(clip: unwrap_impl(clip), fullPage: unwrap_impl(fullPage), omitBackground: unwrap_impl(omitBackground), path: unwrap_impl(path), quality: unwrap_impl(quality), timeout: unwrap_impl(timeout), type: unwrap_impl(type)))
|
1249
1255
|
end
|
1250
1256
|
|
1251
1257
|
# Returns the array of option values that have been successfully selected.
|
@@ -1287,12 +1293,19 @@ module Playwright
|
|
1287
1293
|
# ```
|
1288
1294
|
#
|
1289
1295
|
# Shortcut for main frame's [`method: Frame.selectOption`]
|
1290
|
-
def select_option(
|
1291
|
-
|
1296
|
+
def select_option(
|
1297
|
+
selector,
|
1298
|
+
element: nil,
|
1299
|
+
index: nil,
|
1300
|
+
value: nil,
|
1301
|
+
label: nil,
|
1302
|
+
noWaitAfter: nil,
|
1303
|
+
timeout: nil)
|
1304
|
+
wrap_impl(@impl.select_option(unwrap_impl(selector), element: unwrap_impl(element), index: unwrap_impl(index), value: unwrap_impl(value), label: unwrap_impl(label), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
1292
1305
|
end
|
1293
1306
|
|
1294
1307
|
def set_content(html, timeout: nil, waitUntil: nil)
|
1295
|
-
wrap_impl(@impl.set_content(html, timeout: timeout, waitUntil: waitUntil))
|
1308
|
+
wrap_impl(@impl.set_content(unwrap_impl(html), timeout: unwrap_impl(timeout), waitUntil: unwrap_impl(waitUntil)))
|
1296
1309
|
end
|
1297
1310
|
alias_method :content=, :set_content
|
1298
1311
|
|
@@ -1307,7 +1320,7 @@ module Playwright
|
|
1307
1320
|
# > NOTE: [`method: Page.setDefaultNavigationTimeout`] takes priority over [`method: Page.setDefaultTimeout`],
|
1308
1321
|
# [`method: BrowserContext.setDefaultTimeout`] and [`method: BrowserContext.setDefaultNavigationTimeout`].
|
1309
1322
|
def set_default_navigation_timeout(timeout)
|
1310
|
-
|
1323
|
+
wrap_impl(@impl.set_default_navigation_timeout(unwrap_impl(timeout)))
|
1311
1324
|
end
|
1312
1325
|
alias_method :default_navigation_timeout=, :set_default_navigation_timeout
|
1313
1326
|
|
@@ -1315,7 +1328,7 @@ module Playwright
|
|
1315
1328
|
#
|
1316
1329
|
# > NOTE: [`method: Page.setDefaultNavigationTimeout`] takes priority over [`method: Page.setDefaultTimeout`].
|
1317
1330
|
def set_default_timeout(timeout)
|
1318
|
-
|
1331
|
+
wrap_impl(@impl.set_default_timeout(unwrap_impl(timeout)))
|
1319
1332
|
end
|
1320
1333
|
alias_method :default_timeout=, :set_default_timeout
|
1321
1334
|
|
@@ -1323,7 +1336,7 @@ module Playwright
|
|
1323
1336
|
#
|
1324
1337
|
# > NOTE: [`method: Page.setExtraHTTPHeaders`] does not guarantee the order of headers in the outgoing requests.
|
1325
1338
|
def set_extra_http_headers(headers)
|
1326
|
-
|
1339
|
+
wrap_impl(@impl.set_extra_http_headers(unwrap_impl(headers)))
|
1327
1340
|
end
|
1328
1341
|
alias_method :extra_http_headers=, :set_extra_http_headers
|
1329
1342
|
|
@@ -1333,7 +1346,7 @@ module Playwright
|
|
1333
1346
|
# Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
|
1334
1347
|
# are resolved relative to the the current working directory. For empty array, clears the selected files.
|
1335
1348
|
def set_input_files(selector, files, noWaitAfter: nil, timeout: nil)
|
1336
|
-
|
1349
|
+
wrap_impl(@impl.set_input_files(unwrap_impl(selector), unwrap_impl(files), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
1337
1350
|
end
|
1338
1351
|
|
1339
1352
|
# In the case of multiple pages in a single browser, each page can have its own viewport size. However,
|
@@ -1364,7 +1377,7 @@ module Playwright
|
|
1364
1377
|
# page.goto("https://example.com")
|
1365
1378
|
# ```
|
1366
1379
|
def set_viewport_size(viewportSize)
|
1367
|
-
wrap_impl(@impl.set_viewport_size(viewportSize))
|
1380
|
+
wrap_impl(@impl.set_viewport_size(unwrap_impl(viewportSize)))
|
1368
1381
|
end
|
1369
1382
|
alias_method :viewport_size=, :set_viewport_size
|
1370
1383
|
|
@@ -1389,12 +1402,12 @@ module Playwright
|
|
1389
1402
|
noWaitAfter: nil,
|
1390
1403
|
position: nil,
|
1391
1404
|
timeout: nil)
|
1392
|
-
|
1405
|
+
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)))
|
1393
1406
|
end
|
1394
1407
|
|
1395
1408
|
# Returns `element.textContent`.
|
1396
1409
|
def text_content(selector, timeout: nil)
|
1397
|
-
|
1410
|
+
wrap_impl(@impl.text_content(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
|
1398
1411
|
end
|
1399
1412
|
|
1400
1413
|
# Returns the page's title. Shortcut for main frame's [`method: Frame.title`].
|
@@ -1424,13 +1437,13 @@ module Playwright
|
|
1424
1437
|
# ```
|
1425
1438
|
#
|
1426
1439
|
# Shortcut for main frame's [`method: Frame.type`].
|
1427
|
-
def
|
1440
|
+
def type(
|
1428
1441
|
selector,
|
1429
1442
|
text,
|
1430
1443
|
delay: nil,
|
1431
1444
|
noWaitAfter: nil,
|
1432
1445
|
timeout: nil)
|
1433
|
-
wrap_impl(@impl.
|
1446
|
+
wrap_impl(@impl.type(unwrap_impl(selector), unwrap_impl(text), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
1434
1447
|
end
|
1435
1448
|
|
1436
1449
|
# This method unchecks an element matching `selector` by performing the following steps:
|
@@ -1449,7 +1462,7 @@ module Playwright
|
|
1449
1462
|
#
|
1450
1463
|
# Shortcut for main frame's [`method: Frame.uncheck`].
|
1451
1464
|
def uncheck(selector, force: nil, noWaitAfter: nil, timeout: nil)
|
1452
|
-
|
1465
|
+
wrap_impl(@impl.uncheck(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
1453
1466
|
end
|
1454
1467
|
|
1455
1468
|
# Removes a route created with [`method: Page.route`]. When `handler` is not specified, removes all routes for the `url`.
|
@@ -1493,13 +1506,13 @@ module Playwright
|
|
1493
1506
|
# page.click("button")
|
1494
1507
|
# frame = event_info.value
|
1495
1508
|
# ```
|
1496
|
-
def expect_event(event,
|
1497
|
-
|
1509
|
+
def expect_event(event, predicate: nil, timeout: nil, &block)
|
1510
|
+
wrap_impl(@impl.expect_event(unwrap_impl(event), predicate: unwrap_impl(predicate), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
|
1498
1511
|
end
|
1499
1512
|
|
1500
|
-
# Returns when the `
|
1513
|
+
# Returns when the `expression` returns a truthy value. It resolves to a JSHandle of the truthy value.
|
1501
1514
|
#
|
1502
|
-
# The `waitForFunction` can be used to observe viewport size change:
|
1515
|
+
# The [`method: Page.waitForFunction`] can be used to observe viewport size change:
|
1503
1516
|
#
|
1504
1517
|
#
|
1505
1518
|
# ```js
|
@@ -1523,7 +1536,7 @@ module Playwright
|
|
1523
1536
|
# webkit = playwright.webkit
|
1524
1537
|
# browser = await webkit.launch()
|
1525
1538
|
# page = await browser.new_page()
|
1526
|
-
# await page.evaluate("window.x = 0; setTimeout(() => { window.x = 100 }, 1000);"
|
1539
|
+
# await page.evaluate("window.x = 0; setTimeout(() => { window.x = 100 }, 1000);")
|
1527
1540
|
# await page.wait_for_function("() => window.x > 0")
|
1528
1541
|
# await browser.close()
|
1529
1542
|
#
|
@@ -1540,7 +1553,7 @@ module Playwright
|
|
1540
1553
|
# webkit = playwright.webkit
|
1541
1554
|
# browser = webkit.launch()
|
1542
1555
|
# page = browser.new_page()
|
1543
|
-
# page.evaluate("window.x = 0; setTimeout(() => { window.x = 100 }, 1000);"
|
1556
|
+
# page.evaluate("window.x = 0; setTimeout(() => { window.x = 100 }, 1000);")
|
1544
1557
|
# page.wait_for_function("() => window.x > 0")
|
1545
1558
|
# browser.close()
|
1546
1559
|
#
|
@@ -1567,8 +1580,8 @@ module Playwright
|
|
1567
1580
|
# ```
|
1568
1581
|
#
|
1569
1582
|
# Shortcut for main frame's [`method: Frame.waitForFunction`].
|
1570
|
-
def wait_for_function(
|
1571
|
-
|
1583
|
+
def wait_for_function(expression, arg: nil, polling: nil, timeout: nil)
|
1584
|
+
wrap_impl(@impl.wait_for_function(unwrap_impl(expression), arg: unwrap_impl(arg), polling: unwrap_impl(polling), timeout: unwrap_impl(timeout)))
|
1572
1585
|
end
|
1573
1586
|
|
1574
1587
|
# Returns when the required load state has been reached.
|
@@ -1622,7 +1635,7 @@ module Playwright
|
|
1622
1635
|
#
|
1623
1636
|
# Shortcut for main frame's [`method: Frame.waitForLoadState`].
|
1624
1637
|
def wait_for_load_state(state: nil, timeout: nil)
|
1625
|
-
|
1638
|
+
wrap_impl(@impl.wait_for_load_state(state: unwrap_impl(state), timeout: unwrap_impl(timeout)))
|
1626
1639
|
end
|
1627
1640
|
|
1628
1641
|
# Waits for the main frame navigation and returns the main resource response. In case of multiple redirects, the
|
@@ -1657,8 +1670,8 @@ module Playwright
|
|
1657
1670
|
# considered a navigation.
|
1658
1671
|
#
|
1659
1672
|
# Shortcut for main frame's [`method: Frame.waitForNavigation`].
|
1660
|
-
def expect_navigation(timeout: nil, url: nil, waitUntil: nil)
|
1661
|
-
|
1673
|
+
def expect_navigation(timeout: nil, url: nil, waitUntil: nil, &block)
|
1674
|
+
wrap_impl(@impl.expect_navigation(timeout: unwrap_impl(timeout), url: unwrap_impl(url), waitUntil: unwrap_impl(waitUntil), &wrap_block_call(block)))
|
1662
1675
|
end
|
1663
1676
|
|
1664
1677
|
# Waits for the matching request and returns it.
|
@@ -1695,7 +1708,7 @@ module Playwright
|
|
1695
1708
|
# await page.waitForRequest(request => request.url().searchParams.get('foo') === 'bar' && request.url().searchParams.get('foo2') === 'bar2');
|
1696
1709
|
# ```
|
1697
1710
|
def expect_request(urlOrPredicate, timeout: nil)
|
1698
|
-
|
1711
|
+
wrap_impl(@impl.expect_request(unwrap_impl(urlOrPredicate), timeout: unwrap_impl(timeout)))
|
1699
1712
|
end
|
1700
1713
|
|
1701
1714
|
# Returns the matched response.
|
@@ -1719,7 +1732,7 @@ module Playwright
|
|
1719
1732
|
# return final_response.ok
|
1720
1733
|
# ```
|
1721
1734
|
def expect_response(urlOrPredicate, timeout: nil)
|
1722
|
-
|
1735
|
+
wrap_impl(@impl.expect_response(unwrap_impl(urlOrPredicate), timeout: unwrap_impl(timeout)))
|
1723
1736
|
end
|
1724
1737
|
|
1725
1738
|
# Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or
|
@@ -1784,7 +1797,7 @@ module Playwright
|
|
1784
1797
|
# run(playwright)
|
1785
1798
|
# ```
|
1786
1799
|
def wait_for_selector(selector, state: nil, timeout: nil)
|
1787
|
-
|
1800
|
+
wrap_impl(@impl.wait_for_selector(unwrap_impl(selector), state: unwrap_impl(state), timeout: unwrap_impl(timeout)))
|
1788
1801
|
end
|
1789
1802
|
|
1790
1803
|
# Waits for the given `timeout` in milliseconds.
|
@@ -1821,52 +1834,75 @@ module Playwright
|
|
1821
1834
|
raise NotImplementedError.new('workers is not implemented yet.')
|
1822
1835
|
end
|
1823
1836
|
|
1824
|
-
#
|
1825
|
-
|
1826
|
-
|
1837
|
+
# Performs action and waits for `download` event to fire. If predicate is provided, it passes `Download` value into the
|
1838
|
+
# `predicate` function and waits for `predicate(event)` to return a truthy value. Will throw an error if the page is
|
1839
|
+
# closed before the download event is fired.
|
1840
|
+
def expect_download(predicate: nil, timeout: nil)
|
1841
|
+
raise NotImplementedError.new('expect_download is not implemented yet.')
|
1827
1842
|
end
|
1828
1843
|
|
1829
|
-
#
|
1830
|
-
|
1831
|
-
|
1844
|
+
# Performs action and waits for `popup` event to fire. If predicate is provided, it passes [Popup] value into the
|
1845
|
+
# `predicate` function and waits for `predicate(event)` to return a truthy value. Will throw an error if the page is
|
1846
|
+
# closed before the popup event is fired.
|
1847
|
+
def expect_popup(predicate: nil, timeout: nil)
|
1848
|
+
raise NotImplementedError.new('expect_popup is not implemented yet.')
|
1832
1849
|
end
|
1833
1850
|
|
1834
|
-
#
|
1835
|
-
|
1836
|
-
|
1851
|
+
# Performs action and waits for `worker` event to fire. If predicate is provided, it passes `Worker` value into the
|
1852
|
+
# `predicate` function and waits for `predicate(event)` to return a truthy value. Will throw an error if the page is
|
1853
|
+
# closed before the worker event is fired.
|
1854
|
+
def expect_worker(predicate: nil, timeout: nil)
|
1855
|
+
raise NotImplementedError.new('expect_worker is not implemented yet.')
|
1837
1856
|
end
|
1838
1857
|
|
1839
|
-
#
|
1840
|
-
|
1841
|
-
|
1858
|
+
# Performs action and waits for `console` event to fire. If predicate is provided, it passes `ConsoleMessage` value into
|
1859
|
+
# the `predicate` function and waits for `predicate(event)` to return a truthy value. Will throw an error if the page is
|
1860
|
+
# closed before the worker event is fired.
|
1861
|
+
def expect_console_message(predicate: nil, timeout: nil)
|
1862
|
+
raise NotImplementedError.new('expect_console_message is not implemented yet.')
|
1863
|
+
end
|
1864
|
+
|
1865
|
+
# Performs action and waits for `filechooser` event to fire. If predicate is provided, it passes `FileChooser` value into
|
1866
|
+
# the `predicate` function and waits for `predicate(event)` to return a truthy value. Will throw an error if the page is
|
1867
|
+
# closed before the worker event is fired.
|
1868
|
+
def expect_file_chooser(predicate: nil, timeout: nil)
|
1869
|
+
raise NotImplementedError.new('expect_file_chooser is not implemented yet.')
|
1870
|
+
end
|
1871
|
+
|
1872
|
+
# > NOTE: In most cases, you should use [`method: Page.waitForEvent`].
|
1873
|
+
#
|
1874
|
+
# Waits for given `event` to fire. If predicate is provided, it passes event's value into the `predicate` function and
|
1875
|
+
# waits for `predicate(event)` to return a truthy value. Will throw an error if the socket is closed before the `event` is
|
1876
|
+
# fired.
|
1877
|
+
def wait_for_event(event, predicate: nil, timeout: nil)
|
1878
|
+
raise NotImplementedError.new('wait_for_event is not implemented yet.')
|
1842
1879
|
end
|
1843
1880
|
|
1844
1881
|
# @nodoc
|
1845
|
-
def
|
1846
|
-
wrap_impl(@impl.
|
1882
|
+
def owned_context=(req)
|
1883
|
+
wrap_impl(@impl.owned_context=(unwrap_impl(req)))
|
1847
1884
|
end
|
1848
1885
|
|
1886
|
+
# -- inherited from EventEmitter --
|
1849
1887
|
# @nodoc
|
1850
|
-
def
|
1851
|
-
|
1888
|
+
def once(event, callback)
|
1889
|
+
event_emitter_proxy.once(event, callback)
|
1852
1890
|
end
|
1853
1891
|
|
1854
1892
|
# -- inherited from EventEmitter --
|
1855
1893
|
# @nodoc
|
1856
1894
|
def on(event, callback)
|
1857
|
-
|
1895
|
+
event_emitter_proxy.on(event, callback)
|
1858
1896
|
end
|
1859
1897
|
|
1860
1898
|
# -- inherited from EventEmitter --
|
1861
1899
|
# @nodoc
|
1862
1900
|
def off(event, callback)
|
1863
|
-
|
1901
|
+
event_emitter_proxy.off(event, callback)
|
1864
1902
|
end
|
1865
1903
|
|
1866
|
-
|
1867
|
-
|
1868
|
-
def once(event, callback)
|
1869
|
-
wrap_impl(@impl.once(event, callback))
|
1904
|
+
private def event_emitter_proxy
|
1905
|
+
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
1870
1906
|
end
|
1871
1907
|
end
|
1872
1908
|
end
|