playwright-ruby-client 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +8 -15
- data/lib/playwright/channel_owners/browser.rb +2 -2
- data/lib/playwright/channel_owners/console_message.rb +25 -0
- data/lib/playwright/channel_owners/element_handle.rb +8 -0
- data/lib/playwright/channel_owners/js_handle.rb +4 -0
- data/lib/playwright/channel_owners/page.rb +14 -1
- data/lib/playwright/version.rb +1 -1
- data/lib/playwright_api/accessibility.rb +20 -6
- data/lib/playwright_api/browser.rb +52 -39
- data/lib/playwright_api/browser_context.rb +94 -44
- data/lib/playwright_api/browser_type.rb +72 -53
- data/lib/playwright_api/cdp_session.rb +10 -7
- data/lib/playwright_api/chromium_browser_context.rb +3 -0
- data/lib/playwright_api/console_message.rb +12 -5
- data/lib/playwright_api/dialog.rb +3 -1
- data/lib/playwright_api/download.rb +13 -4
- data/lib/playwright_api/element_handle.rb +226 -113
- data/lib/playwright_api/file_chooser.rb +4 -2
- data/lib/playwright_api/frame.rb +276 -128
- data/lib/playwright_api/js_handle.rb +30 -10
- data/lib/playwright_api/keyboard.rb +56 -18
- data/lib/playwright_api/mouse.rb +6 -3
- data/lib/playwright_api/page.rb +452 -237
- data/lib/playwright_api/playwright.rb +80 -16
- data/lib/playwright_api/request.rb +35 -15
- data/lib/playwright_api/response.rb +4 -3
- data/lib/playwright_api/route.rb +15 -4
- data/lib/playwright_api/selectors.rb +3 -7
- data/lib/playwright_api/touchscreen.rb +2 -1
- data/lib/playwright_api/video.rb +3 -1
- data/lib/playwright_api/web_socket.rb +4 -2
- data/lib/playwright_api/worker.rb +17 -5
- metadata +5 -2
@@ -1,5 +1,6 @@
|
|
1
1
|
module Playwright
|
2
|
-
# FileChooser objects are dispatched by the page in the
|
2
|
+
# `FileChooser` objects are dispatched by the page in the [`event: Page.filechooser`] event.
|
3
|
+
#
|
3
4
|
#
|
4
5
|
# ```js
|
5
6
|
# page.on('filechooser', async (fileChooser) => {
|
@@ -23,7 +24,8 @@ module Playwright
|
|
23
24
|
raise NotImplementedError.new('page is not implemented yet.')
|
24
25
|
end
|
25
26
|
|
26
|
-
# Sets the value of the file input this chooser is associated with. If some of the `filePaths` are relative paths, then
|
27
|
+
# Sets the value of the file input this chooser is associated with. If some of the `filePaths` are relative paths, then
|
28
|
+
# they are resolved relative to the the current working directory. For empty array, clears the selected files.
|
27
29
|
def set_files(files, noWaitAfter: nil, timeout: nil)
|
28
30
|
raise NotImplementedError.new('set_files is not implemented yet.')
|
29
31
|
end
|
data/lib/playwright_api/frame.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
module Playwright
|
2
|
-
# At every point of time, page exposes its current frame tree via the `
|
3
|
-
# Frame
|
2
|
+
# At every point of time, page exposes its current frame tree via the [`method: Page.mainFrame`] and
|
3
|
+
# [`method: Frame.childFrames`] methods.
|
4
4
|
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
5
|
+
# `Frame` object's lifecycle is controlled by three events, dispatched on the page object:
|
6
|
+
# - [`event: Page.frameattached`] - fired when the frame gets attached to the page. A Frame can be attached to the page
|
7
|
+
# only once.
|
8
|
+
# - [`event: Page.framenavigated`] - fired when the frame commits navigation to a different URL.
|
9
|
+
# - [`event: Page.framedetached`] - fired when the frame gets detached from the page. A Frame can be detached from the
|
10
|
+
# page only once.
|
8
11
|
#
|
9
12
|
# An example of dumping frame tree:
|
13
|
+
#
|
10
14
|
#
|
11
15
|
# ```js
|
12
16
|
# const { firefox } = require('playwright'); // Or 'chromium' or 'webkit'.
|
@@ -26,7 +30,9 @@ module Playwright
|
|
26
30
|
# }
|
27
31
|
# })();
|
28
32
|
# ```
|
33
|
+
#
|
29
34
|
# An example of getting text from an iframe element:
|
35
|
+
#
|
30
36
|
#
|
31
37
|
# ```js
|
32
38
|
# const frame = page.frames().find(frame => frame.name() === 'myframe');
|
@@ -36,66 +42,89 @@ module Playwright
|
|
36
42
|
class Frame < PlaywrightApi
|
37
43
|
|
38
44
|
# Returns the ElementHandle pointing to the frame element.
|
39
|
-
#
|
40
|
-
|
41
|
-
|
45
|
+
#
|
46
|
+
# The method finds an element matching the specified selector within the frame. See
|
47
|
+
# [Working with selectors](./selectors.md#working-with-selectors) for more details. If no elements match the selector,
|
48
|
+
# returns `null`.
|
49
|
+
def query_selector(selector)
|
50
|
+
raise NotImplementedError.new('query_selector is not implemented yet.')
|
42
51
|
end
|
43
52
|
|
44
53
|
# Returns the ElementHandles pointing to the frame elements.
|
45
|
-
#
|
46
|
-
|
47
|
-
|
54
|
+
#
|
55
|
+
# The method finds all elements matching the specified selector within the frame. See
|
56
|
+
# [Working with selectors](./selectors.md#working-with-selectors) for more details. If no elements match the selector,
|
57
|
+
# returns empty array.
|
58
|
+
def query_selector_all(selector)
|
59
|
+
raise NotImplementedError.new('query_selector_all is not implemented yet.')
|
48
60
|
end
|
49
61
|
|
50
62
|
# Returns the return value of `pageFunction`
|
51
|
-
#
|
52
|
-
#
|
63
|
+
#
|
64
|
+
# The method finds an element matching the specified selector within the frame and passes it as a first argument to
|
65
|
+
# `pageFunction`. See [Working with selectors](./selectors.md#working-with-selectors) for more details. If no elements
|
66
|
+
# match the selector, the method throws an error.
|
67
|
+
#
|
68
|
+
# If `pageFunction` returns a [Promise], then `frame.$eval` would wait for the promise to resolve and return its value.
|
69
|
+
#
|
53
70
|
# Examples:
|
71
|
+
#
|
54
72
|
#
|
55
73
|
# ```js
|
56
74
|
# const searchValue = await frame.$eval('#search', el => el.value);
|
57
75
|
# const preloadHref = await frame.$eval('link[rel=preload]', el => el.href);
|
58
76
|
# const html = await frame.$eval('.main-container', (e, suffix) => e.outerHTML + suffix, 'hello');
|
59
77
|
# ```
|
60
|
-
def
|
61
|
-
raise NotImplementedError.new('
|
78
|
+
def eval_on_selector(selector, pageFunction, arg: nil)
|
79
|
+
raise NotImplementedError.new('eval_on_selector is not implemented yet.')
|
62
80
|
end
|
63
81
|
|
64
82
|
# Returns the return value of `pageFunction`
|
65
|
-
#
|
66
|
-
#
|
83
|
+
#
|
84
|
+
# The method finds all elements matching the specified selector within the frame and passes an array of matched elements
|
85
|
+
# as a first argument to `pageFunction`. See [Working with selectors](./selectors.md#working-with-selectors) for more
|
86
|
+
# details.
|
87
|
+
#
|
88
|
+
# If `pageFunction` returns a [Promise], then `frame.$$eval` would wait for the promise to resolve and return its value.
|
89
|
+
#
|
67
90
|
# Examples:
|
91
|
+
#
|
68
92
|
#
|
69
93
|
# ```js
|
70
94
|
# const divsCounts = await frame.$$eval('div', (divs, min) => divs.length >= min, 10);
|
71
95
|
# ```
|
72
|
-
def
|
73
|
-
raise NotImplementedError.new('
|
96
|
+
def eval_on_selector_all(selector, pageFunction, arg: nil)
|
97
|
+
raise NotImplementedError.new('eval_on_selector_all is not implemented yet.')
|
74
98
|
end
|
75
99
|
|
76
100
|
# Returns the added tag when the script's onload fires or when the script content was injected into frame.
|
101
|
+
#
|
77
102
|
# Adds a `<script>` tag into the page with the desired url or content.
|
78
|
-
def add_script_tag(
|
103
|
+
def add_script_tag(content: nil, path: nil, type: nil, url: nil)
|
79
104
|
raise NotImplementedError.new('add_script_tag is not implemented yet.')
|
80
105
|
end
|
81
106
|
|
82
107
|
# Returns the added tag when the stylesheet's onload fires or when the CSS content was injected into frame.
|
83
|
-
#
|
84
|
-
|
108
|
+
#
|
109
|
+
# Adds a `<link rel="stylesheet">` tag into the page with the desired url or a `<style type="text/css">` tag with the
|
110
|
+
# content.
|
111
|
+
def add_style_tag(content: nil, path: nil, url: nil)
|
85
112
|
raise NotImplementedError.new('add_style_tag is not implemented yet.')
|
86
113
|
end
|
87
114
|
|
88
115
|
# This method checks an element matching `selector` by performing the following steps:
|
116
|
+
# 1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
117
|
+
# 1. Ensure that matched element is a checkbox or a radio input. If not, this method rejects. If the element is already
|
118
|
+
# checked, this method returns immediately.
|
119
|
+
# 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the
|
120
|
+
# element is detached during the checks, the whole action is retried.
|
121
|
+
# 1. Scroll the element into view if needed.
|
122
|
+
# 1. Use [`property: Page.mouse`] to click in the center of the element.
|
123
|
+
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
124
|
+
# 1. Ensure that the element is now checked. If not, this method rejects.
|
89
125
|
#
|
90
|
-
#
|
91
|
-
#
|
92
|
-
# Wait for actionability checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
|
93
|
-
# Scroll the element into view if needed.
|
94
|
-
# Use page.mouse to click in the center of the element.
|
95
|
-
# Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
96
|
-
# Ensure that the element is now checked. If not, this method rejects.
|
97
|
-
#
|
98
|
-
# When all steps combined have not finished during the specified `timeout`, this method rejects with a TimeoutError. Passing zero timeout disables this.
|
126
|
+
# When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`.
|
127
|
+
# Passing zero timeout disables this.
|
99
128
|
def check(selector, force: nil, noWaitAfter: nil, timeout: nil)
|
100
129
|
raise NotImplementedError.new('check is not implemented yet.')
|
101
130
|
end
|
@@ -105,23 +134,24 @@ module Playwright
|
|
105
134
|
end
|
106
135
|
|
107
136
|
# This method clicks an element matching `selector` by performing the following steps:
|
137
|
+
# 1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
138
|
+
# 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the
|
139
|
+
# element is detached during the checks, the whole action is retried.
|
140
|
+
# 1. Scroll the element into view if needed.
|
141
|
+
# 1. Use [`property: Page.mouse`] to click in the center of the element, or the specified `position`.
|
142
|
+
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
108
143
|
#
|
109
|
-
#
|
110
|
-
#
|
111
|
-
# Scroll the element into view if needed.
|
112
|
-
# Use page.mouse to click in the center of the element, or the specified `position`.
|
113
|
-
# Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
114
|
-
#
|
115
|
-
# When all steps combined have not finished during the specified `timeout`, this method rejects with a TimeoutError. Passing zero timeout disables this.
|
144
|
+
# When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`.
|
145
|
+
# Passing zero timeout disables this.
|
116
146
|
def click(
|
117
147
|
selector,
|
118
148
|
button: nil,
|
119
149
|
clickCount: nil,
|
120
150
|
delay: nil,
|
121
|
-
position: nil,
|
122
|
-
modifiers: nil,
|
123
151
|
force: nil,
|
152
|
+
modifiers: nil,
|
124
153
|
noWaitAfter: nil,
|
154
|
+
position: nil,
|
125
155
|
timeout: nil)
|
126
156
|
raise NotImplementedError.new('click is not implemented yet.')
|
127
157
|
end
|
@@ -132,45 +162,53 @@ module Playwright
|
|
132
162
|
end
|
133
163
|
|
134
164
|
# This method double clicks an element matching `selector` by performing the following steps:
|
165
|
+
# 1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
166
|
+
# 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the
|
167
|
+
# element is detached during the checks, the whole action is retried.
|
168
|
+
# 1. Scroll the element into view if needed.
|
169
|
+
# 1. Use [`property: Page.mouse`] to double click in the center of the element, or the specified `position`.
|
170
|
+
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the
|
171
|
+
# first click of the `dblclick()` triggers a navigation event, this method will reject.
|
135
172
|
#
|
136
|
-
#
|
137
|
-
#
|
138
|
-
# Scroll the element into view if needed.
|
139
|
-
# Use page.mouse to double click in the center of the element, or the specified `position`.
|
140
|
-
# Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the first click of the `dblclick()` triggers a navigation event, this method will reject.
|
141
|
-
#
|
142
|
-
# When all steps combined have not finished during the specified `timeout`, this method rejects with a TimeoutError. Passing zero timeout disables this.
|
173
|
+
# When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`.
|
174
|
+
# Passing zero timeout disables this.
|
143
175
|
#
|
144
|
-
# **NOTE** `frame.dblclick()` dispatches two `click` events and a single `dblclick` event.
|
176
|
+
# > **NOTE** `frame.dblclick()` dispatches two `click` events and a single `dblclick` event.
|
145
177
|
def dblclick(
|
146
178
|
selector,
|
147
179
|
button: nil,
|
148
180
|
delay: nil,
|
149
|
-
position: nil,
|
150
|
-
modifiers: nil,
|
151
181
|
force: nil,
|
182
|
+
modifiers: nil,
|
152
183
|
noWaitAfter: nil,
|
184
|
+
position: nil,
|
153
185
|
timeout: nil)
|
154
186
|
raise NotImplementedError.new('dblclick is not implemented yet.')
|
155
187
|
end
|
156
188
|
|
157
|
-
# The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the elment, `click`
|
189
|
+
# The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the elment, `click`
|
190
|
+
# is dispatched. This is equivalend to calling
|
191
|
+
# [element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
|
192
|
+
#
|
158
193
|
#
|
159
194
|
# ```js
|
160
195
|
# await frame.dispatchEvent('button#submit', 'click');
|
161
196
|
# ```
|
162
|
-
# Under the hood, it creates an instance of an event based on the given `type`, initializes it with `eventInit` properties and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default.
|
163
|
-
# Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial properties:
|
164
197
|
#
|
165
|
-
#
|
166
|
-
#
|
167
|
-
#
|
168
|
-
#
|
169
|
-
#
|
170
|
-
#
|
171
|
-
#
|
198
|
+
# Under the hood, it creates an instance of an event based on the given `type`, initializes it with `eventInit` properties
|
199
|
+
# and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default.
|
200
|
+
#
|
201
|
+
# Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial properties:
|
202
|
+
# - [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent)
|
203
|
+
# - [FocusEvent](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent)
|
204
|
+
# - [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent)
|
205
|
+
# - [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent)
|
206
|
+
# - [PointerEvent](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/PointerEvent)
|
207
|
+
# - [TouchEvent](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/TouchEvent)
|
208
|
+
# - [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event/Event)
|
172
209
|
#
|
173
210
|
# You can also specify `JSHandle` as the property value if you want live objects to be passed into the event:
|
211
|
+
#
|
174
212
|
#
|
175
213
|
# ```js
|
176
214
|
# // Note you can only create DataTransfer in Chromium and Firefox
|
@@ -182,8 +220,14 @@ module Playwright
|
|
182
220
|
end
|
183
221
|
|
184
222
|
# Returns the return value of `pageFunction`
|
185
|
-
#
|
186
|
-
# If the function passed to the `frame.evaluate` returns a
|
223
|
+
#
|
224
|
+
# If the function passed to the `frame.evaluate` returns a [Promise], then `frame.evaluate` would wait for the promise to
|
225
|
+
# resolve and return its value.
|
226
|
+
#
|
227
|
+
# If the function passed to the `frame.evaluate` returns a non-[Serializable] value, then `frame.evaluate` returns
|
228
|
+
# `undefined`. DevTools Protocol also supports transferring some additional values that are not serializable by `JSON`:
|
229
|
+
# `-0`, `NaN`, `Infinity`, `-Infinity`, and bigint literals.
|
230
|
+
#
|
187
231
|
#
|
188
232
|
# ```js
|
189
233
|
# const result = await frame.evaluate(([x, y]) => {
|
@@ -191,12 +235,16 @@ module Playwright
|
|
191
235
|
# }, [7, 8]);
|
192
236
|
# console.log(result); // prints "56"
|
193
237
|
# ```
|
238
|
+
#
|
194
239
|
# A string can also be passed in instead of a function.
|
240
|
+
#
|
195
241
|
#
|
196
242
|
# ```js
|
197
243
|
# console.log(await frame.evaluate('1 + 2')); // prints "3"
|
198
244
|
# ```
|
199
|
-
#
|
245
|
+
#
|
246
|
+
# `ElementHandle` instances can be passed as an argument to the `frame.evaluate`:
|
247
|
+
#
|
200
248
|
#
|
201
249
|
# ```js
|
202
250
|
# const bodyHandle = await frame.$('body');
|
@@ -208,19 +256,28 @@ module Playwright
|
|
208
256
|
end
|
209
257
|
|
210
258
|
# Returns the return value of `pageFunction` as in-page object (JSHandle).
|
211
|
-
#
|
212
|
-
#
|
259
|
+
#
|
260
|
+
# The only difference between `frame.evaluate` and `frame.evaluateHandle` is that `frame.evaluateHandle` returns in-page
|
261
|
+
# object (JSHandle).
|
262
|
+
#
|
263
|
+
# If the function, passed to the `frame.evaluateHandle`, returns a [Promise], then `frame.evaluateHandle` would wait for
|
264
|
+
# the promise to resolve and return its value.
|
265
|
+
#
|
213
266
|
#
|
214
267
|
# ```js
|
215
268
|
# const aWindowHandle = await frame.evaluateHandle(() => Promise.resolve(window));
|
216
269
|
# aWindowHandle; // Handle for the window object.
|
217
270
|
# ```
|
271
|
+
#
|
218
272
|
# A string can also be passed in instead of a function.
|
273
|
+
#
|
219
274
|
#
|
220
275
|
# ```js
|
221
276
|
# const aHandle = await frame.evaluateHandle('document'); // Handle for the 'document'.
|
222
277
|
# ```
|
223
|
-
#
|
278
|
+
#
|
279
|
+
# `JSHandle` instances can be passed as an argument to the `frame.evaluateHandle`:
|
280
|
+
#
|
224
281
|
#
|
225
282
|
# ```js
|
226
283
|
# const aHandle = await frame.evaluateHandle(() => document.body);
|
@@ -232,20 +289,29 @@ module Playwright
|
|
232
289
|
raise NotImplementedError.new('evaluate_handle is not implemented yet.')
|
233
290
|
end
|
234
291
|
|
235
|
-
# This method waits for an element matching `selector`, waits for actionability checks, focuses the
|
236
|
-
#
|
292
|
+
# This method waits for an element matching `selector`, waits for [actionability](./actionability.md) checks, focuses the
|
293
|
+
# element, fills it and triggers an `input` event after filling. If the element matching `selector` is not an `<input>`,
|
294
|
+
# `<textarea>` or `[contenteditable]` element, this method throws an error. Note that you can pass an empty string to
|
295
|
+
# clear the input field.
|
296
|
+
#
|
297
|
+
# To send fine-grained keyboard events, use [`method: Frame.type`].
|
237
298
|
def fill(selector, value, noWaitAfter: nil, timeout: nil)
|
238
299
|
raise NotImplementedError.new('fill is not implemented yet.')
|
239
300
|
end
|
240
301
|
|
241
|
-
# This method fetches an element with `selector` and focuses it. If there's no element matching `selector`, the method
|
302
|
+
# This method fetches an element with `selector` and focuses it. If there's no element matching `selector`, the method
|
303
|
+
# waits until a matching element appears in the DOM.
|
242
304
|
def focus(selector, timeout: nil)
|
243
305
|
raise NotImplementedError.new('focus is not implemented yet.')
|
244
306
|
end
|
245
307
|
|
246
308
|
# Returns the `frame` or `iframe` element handle which corresponds to this frame.
|
247
|
-
#
|
309
|
+
#
|
310
|
+
# This is an inverse of [`method: ElementHandle.contentFrame`]. Note that returned handle actually belongs to the parent
|
311
|
+
# frame.
|
312
|
+
#
|
248
313
|
# This method throws an error if the frame has been detached before `frameElement()` returns.
|
314
|
+
#
|
249
315
|
#
|
250
316
|
# ```js
|
251
317
|
# const frameElement = await frame.frameElement();
|
@@ -261,37 +327,43 @@ module Playwright
|
|
261
327
|
raise NotImplementedError.new('get_attribute is not implemented yet.')
|
262
328
|
end
|
263
329
|
|
264
|
-
# Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
|
265
|
-
#
|
330
|
+
# Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
|
331
|
+
# last redirect.
|
266
332
|
#
|
267
|
-
#
|
268
|
-
#
|
269
|
-
#
|
270
|
-
# the
|
271
|
-
# the
|
333
|
+
# `frame.goto` will throw an error if:
|
334
|
+
# - there's an SSL error (e.g. in case of self-signed certificates).
|
335
|
+
# - target URL is invalid.
|
336
|
+
# - the `timeout` is exceeded during navigation.
|
337
|
+
# - the remote server does not respond or is unreachable.
|
338
|
+
# - the main resource failed to load.
|
272
339
|
#
|
273
|
-
# `frame.goto` will not throw an error when any valid HTTP status code is returned by the remote server, including 404
|
340
|
+
# `frame.goto` will not throw an error when any valid HTTP status code is returned by the remote server, including 404
|
341
|
+
# "Not Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling
|
342
|
+
# [`method: Response.status`].
|
274
343
|
#
|
275
|
-
# **NOTE** `frame.goto` either throws an error or returns a main resource response. The only exceptions are navigation
|
276
|
-
#
|
277
|
-
|
278
|
-
|
344
|
+
# > **NOTE** `frame.goto` either throws an error or returns a main resource response. The only exceptions are navigation
|
345
|
+
# to `about:blank` or navigation to the same URL with a different hash, which would succeed and return `null`.
|
346
|
+
# > **NOTE** Headless mode doesn't support navigation to a PDF document. See the
|
347
|
+
# [upstream issue](https://bugs.chromium.org/p/chromium/issues/detail?id=761295).
|
348
|
+
def goto(url, referer: nil, timeout: nil, waitUntil: nil)
|
349
|
+
wrap_channel_owner(@channel_owner.goto(url, referer: referer, timeout: timeout, waitUntil: waitUntil))
|
279
350
|
end
|
280
351
|
|
281
352
|
# This method hovers over an element matching `selector` by performing the following steps:
|
353
|
+
# 1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
354
|
+
# 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the
|
355
|
+
# element is detached during the checks, the whole action is retried.
|
356
|
+
# 1. Scroll the element into view if needed.
|
357
|
+
# 1. Use [`property: Page.mouse`] to hover over the center of the element, or the specified `position`.
|
358
|
+
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
282
359
|
#
|
283
|
-
#
|
284
|
-
#
|
285
|
-
# Scroll the element into view if needed.
|
286
|
-
# Use page.mouse to hover over the center of the element, or the specified `position`.
|
287
|
-
# Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
288
|
-
#
|
289
|
-
# When all steps combined have not finished during the specified `timeout`, this method rejects with a TimeoutError. Passing zero timeout disables this.
|
360
|
+
# When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`.
|
361
|
+
# Passing zero timeout disables this.
|
290
362
|
def hover(
|
291
363
|
selector,
|
292
|
-
position: nil,
|
293
|
-
modifiers: nil,
|
294
364
|
force: nil,
|
365
|
+
modifiers: nil,
|
366
|
+
position: nil,
|
295
367
|
timeout: nil)
|
296
368
|
raise NotImplementedError.new('hover is not implemented yet.')
|
297
369
|
end
|
@@ -306,15 +378,47 @@ module Playwright
|
|
306
378
|
raise NotImplementedError.new('inner_text is not implemented yet.')
|
307
379
|
end
|
308
380
|
|
381
|
+
# Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
|
382
|
+
def checked?(selector, timeout: nil)
|
383
|
+
raise NotImplementedError.new('checked? is not implemented yet.')
|
384
|
+
end
|
385
|
+
|
309
386
|
# Returns `true` if the frame has been detached, or `false` otherwise.
|
310
387
|
def detached?
|
311
388
|
raise NotImplementedError.new('detached? is not implemented yet.')
|
312
389
|
end
|
313
390
|
|
391
|
+
# Returns whether the element is disabled, the opposite of [enabled](./actionability.md#enabled).
|
392
|
+
def disabled?(selector, timeout: nil)
|
393
|
+
raise NotImplementedError.new('disabled? is not implemented yet.')
|
394
|
+
end
|
395
|
+
|
396
|
+
# Returns whether the element is [editable](./actionability.md#editable).
|
397
|
+
def editable?(selector, timeout: nil)
|
398
|
+
raise NotImplementedError.new('editable? is not implemented yet.')
|
399
|
+
end
|
400
|
+
|
401
|
+
# Returns whether the element is [enabled](./actionability.md#enabled).
|
402
|
+
def enabled?(selector, timeout: nil)
|
403
|
+
raise NotImplementedError.new('enabled? is not implemented yet.')
|
404
|
+
end
|
405
|
+
|
406
|
+
# Returns whether the element is hidden, the opposite of [visible](./actionability.md#visible).
|
407
|
+
def hidden?(selector, timeout: nil)
|
408
|
+
raise NotImplementedError.new('hidden? is not implemented yet.')
|
409
|
+
end
|
410
|
+
|
411
|
+
# Returns whether the element is [visible](./actionability.md#visible).
|
412
|
+
def visible?(selector, timeout: nil)
|
413
|
+
raise NotImplementedError.new('visible? is not implemented yet.')
|
414
|
+
end
|
415
|
+
|
314
416
|
# Returns frame's name attribute as specified in the tag.
|
417
|
+
#
|
315
418
|
# If the name is empty, returns the id attribute instead.
|
316
419
|
#
|
317
|
-
# **NOTE** This value is calculated once when the frame is created, and will not update if the attribute is changed
|
420
|
+
# > **NOTE** This value is calculated once when the frame is created, and will not update if the attribute is changed
|
421
|
+
# later.
|
318
422
|
def name
|
319
423
|
raise NotImplementedError.new('name is not implemented yet.')
|
320
424
|
end
|
@@ -329,12 +433,22 @@ module Playwright
|
|
329
433
|
raise NotImplementedError.new('parent_frame is not implemented yet.')
|
330
434
|
end
|
331
435
|
|
332
|
-
# `key` can specify the intended keyboardEvent.key
|
333
|
-
#
|
334
|
-
#
|
436
|
+
# `key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)
|
437
|
+
# value or a single character to generate the text for. A superset of the `key` values can be found
|
438
|
+
# [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
|
439
|
+
#
|
440
|
+
# `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
|
441
|
+
# `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
|
442
|
+
#
|
443
|
+
# Following modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`.
|
444
|
+
#
|
335
445
|
# Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
|
336
|
-
#
|
337
|
-
#
|
446
|
+
#
|
447
|
+
# If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
|
448
|
+
# texts.
|
449
|
+
#
|
450
|
+
# Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When speficied with the
|
451
|
+
# modifier, modifier is pressed and being held while the subsequent key is being pressed.
|
338
452
|
def press(
|
339
453
|
selector,
|
340
454
|
key,
|
@@ -345,7 +459,10 @@ module Playwright
|
|
345
459
|
end
|
346
460
|
|
347
461
|
# Returns the array of option values that have been successfully selected.
|
348
|
-
#
|
462
|
+
#
|
463
|
+
# Triggers a `change` and `input` event once all the provided options have been selected. If there's no `<select>` element
|
464
|
+
# matching `selector`, the method throws an error.
|
465
|
+
#
|
349
466
|
#
|
350
467
|
# ```js
|
351
468
|
# // single selection matching the value
|
@@ -365,29 +482,33 @@ module Playwright
|
|
365
482
|
raise NotImplementedError.new('set_content is not implemented yet.')
|
366
483
|
end
|
367
484
|
|
368
|
-
# This method expects `selector` to point to an
|
369
|
-
#
|
485
|
+
# This method expects `selector` to point to an
|
486
|
+
# [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
|
487
|
+
#
|
488
|
+
# Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
|
489
|
+
# are resolved relative to the the current working directory. For empty array, clears the selected files.
|
370
490
|
def set_input_files(selector, files, noWaitAfter: nil, timeout: nil)
|
371
491
|
raise NotImplementedError.new('set_input_files is not implemented yet.')
|
372
492
|
end
|
373
493
|
|
374
494
|
# This method taps an element matching `selector` by performing the following steps:
|
495
|
+
# 1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
496
|
+
# 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the
|
497
|
+
# element is detached during the checks, the whole action is retried.
|
498
|
+
# 1. Scroll the element into view if needed.
|
499
|
+
# 1. Use [`property: Page.touchscreen`] to tap the center of the element, or the specified `position`.
|
500
|
+
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
375
501
|
#
|
376
|
-
#
|
377
|
-
#
|
378
|
-
# Scroll the element into view if needed.
|
379
|
-
# Use page.touchscreen to tap the center of the element, or the specified `position`.
|
380
|
-
# Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
502
|
+
# When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`.
|
503
|
+
# Passing zero timeout disables this.
|
381
504
|
#
|
382
|
-
#
|
383
|
-
#
|
384
|
-
# **NOTE** `frame.tap()` requires that the `hasTouch` option of the browser context be set to true.
|
505
|
+
# > **NOTE** `frame.tap()` requires that the `hasTouch` option of the browser context be set to true.
|
385
506
|
def tap_point(
|
386
507
|
selector,
|
387
|
-
|
508
|
+
force: nil,
|
388
509
|
modifiers: nil,
|
389
510
|
noWaitAfter: nil,
|
390
|
-
|
511
|
+
position: nil,
|
391
512
|
timeout: nil)
|
392
513
|
raise NotImplementedError.new('tap_point is not implemented yet.')
|
393
514
|
end
|
@@ -402,8 +523,11 @@ module Playwright
|
|
402
523
|
raise NotImplementedError.new('title is not implemented yet.')
|
403
524
|
end
|
404
525
|
|
405
|
-
# Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. `frame.type` can be used to
|
406
|
-
#
|
526
|
+
# Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. `frame.type` can be used to
|
527
|
+
# send fine-grained keyboard events. To fill values in form fields, use [`method: Frame.fill`].
|
528
|
+
#
|
529
|
+
# To press a special key, like `Control` or `ArrowDown`, use [`method: Keyboard.press`].
|
530
|
+
#
|
407
531
|
#
|
408
532
|
# ```js
|
409
533
|
# await frame.type('#mytextarea', 'Hello'); // Types instantly
|
@@ -419,16 +543,18 @@ module Playwright
|
|
419
543
|
end
|
420
544
|
|
421
545
|
# This method checks an element matching `selector` by performing the following steps:
|
546
|
+
# 1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
547
|
+
# 1. Ensure that matched element is a checkbox or a radio input. If not, this method rejects. If the element is already
|
548
|
+
# unchecked, this method returns immediately.
|
549
|
+
# 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the
|
550
|
+
# element is detached during the checks, the whole action is retried.
|
551
|
+
# 1. Scroll the element into view if needed.
|
552
|
+
# 1. Use [`property: Page.mouse`] to click in the center of the element.
|
553
|
+
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
554
|
+
# 1. Ensure that the element is now unchecked. If not, this method rejects.
|
422
555
|
#
|
423
|
-
#
|
424
|
-
#
|
425
|
-
# Wait for actionability checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
|
426
|
-
# Scroll the element into view if needed.
|
427
|
-
# Use page.mouse to click in the center of the element.
|
428
|
-
# Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
429
|
-
# Ensure that the element is now unchecked. If not, this method rejects.
|
430
|
-
#
|
431
|
-
# When all steps combined have not finished during the specified `timeout`, this method rejects with a TimeoutError. Passing zero timeout disables this.
|
556
|
+
# When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`.
|
557
|
+
# Passing zero timeout disables this.
|
432
558
|
def uncheck(selector, force: nil, noWaitAfter: nil, timeout: nil)
|
433
559
|
raise NotImplementedError.new('uncheck is not implemented yet.')
|
434
560
|
end
|
@@ -439,7 +565,9 @@ module Playwright
|
|
439
565
|
end
|
440
566
|
|
441
567
|
# Returns when the `pageFunction` returns a truthy value, returns that value.
|
568
|
+
#
|
442
569
|
# The `waitForFunction` can be used to observe viewport size change:
|
570
|
+
#
|
443
571
|
#
|
444
572
|
# ```js
|
445
573
|
# const { firefox } = require('playwright'); // Or 'chromium' or 'webkit'.
|
@@ -453,7 +581,9 @@ module Playwright
|
|
453
581
|
# await browser.close();
|
454
582
|
# })();
|
455
583
|
# ```
|
584
|
+
#
|
456
585
|
# To pass an argument to the predicate of `frame.waitForFunction` function:
|
586
|
+
#
|
457
587
|
#
|
458
588
|
# ```js
|
459
589
|
# const selector = '.foo';
|
@@ -464,7 +594,10 @@ module Playwright
|
|
464
594
|
end
|
465
595
|
|
466
596
|
# Waits for the required load state to be reached.
|
467
|
-
#
|
597
|
+
#
|
598
|
+
# This returns when the frame reaches a required load state, `load` by default. The navigation must have been committed
|
599
|
+
# when this method is called. If current document has already reached the required state, resolves immediately.
|
600
|
+
#
|
468
601
|
#
|
469
602
|
# ```js
|
470
603
|
# await frame.click('button'); // Click triggers navigation.
|
@@ -474,8 +607,13 @@ module Playwright
|
|
474
607
|
raise NotImplementedError.new('wait_for_load_state is not implemented yet.')
|
475
608
|
end
|
476
609
|
|
477
|
-
# Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
|
478
|
-
#
|
610
|
+
# Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
|
611
|
+
# last redirect. In case of navigation to a different anchor or navigation due to History API usage, the navigation will
|
612
|
+
# resolve with `null`.
|
613
|
+
#
|
614
|
+
# This method waits for the frame to navigate to a new URL. It is useful for when you run code which will indirectly cause
|
615
|
+
# the frame to navigate. Consider this example:
|
616
|
+
#
|
479
617
|
#
|
480
618
|
# ```js
|
481
619
|
# const [response] = await Promise.all([
|
@@ -483,14 +621,22 @@ module Playwright
|
|
483
621
|
# frame.click('a.my-link'), // Clicking the link will indirectly cause a navigation
|
484
622
|
# ]);
|
485
623
|
# ```
|
486
|
-
#
|
624
|
+
#
|
625
|
+
# **NOTE** Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the URL is
|
626
|
+
# considered a navigation.
|
487
627
|
def wait_for_navigation(timeout: nil, url: nil, waitUntil: nil)
|
488
628
|
raise NotImplementedError.new('wait_for_navigation is not implemented yet.')
|
489
629
|
end
|
490
630
|
|
491
|
-
# Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or
|
492
|
-
#
|
631
|
+
# Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or
|
632
|
+
# `detached`.
|
633
|
+
#
|
634
|
+
# Wait for the `selector` to satisfy `state` option (either appear/disappear from dom, or become visible/hidden). If at
|
635
|
+
# the moment of calling the method `selector` already satisfies the condition, the method will return immediately. If the
|
636
|
+
# selector doesn't satisfy the condition for the `timeout` milliseconds, the function will throw.
|
637
|
+
#
|
493
638
|
# This method works across navigations:
|
639
|
+
#
|
494
640
|
#
|
495
641
|
# ```js
|
496
642
|
# const { webkit } = require('playwright'); // Or 'chromium' or 'firefox'.
|
@@ -513,7 +659,9 @@ module Playwright
|
|
513
659
|
end
|
514
660
|
|
515
661
|
# Waits for the given `timeout` in milliseconds.
|
516
|
-
#
|
662
|
+
#
|
663
|
+
# Note that `frame.waitForTimeout()` should only be used for debugging. Tests using the timer in production are going to
|
664
|
+
# be flaky. Use signals such as network events, selectors becoming visible and others instead.
|
517
665
|
def wait_for_timeout(timeout)
|
518
666
|
raise NotImplementedError.new('wait_for_timeout is not implemented yet.')
|
519
667
|
end
|