playwright-ruby-client 1.28.1 → 1.29.0
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 +9 -14
- data/documentation/docs/api/api_request_context.md +44 -41
- data/documentation/docs/api/api_response.md +13 -3
- data/documentation/docs/api/browser.md +24 -23
- data/documentation/docs/api/browser_context.md +71 -45
- data/documentation/docs/api/browser_type.md +21 -14
- data/documentation/docs/api/cdp_session.md +3 -5
- data/documentation/docs/api/console_message.md +7 -4
- data/documentation/docs/api/dialog.md +9 -5
- data/documentation/docs/api/download.md +19 -11
- data/documentation/docs/api/element_handle.md +125 -116
- data/documentation/docs/api/experimental/android.md +4 -5
- data/documentation/docs/api/experimental/android_device.md +11 -2
- data/documentation/docs/api/experimental/android_input.md +5 -0
- data/documentation/docs/api/file_chooser.md +6 -3
- data/documentation/docs/api/frame.md +182 -171
- data/documentation/docs/api/frame_locator.md +27 -38
- data/documentation/docs/api/js_handle.md +16 -10
- data/documentation/docs/api/keyboard.md +29 -16
- data/documentation/docs/api/locator.md +189 -140
- data/documentation/docs/api/mouse.md +9 -4
- data/documentation/docs/api/page.md +304 -289
- data/documentation/docs/api/playwright.md +8 -5
- data/documentation/docs/api/request.md +34 -15
- data/documentation/docs/api/response.md +27 -10
- data/documentation/docs/api/route.md +44 -12
- data/documentation/docs/api/selectors.md +5 -3
- data/documentation/docs/api/touchscreen.md +2 -0
- data/documentation/docs/api/tracing.md +11 -11
- data/documentation/docs/api/web_socket.md +9 -4
- data/documentation/docs/api/worker.md +12 -11
- data/documentation/docs/include/api_coverage.md +2 -0
- data/lib/playwright/channel_owners/api_request_context.rb +37 -2
- data/lib/playwright/channel_owners/browser_context.rb +22 -26
- data/lib/playwright/channel_owners/page.rb +35 -25
- data/lib/playwright/channel_owners/route.rb +28 -8
- data/lib/playwright/event_emitter.rb +6 -1
- data/lib/playwright/locator_impl.rb +8 -0
- data/lib/playwright/select_option_values.rb +2 -0
- data/lib/playwright/version.rb +2 -2
- data/lib/playwright_api/accessibility.rb +9 -13
- data/lib/playwright_api/android.rb +8 -6
- data/lib/playwright_api/android_device.rb +32 -7
- data/lib/playwright_api/android_input.rb +5 -0
- data/lib/playwright_api/android_socket.rb +4 -2
- data/lib/playwright_api/android_web_view.rb +5 -2
- data/lib/playwright_api/api_request.rb +6 -3
- data/lib/playwright_api/api_request_context.rb +46 -36
- data/lib/playwright_api/api_response.rb +13 -2
- data/lib/playwright_api/browser.rb +24 -16
- data/lib/playwright_api/browser_context.rb +76 -39
- data/lib/playwright_api/browser_type.rb +23 -13
- data/lib/playwright_api/cdp_session.rb +3 -4
- data/lib/playwright_api/console_message.rb +7 -2
- data/lib/playwright_api/dialog.rb +8 -4
- data/lib/playwright_api/download.rb +19 -9
- data/lib/playwright_api/element_handle.rb +116 -93
- data/lib/playwright_api/file_chooser.rb +6 -1
- data/lib/playwright_api/frame.rb +180 -135
- data/lib/playwright_api/frame_locator.rb +29 -32
- data/lib/playwright_api/js_handle.rb +16 -6
- data/lib/playwright_api/keyboard.rb +29 -14
- data/lib/playwright_api/locator.rb +183 -112
- data/lib/playwright_api/mouse.rb +9 -2
- data/lib/playwright_api/page.rb +301 -253
- data/lib/playwright_api/playwright.rb +11 -4
- data/lib/playwright_api/request.rb +34 -7
- data/lib/playwright_api/response.rb +27 -10
- data/lib/playwright_api/route.rb +44 -11
- data/lib/playwright_api/selectors.rb +6 -1
- data/lib/playwright_api/touchscreen.rb +2 -0
- data/lib/playwright_api/tracing.rb +11 -5
- data/lib/playwright_api/web_socket.rb +9 -4
- data/lib/playwright_api/worker.rb +16 -13
- data/playwright.gemspec +1 -1
- metadata +7 -7
@@ -3,10 +3,9 @@ require_relative './js_handle.rb'
|
|
3
3
|
module Playwright
|
4
4
|
# - extends: `JSHandle`
|
5
5
|
#
|
6
|
-
# ElementHandle represents an in-page DOM element. ElementHandles can be created with the [`method: Page.querySelector`]
|
7
|
-
# method.
|
6
|
+
# ElementHandle represents an in-page DOM element. ElementHandles can be created with the [`method: Page.querySelector`] method.
|
8
7
|
#
|
9
|
-
#
|
8
|
+
# **NOTE**: The use of ElementHandle is discouraged, use `Locator` objects and web-first assertions instead.
|
10
9
|
#
|
11
10
|
# ```python sync
|
12
11
|
# href_element = page.query_selector("a")
|
@@ -16,15 +15,11 @@ module Playwright
|
|
16
15
|
# ElementHandle prevents DOM element from garbage collection unless the handle is disposed with
|
17
16
|
# [`method: JSHandle.dispose`]. ElementHandles are auto-disposed when their origin frame gets navigated.
|
18
17
|
#
|
19
|
-
# ElementHandle instances can be used as an argument in [`method: Page.evalOnSelector`] and [`method: Page.evaluate`]
|
20
|
-
# methods.
|
18
|
+
# ElementHandle instances can be used as an argument in [`method: Page.evalOnSelector`] and [`method: Page.evaluate`] methods.
|
21
19
|
#
|
22
|
-
# The difference between the `Locator` and ElementHandle is that the ElementHandle points to a particular element, while
|
23
|
-
# `Locator` captures the logic of how to retrieve an element.
|
20
|
+
# The difference between the `Locator` and ElementHandle is that the ElementHandle points to a particular element, while `Locator` captures the logic of how to retrieve an element.
|
24
21
|
#
|
25
|
-
# In the example below, handle points to a particular DOM element on page. If that element changes text or is used by
|
26
|
-
# React to render an entirely different component, handle is still pointing to that very DOM element. This can lead to
|
27
|
-
# unexpected behaviors.
|
22
|
+
# In the example below, handle points to a particular DOM element on page. If that element changes text or is used by React to render an entirely different component, handle is still pointing to that very DOM element. This can lead to unexpected behaviors.
|
28
23
|
#
|
29
24
|
# ```python sync
|
30
25
|
# handle = page.query_selector("text=Submit")
|
@@ -32,8 +27,7 @@ module Playwright
|
|
32
27
|
# handle.click()
|
33
28
|
# ```
|
34
29
|
#
|
35
|
-
# With the locator, every time the `element` is used, up-to-date DOM element is located in the page using the selector. So
|
36
|
-
# in the snippet below, underlying DOM element is going to be located twice.
|
30
|
+
# With the locator, every time the `element` is used, up-to-date DOM element is located in the page using the selector. So in the snippet below, underlying DOM element is going to be located twice.
|
37
31
|
#
|
38
32
|
# ```python sync
|
39
33
|
# locator = page.get_by_text("Submit")
|
@@ -42,6 +36,7 @@ module Playwright
|
|
42
36
|
# ```
|
43
37
|
class ElementHandle < JSHandle
|
44
38
|
|
39
|
+
#
|
45
40
|
# This method returns the bounding box of the element, or `null` if the element is not visible. The bounding box is
|
46
41
|
# calculated relative to the main frame viewport - which is usually the same as the browser window.
|
47
42
|
#
|
@@ -55,6 +50,8 @@ module Playwright
|
|
55
50
|
# Assuming the page is static, it is safe to use bounding box coordinates to perform input. For example, the following
|
56
51
|
# snippet should click the center of the element.
|
57
52
|
#
|
53
|
+
# **Usage**
|
54
|
+
#
|
58
55
|
# ```python sync
|
59
56
|
# box = element_handle.bounding_box()
|
60
57
|
# page.mouse.click(box["x"] + box["width"] / 2, box["y"] + box["height"] / 2)
|
@@ -63,9 +60,9 @@ module Playwright
|
|
63
60
|
wrap_impl(@impl.bounding_box)
|
64
61
|
end
|
65
62
|
|
63
|
+
#
|
66
64
|
# This method checks the element by performing the following steps:
|
67
|
-
# 1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already checked,
|
68
|
-
# this method returns immediately.
|
65
|
+
# 1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already checked, this method returns immediately.
|
69
66
|
# 1. Wait for [actionability](../actionability.md) checks on the element, unless `force` option is set.
|
70
67
|
# 1. Scroll the element into view if needed.
|
71
68
|
# 1. Use [`property: Page.mouse`] to click in the center of the element.
|
@@ -74,8 +71,8 @@ module Playwright
|
|
74
71
|
#
|
75
72
|
# If the element is detached from the DOM at any moment during the action, this method throws.
|
76
73
|
#
|
77
|
-
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
78
|
-
# zero timeout disables this.
|
74
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
75
|
+
# `TimeoutError`. Passing zero timeout disables this.
|
79
76
|
def check(
|
80
77
|
force: nil,
|
81
78
|
noWaitAfter: nil,
|
@@ -85,6 +82,7 @@ module Playwright
|
|
85
82
|
wrap_impl(@impl.check(force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
86
83
|
end
|
87
84
|
|
85
|
+
#
|
88
86
|
# This method clicks the element by performing the following steps:
|
89
87
|
# 1. Wait for [actionability](../actionability.md) checks on the element, unless `force` option is set.
|
90
88
|
# 1. Scroll the element into view if needed.
|
@@ -93,8 +91,8 @@ module Playwright
|
|
93
91
|
#
|
94
92
|
# If the element is detached from the DOM at any moment during the action, this method throws.
|
95
93
|
#
|
96
|
-
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
97
|
-
# zero timeout disables this.
|
94
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
95
|
+
# `TimeoutError`. Passing zero timeout disables this.
|
98
96
|
def click(
|
99
97
|
button: nil,
|
100
98
|
clickCount: nil,
|
@@ -108,24 +106,25 @@ module Playwright
|
|
108
106
|
wrap_impl(@impl.click(button: unwrap_impl(button), clickCount: unwrap_impl(clickCount), delay: unwrap_impl(delay), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
109
107
|
end
|
110
108
|
|
109
|
+
#
|
111
110
|
# Returns the content frame for element handles referencing iframe nodes, or `null` otherwise
|
112
111
|
def content_frame
|
113
112
|
wrap_impl(@impl.content_frame)
|
114
113
|
end
|
115
114
|
|
115
|
+
#
|
116
116
|
# This method double clicks the element by performing the following steps:
|
117
117
|
# 1. Wait for [actionability](../actionability.md) checks on the element, unless `force` option is set.
|
118
118
|
# 1. Scroll the element into view if needed.
|
119
119
|
# 1. Use [`property: Page.mouse`] to double click in the center of the element, or the specified `position`.
|
120
|
-
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the
|
121
|
-
# first click of the `dblclick()` triggers a navigation event, this method will throw.
|
120
|
+
# 1. 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 throw.
|
122
121
|
#
|
123
122
|
# If the element is detached from the DOM at any moment during the action, this method throws.
|
124
123
|
#
|
125
|
-
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
126
|
-
# zero timeout disables this.
|
124
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
125
|
+
# `TimeoutError`. Passing zero timeout disables this.
|
127
126
|
#
|
128
|
-
#
|
127
|
+
# **NOTE**: `elementHandle.dblclick()` dispatches two `click` events and a single `dblclick` event.
|
129
128
|
def dblclick(
|
130
129
|
button: nil,
|
131
130
|
delay: nil,
|
@@ -138,18 +137,23 @@ module Playwright
|
|
138
137
|
wrap_impl(@impl.dblclick(button: unwrap_impl(button), delay: unwrap_impl(delay), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
139
138
|
end
|
140
139
|
|
141
|
-
#
|
142
|
-
# `click`
|
140
|
+
#
|
141
|
+
# The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element, `click`
|
142
|
+
# is dispatched. This is equivalent to calling
|
143
143
|
# [element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
|
144
144
|
#
|
145
|
+
# **Usage**
|
146
|
+
#
|
145
147
|
# ```python sync
|
146
148
|
# element_handle.dispatch_event("click")
|
147
149
|
# ```
|
148
150
|
#
|
149
|
-
# Under the hood, it creates an instance of an event based on the given `type`, initializes it with
|
150
|
-
# and dispatches it on the element. Events are `composed`, `cancelable` and bubble by
|
151
|
+
# Under the hood, it creates an instance of an event based on the given `type`, initializes it with
|
152
|
+
# `eventInit` properties and dispatches it on the element. Events are `composed`, `cancelable` and bubble by
|
153
|
+
# default.
|
151
154
|
#
|
152
|
-
# Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial
|
155
|
+
# Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial
|
156
|
+
# properties:
|
153
157
|
# - [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent)
|
154
158
|
# - [FocusEvent](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent)
|
155
159
|
# - [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent)
|
@@ -169,16 +173,16 @@ module Playwright
|
|
169
173
|
wrap_impl(@impl.dispatch_event(unwrap_impl(type), eventInit: unwrap_impl(eventInit)))
|
170
174
|
end
|
171
175
|
|
176
|
+
#
|
172
177
|
# Returns the return value of `expression`.
|
173
178
|
#
|
174
179
|
# The method finds an element matching the specified selector in the `ElementHandle`s subtree and passes it as a first
|
175
|
-
# argument to `expression`.
|
176
|
-
# selector, the method throws an error.
|
180
|
+
# argument to `expression`. If no elements match the selector, the method throws an error.
|
177
181
|
#
|
178
|
-
# If `expression` returns a [Promise], then [`method: ElementHandle.evalOnSelector`] would wait for the promise to resolve
|
179
|
-
#
|
182
|
+
# If `expression` returns a [Promise], then [`method: ElementHandle.evalOnSelector`] would wait for the promise to resolve and return its
|
183
|
+
# value.
|
180
184
|
#
|
181
|
-
#
|
185
|
+
# **Usage**
|
182
186
|
#
|
183
187
|
# ```python sync
|
184
188
|
# tweet_handle = page.query_selector(".tweet")
|
@@ -189,15 +193,16 @@ module Playwright
|
|
189
193
|
wrap_impl(@impl.eval_on_selector(unwrap_impl(selector), unwrap_impl(expression), arg: unwrap_impl(arg)))
|
190
194
|
end
|
191
195
|
|
196
|
+
#
|
192
197
|
# Returns the return value of `expression`.
|
193
198
|
#
|
194
199
|
# The method finds all elements matching the specified selector in the `ElementHandle`'s subtree and passes an array of
|
195
|
-
# matched elements as a first argument to `expression`.
|
200
|
+
# matched elements as a first argument to `expression`.
|
196
201
|
#
|
197
|
-
# If `expression` returns a [Promise], then [`method: ElementHandle.evalOnSelectorAll`] would wait for the promise to
|
198
|
-
#
|
202
|
+
# If `expression` returns a [Promise], then [`method: ElementHandle.evalOnSelectorAll`] would wait for the promise to resolve and return its
|
203
|
+
# value.
|
199
204
|
#
|
200
|
-
#
|
205
|
+
# **Usage**
|
201
206
|
#
|
202
207
|
# ```html
|
203
208
|
# <div class="feed">
|
@@ -214,30 +219,30 @@ module Playwright
|
|
214
219
|
wrap_impl(@impl.eval_on_selector_all(unwrap_impl(selector), unwrap_impl(expression), arg: unwrap_impl(arg)))
|
215
220
|
end
|
216
221
|
|
217
|
-
# This method waits for [actionability](../actionability.md) checks, focuses the element, fills it and triggers an `input`
|
218
|
-
# event after filling. Note that you can pass an empty string to clear the input field.
|
219
222
|
#
|
220
|
-
#
|
221
|
-
#
|
222
|
-
# [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled
|
223
|
-
# instead.
|
223
|
+
# This method waits for [actionability](../actionability.md) checks, focuses the element, fills it and triggers an `input` event after filling. Note that you can pass an empty string to clear the input field.
|
224
|
+
#
|
225
|
+
# If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error. However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled instead.
|
224
226
|
#
|
225
227
|
# To send fine-grained keyboard events, use [`method: ElementHandle.type`].
|
226
228
|
def fill(value, force: nil, noWaitAfter: nil, timeout: nil)
|
227
229
|
wrap_impl(@impl.fill(unwrap_impl(value), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
228
230
|
end
|
229
231
|
|
232
|
+
#
|
230
233
|
# Calls [focus](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the element.
|
231
234
|
def focus
|
232
235
|
wrap_impl(@impl.focus)
|
233
236
|
end
|
234
237
|
|
238
|
+
#
|
235
239
|
# Returns element attribute value.
|
236
240
|
def get_attribute(name)
|
237
241
|
wrap_impl(@impl.get_attribute(unwrap_impl(name)))
|
238
242
|
end
|
239
243
|
alias_method :[], :get_attribute
|
240
244
|
|
245
|
+
#
|
241
246
|
# This method hovers over the element by performing the following steps:
|
242
247
|
# 1. Wait for [actionability](../actionability.md) checks on the element, unless `force` option is set.
|
243
248
|
# 1. Scroll the element into view if needed.
|
@@ -246,8 +251,8 @@ module Playwright
|
|
246
251
|
#
|
247
252
|
# If the element is detached from the DOM at any moment during the action, this method throws.
|
248
253
|
#
|
249
|
-
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
250
|
-
# zero timeout disables this.
|
254
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
255
|
+
# `TimeoutError`. Passing zero timeout disables this.
|
251
256
|
def hover(
|
252
257
|
force: nil,
|
253
258
|
modifiers: nil,
|
@@ -258,63 +263,74 @@ module Playwright
|
|
258
263
|
wrap_impl(@impl.hover(force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
259
264
|
end
|
260
265
|
|
266
|
+
#
|
261
267
|
# Returns the `element.innerHTML`.
|
262
268
|
def inner_html
|
263
269
|
wrap_impl(@impl.inner_html)
|
264
270
|
end
|
265
271
|
|
272
|
+
#
|
266
273
|
# Returns the `element.innerText`.
|
267
274
|
def inner_text
|
268
275
|
wrap_impl(@impl.inner_text)
|
269
276
|
end
|
270
277
|
|
278
|
+
#
|
271
279
|
# Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element.
|
272
280
|
#
|
273
|
-
# Throws for non-input elements. However, if the element is inside the `<label>` element that has an associated
|
274
|
-
# [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), returns the value of the control.
|
281
|
+
# Throws for non-input elements. However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), returns the value of the control.
|
275
282
|
def input_value(timeout: nil)
|
276
283
|
wrap_impl(@impl.input_value(timeout: unwrap_impl(timeout)))
|
277
284
|
end
|
278
285
|
|
286
|
+
#
|
279
287
|
# Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
|
280
288
|
def checked?
|
281
289
|
wrap_impl(@impl.checked?)
|
282
290
|
end
|
283
291
|
|
292
|
+
#
|
284
293
|
# Returns whether the element is disabled, the opposite of [enabled](../actionability.md#enabled).
|
285
294
|
def disabled?
|
286
295
|
wrap_impl(@impl.disabled?)
|
287
296
|
end
|
288
297
|
|
298
|
+
#
|
289
299
|
# Returns whether the element is [editable](../actionability.md#editable).
|
290
300
|
def editable?
|
291
301
|
wrap_impl(@impl.editable?)
|
292
302
|
end
|
293
303
|
|
304
|
+
#
|
294
305
|
# Returns whether the element is [enabled](../actionability.md#enabled).
|
295
306
|
def enabled?
|
296
307
|
wrap_impl(@impl.enabled?)
|
297
308
|
end
|
298
309
|
|
310
|
+
#
|
299
311
|
# Returns whether the element is hidden, the opposite of [visible](../actionability.md#visible).
|
300
312
|
def hidden?
|
301
313
|
wrap_impl(@impl.hidden?)
|
302
314
|
end
|
303
315
|
|
316
|
+
#
|
304
317
|
# Returns whether the element is [visible](../actionability.md#visible).
|
305
318
|
def visible?
|
306
319
|
wrap_impl(@impl.visible?)
|
307
320
|
end
|
308
321
|
|
322
|
+
#
|
309
323
|
# Returns the frame containing the given element.
|
310
324
|
def owner_frame
|
311
325
|
wrap_impl(@impl.owner_frame)
|
312
326
|
end
|
313
327
|
|
328
|
+
#
|
314
329
|
# Focuses the element, and then uses [`method: Keyboard.down`] and [`method: Keyboard.up`].
|
315
330
|
#
|
316
|
-
# `key` can specify the intended
|
317
|
-
# value or a single character to
|
331
|
+
# `key` can specify the intended
|
332
|
+
# [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to
|
333
|
+
# generate the text for. A superset of the `key` values can be found
|
318
334
|
# [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
|
319
335
|
#
|
320
336
|
# `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
|
@@ -324,8 +340,8 @@ module Playwright
|
|
324
340
|
#
|
325
341
|
# Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
|
326
342
|
#
|
327
|
-
# If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different
|
328
|
-
# texts.
|
343
|
+
# If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different
|
344
|
+
# respective texts.
|
329
345
|
#
|
330
346
|
# Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
|
331
347
|
# modifier, modifier is pressed and being held while the subsequent key is being pressed.
|
@@ -333,21 +349,22 @@ module Playwright
|
|
333
349
|
wrap_impl(@impl.press(unwrap_impl(key), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
334
350
|
end
|
335
351
|
|
336
|
-
#
|
337
|
-
#
|
352
|
+
#
|
353
|
+
# The method finds an element matching the specified selector in the `ElementHandle`'s subtree. If no elements match the selector,
|
354
|
+
# returns `null`.
|
338
355
|
def query_selector(selector)
|
339
356
|
wrap_impl(@impl.query_selector(unwrap_impl(selector)))
|
340
357
|
end
|
341
358
|
|
342
|
-
#
|
343
|
-
#
|
359
|
+
#
|
360
|
+
# The method finds all elements matching the specified selector in the `ElementHandle`s subtree. If no elements match the selector,
|
361
|
+
# returns empty array.
|
344
362
|
def query_selector_all(selector)
|
345
363
|
wrap_impl(@impl.query_selector_all(unwrap_impl(selector)))
|
346
364
|
end
|
347
365
|
|
348
|
-
#
|
349
|
-
# element is covered by other elements, it will not be actually visible on the screenshot. If the element is a scrollable
|
350
|
-
# container, only the currently scrolled content will be visible on the screenshot.
|
366
|
+
#
|
367
|
+
# This method captures a screenshot of the page, clipped to the size and position of this particular element. If the element is covered by other elements, it will not be actually visible on the screenshot. If the element is a scrollable container, only the currently scrolled content will be visible on the screenshot.
|
351
368
|
#
|
352
369
|
# This method waits for the [actionability](../actionability.md) checks, then scrolls element into view before taking a
|
353
370
|
# screenshot. If the element is detached from DOM, the method throws an error.
|
@@ -366,6 +383,7 @@ module Playwright
|
|
366
383
|
wrap_impl(@impl.screenshot(animations: unwrap_impl(animations), caret: unwrap_impl(caret), mask: unwrap_impl(mask), omitBackground: unwrap_impl(omitBackground), path: unwrap_impl(path), quality: unwrap_impl(quality), scale: unwrap_impl(scale), timeout: unwrap_impl(timeout), type: unwrap_impl(type)))
|
367
384
|
end
|
368
385
|
|
386
|
+
#
|
369
387
|
# This method waits for [actionability](../actionability.md) checks, then tries to scroll element into view, unless it is
|
370
388
|
# completely visible as defined by
|
371
389
|
# [IntersectionObserver](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API)'s `ratio`.
|
@@ -376,17 +394,17 @@ module Playwright
|
|
376
394
|
wrap_impl(@impl.scroll_into_view_if_needed(timeout: unwrap_impl(timeout)))
|
377
395
|
end
|
378
396
|
|
379
|
-
# This method waits for [actionability](../actionability.md) checks, waits until all specified options are present in the
|
380
|
-
# `<select>` element and selects these options.
|
381
397
|
#
|
382
|
-
#
|
383
|
-
#
|
384
|
-
# [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used instead.
|
398
|
+
# This method waits for [actionability](../actionability.md) checks, waits until all specified options are present in the `<select>` element and selects these options.
|
399
|
+
#
|
400
|
+
# If the target element is not a `<select>` element, this method throws an error. However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used instead.
|
385
401
|
#
|
386
402
|
# Returns the array of option values that have been successfully selected.
|
387
403
|
#
|
388
404
|
# Triggers a `change` and `input` event once all the provided options have been selected.
|
389
405
|
#
|
406
|
+
# **Usage**
|
407
|
+
#
|
390
408
|
# ```python sync
|
391
409
|
# # single selection matching the value
|
392
410
|
# handle.select_option("blue")
|
@@ -406,28 +424,27 @@ module Playwright
|
|
406
424
|
wrap_impl(@impl.select_option(element: unwrap_impl(element), index: unwrap_impl(index), value: unwrap_impl(value), label: unwrap_impl(label), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
407
425
|
end
|
408
426
|
|
427
|
+
#
|
409
428
|
# This method waits for [actionability](../actionability.md) checks, then focuses the element and selects all its text
|
410
429
|
# content.
|
411
430
|
#
|
412
|
-
# If the element is inside the `<label>` element that has an associated
|
413
|
-
# [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), focuses and selects text in the
|
414
|
-
# control instead.
|
431
|
+
# If the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), focuses and selects text in the control instead.
|
415
432
|
def select_text(force: nil, timeout: nil)
|
416
433
|
wrap_impl(@impl.select_text(force: unwrap_impl(force), timeout: unwrap_impl(timeout)))
|
417
434
|
end
|
418
435
|
|
436
|
+
#
|
419
437
|
# This method checks or unchecks an element by performing the following steps:
|
420
438
|
# 1. Ensure that element is a checkbox or a radio input. If not, this method throws.
|
421
439
|
# 1. If the element already has the right checked state, this method returns immediately.
|
422
|
-
# 1. Wait for [actionability](../actionability.md) checks on the matched element, unless `force` option is set. If the
|
423
|
-
# element is detached during the checks, the whole action is retried.
|
440
|
+
# 1. Wait for [actionability](../actionability.md) checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
|
424
441
|
# 1. Scroll the element into view if needed.
|
425
442
|
# 1. Use [`property: Page.mouse`] to click in the center of the element.
|
426
443
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
427
444
|
# 1. Ensure that the element is now checked or unchecked. If not, this method throws.
|
428
445
|
#
|
429
|
-
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
430
|
-
# zero timeout disables this.
|
446
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
447
|
+
# `TimeoutError`. Passing zero timeout disables this.
|
431
448
|
def set_checked(
|
432
449
|
checked,
|
433
450
|
force: nil,
|
@@ -439,18 +456,18 @@ module Playwright
|
|
439
456
|
end
|
440
457
|
alias_method :checked=, :set_checked
|
441
458
|
|
459
|
+
#
|
442
460
|
# Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
|
443
461
|
# are resolved relative to the current working directory. For empty array, clears the selected files.
|
444
462
|
#
|
445
463
|
# This method expects `ElementHandle` to point to an
|
446
|
-
# [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). However, if the element is inside the
|
447
|
-
# `<label>` element that has an associated
|
448
|
-
# [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), targets the control instead.
|
464
|
+
# [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), targets the control instead.
|
449
465
|
def set_input_files(files, noWaitAfter: nil, timeout: nil)
|
450
466
|
wrap_impl(@impl.set_input_files(unwrap_impl(files), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
451
467
|
end
|
452
468
|
alias_method :input_files=, :set_input_files
|
453
469
|
|
470
|
+
#
|
454
471
|
# This method taps the element by performing the following steps:
|
455
472
|
# 1. Wait for [actionability](../actionability.md) checks on the element, unless `force` option is set.
|
456
473
|
# 1. Scroll the element into view if needed.
|
@@ -459,10 +476,10 @@ module Playwright
|
|
459
476
|
#
|
460
477
|
# If the element is detached from the DOM at any moment during the action, this method throws.
|
461
478
|
#
|
462
|
-
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
463
|
-
# zero timeout disables this.
|
479
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
480
|
+
# `TimeoutError`. Passing zero timeout disables this.
|
464
481
|
#
|
465
|
-
#
|
482
|
+
# **NOTE**: `elementHandle.tap()` requires that the `hasTouch` option of the browser context be set to true.
|
466
483
|
def tap_point(
|
467
484
|
force: nil,
|
468
485
|
modifiers: nil,
|
@@ -473,15 +490,19 @@ module Playwright
|
|
473
490
|
wrap_impl(@impl.tap_point(force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
474
491
|
end
|
475
492
|
|
493
|
+
#
|
476
494
|
# Returns the `node.textContent`.
|
477
495
|
def text_content
|
478
496
|
wrap_impl(@impl.text_content)
|
479
497
|
end
|
480
498
|
|
499
|
+
#
|
481
500
|
# Focuses the element, and then sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
|
482
501
|
#
|
483
502
|
# To press a special key, like `Control` or `ArrowDown`, use [`method: ElementHandle.press`].
|
484
503
|
#
|
504
|
+
# **Usage**
|
505
|
+
#
|
485
506
|
# ```python sync
|
486
507
|
# element_handle.type("hello") # types instantly
|
487
508
|
# element_handle.type("world", delay=100) # types slower, like a user
|
@@ -498,9 +519,9 @@ module Playwright
|
|
498
519
|
wrap_impl(@impl.type(unwrap_impl(text), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
499
520
|
end
|
500
521
|
|
522
|
+
#
|
501
523
|
# This method checks the element by performing the following steps:
|
502
|
-
# 1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already
|
503
|
-
# unchecked, this method returns immediately.
|
524
|
+
# 1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already unchecked, this method returns immediately.
|
504
525
|
# 1. Wait for [actionability](../actionability.md) checks on the element, unless `force` option is set.
|
505
526
|
# 1. Scroll the element into view if needed.
|
506
527
|
# 1. Use [`property: Page.mouse`] to click in the center of the element.
|
@@ -509,8 +530,8 @@ module Playwright
|
|
509
530
|
#
|
510
531
|
# If the element is detached from the DOM at any moment during the action, this method throws.
|
511
532
|
#
|
512
|
-
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
513
|
-
# zero timeout disables this.
|
533
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
534
|
+
# `TimeoutError`. Passing zero timeout disables this.
|
514
535
|
def uncheck(
|
515
536
|
force: nil,
|
516
537
|
noWaitAfter: nil,
|
@@ -520,15 +541,14 @@ module Playwright
|
|
520
541
|
wrap_impl(@impl.uncheck(force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
521
542
|
end
|
522
543
|
|
544
|
+
#
|
523
545
|
# Returns when the element satisfies the `state`.
|
524
546
|
#
|
525
|
-
# Depending on the `state` parameter, this method waits for one of the [actionability](../actionability.md) checks
|
526
|
-
# pass. This method throws when the element is detached while waiting, unless waiting for the `"hidden"` state.
|
547
|
+
# Depending on the `state` parameter, this method waits for one of the [actionability](../actionability.md) checks
|
548
|
+
# to pass. This method throws when the element is detached while waiting, unless waiting for the `"hidden"` state.
|
527
549
|
# - `"visible"` Wait until the element is [visible](../actionability.md#visible).
|
528
|
-
# - `"hidden"` Wait until the element is [not visible](../actionability.md#visible) or
|
529
|
-
#
|
530
|
-
# - `"stable"` Wait until the element is both [visible](../actionability.md#visible) and
|
531
|
-
# [stable](../actionability.md#stable).
|
550
|
+
# - `"hidden"` Wait until the element is [not visible](../actionability.md#visible) or [not attached](../actionability.md#attached). Note that waiting for hidden does not throw when the element detaches.
|
551
|
+
# - `"stable"` Wait until the element is both [visible](../actionability.md#visible) and [stable](../actionability.md#stable).
|
532
552
|
# - `"enabled"` Wait until the element is [enabled](../actionability.md#enabled).
|
533
553
|
# - `"disabled"` Wait until the element is [not enabled](../actionability.md#enabled).
|
534
554
|
# - `"editable"` Wait until the element is [editable](../actionability.md#editable).
|
@@ -538,13 +558,16 @@ module Playwright
|
|
538
558
|
wrap_impl(@impl.wait_for_element_state(unwrap_impl(state), timeout: unwrap_impl(timeout)))
|
539
559
|
end
|
540
560
|
|
541
|
-
# Returns element specified by selector when it satisfies `state` option. Returns `null` if waiting for `hidden` or
|
542
|
-
# `detached`.
|
543
561
|
#
|
544
|
-
#
|
545
|
-
#
|
546
|
-
#
|
547
|
-
#
|
562
|
+
# Returns element specified by selector when it satisfies `state` option. Returns `null` if waiting for `hidden`
|
563
|
+
# or `detached`.
|
564
|
+
#
|
565
|
+
# Wait for the `selector` relative to the element handle to satisfy `state` option (either
|
566
|
+
# appear/disappear from dom, or become visible/hidden). If at the moment of calling the method `selector` already
|
567
|
+
# satisfies the condition, the method will return immediately. If the selector doesn't satisfy the condition for the
|
568
|
+
# `timeout` milliseconds, the function will throw.
|
569
|
+
#
|
570
|
+
# **Usage**
|
548
571
|
#
|
549
572
|
# ```python sync
|
550
573
|
# page.set_content("<div><span></span></div>")
|
@@ -553,7 +576,7 @@ module Playwright
|
|
553
576
|
# span = div.wait_for_selector("span", state="attached")
|
554
577
|
# ```
|
555
578
|
#
|
556
|
-
#
|
579
|
+
# **NOTE**: This method does not work across navigations, use [`method: Page.waitForSelector`] instead.
|
557
580
|
def wait_for_selector(selector, state: nil, strict: nil, timeout: nil)
|
558
581
|
wrap_impl(@impl.wait_for_selector(unwrap_impl(selector), state: unwrap_impl(state), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
559
582
|
end
|
@@ -1,29 +1,34 @@
|
|
1
1
|
module Playwright
|
2
|
+
#
|
2
3
|
# `FileChooser` objects are dispatched by the page in the [`event: Page.fileChooser`] event.
|
3
4
|
#
|
4
5
|
# ```python sync
|
5
6
|
# with page.expect_file_chooser() as fc_info:
|
6
|
-
# page.get_by_text("Upload").click()
|
7
|
+
# page.get_by_text("Upload file").click()
|
7
8
|
# file_chooser = fc_info.value
|
8
9
|
# file_chooser.set_files("myfile.pdf")
|
9
10
|
# ```
|
10
11
|
class FileChooser < PlaywrightApi
|
11
12
|
|
13
|
+
#
|
12
14
|
# Returns input element associated with this file chooser.
|
13
15
|
def element
|
14
16
|
wrap_impl(@impl.element)
|
15
17
|
end
|
16
18
|
|
19
|
+
#
|
17
20
|
# Returns whether this file chooser accepts multiple files.
|
18
21
|
def multiple?
|
19
22
|
wrap_impl(@impl.multiple?)
|
20
23
|
end
|
21
24
|
|
25
|
+
#
|
22
26
|
# Returns page this file chooser belongs to.
|
23
27
|
def page
|
24
28
|
wrap_impl(@impl.page)
|
25
29
|
end
|
26
30
|
|
31
|
+
#
|
27
32
|
# Sets the value of the file input this chooser is associated with. If some of the `filePaths` are relative paths, then
|
28
33
|
# they are resolved relative to the current working directory. For empty array, clears the selected files.
|
29
34
|
def set_files(files, noWaitAfter: nil, timeout: nil)
|