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
data/lib/playwright_api/frame.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
module Playwright
|
2
|
+
#
|
2
3
|
# At every point of time, page exposes its current frame tree via the [`method: Page.mainFrame`] and
|
3
4
|
# [`method: Frame.childFrames`] methods.
|
4
5
|
#
|
5
6
|
# `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.
|
7
|
+
# - [`event: Page.frameAttached`] - fired when the frame gets attached to the page. A Frame can be attached to the page only once.
|
8
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.
|
9
|
+
# - [`event: Page.frameDetached`] - fired when the frame gets detached from the page. A Frame can be detached from the page only once.
|
11
10
|
#
|
12
11
|
# An example of dumping frame tree:
|
13
12
|
#
|
@@ -32,6 +31,7 @@ module Playwright
|
|
32
31
|
# ```
|
33
32
|
class Frame < PlaywrightApi
|
34
33
|
|
34
|
+
#
|
35
35
|
# Returns the added tag when the script's onload fires or when the script content was injected into frame.
|
36
36
|
#
|
37
37
|
# Adds a `<script>` tag into the page with the desired url or content.
|
@@ -39,6 +39,7 @@ module Playwright
|
|
39
39
|
wrap_impl(@impl.add_script_tag(content: unwrap_impl(content), path: unwrap_impl(path), type: unwrap_impl(type), url: unwrap_impl(url)))
|
40
40
|
end
|
41
41
|
|
42
|
+
#
|
42
43
|
# Returns the added tag when the stylesheet's onload fires or when the CSS content was injected into frame.
|
43
44
|
#
|
44
45
|
# Adds a `<link rel="stylesheet">` tag into the page with the desired url or a `<style type="text/css">` tag with the
|
@@ -47,19 +48,18 @@ module Playwright
|
|
47
48
|
wrap_impl(@impl.add_style_tag(content: unwrap_impl(content), path: unwrap_impl(path), url: unwrap_impl(url)))
|
48
49
|
end
|
49
50
|
|
51
|
+
#
|
50
52
|
# This method checks an element matching `selector` by performing the following steps:
|
51
53
|
# 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
52
|
-
# 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws. If the element is already
|
53
|
-
#
|
54
|
-
# 1. Wait for [actionability](../actionability.md) checks on the matched element, unless `force` option is set. If the
|
55
|
-
# element is detached during the checks, the whole action is retried.
|
54
|
+
# 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws. If the element is already checked, this method returns immediately.
|
55
|
+
# 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.
|
56
56
|
# 1. Scroll the element into view if needed.
|
57
57
|
# 1. Use [`property: Page.mouse`] to click in the center of the element.
|
58
58
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
59
59
|
# 1. Ensure that the element is now checked. If not, this method throws.
|
60
60
|
#
|
61
|
-
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
62
|
-
# zero timeout disables this.
|
61
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
62
|
+
# `TimeoutError`. Passing zero timeout disables this.
|
63
63
|
def check(
|
64
64
|
selector,
|
65
65
|
force: nil,
|
@@ -75,16 +75,16 @@ module Playwright
|
|
75
75
|
wrap_impl(@impl.child_frames)
|
76
76
|
end
|
77
77
|
|
78
|
+
#
|
78
79
|
# This method clicks an element matching `selector` by performing the following steps:
|
79
80
|
# 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
80
|
-
# 1. Wait for [actionability](../actionability.md) checks on the matched element, unless `force` option is set. If the
|
81
|
-
# element is detached during the checks, the whole action is retried.
|
81
|
+
# 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.
|
82
82
|
# 1. Scroll the element into view if needed.
|
83
83
|
# 1. Use [`property: Page.mouse`] to click in the center of the element, or the specified `position`.
|
84
84
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
85
85
|
#
|
86
|
-
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
87
|
-
# zero timeout disables this.
|
86
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
87
|
+
# `TimeoutError`. Passing zero timeout disables this.
|
88
88
|
def click(
|
89
89
|
selector,
|
90
90
|
button: nil,
|
@@ -100,24 +100,24 @@ module Playwright
|
|
100
100
|
wrap_impl(@impl.click(unwrap_impl(selector), button: unwrap_impl(button), clickCount: unwrap_impl(clickCount), delay: unwrap_impl(delay), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
101
101
|
end
|
102
102
|
|
103
|
+
#
|
103
104
|
# Gets the full HTML contents of the frame, including the doctype.
|
104
105
|
def content
|
105
106
|
wrap_impl(@impl.content)
|
106
107
|
end
|
107
108
|
|
109
|
+
#
|
108
110
|
# This method double clicks an element matching `selector` by performing the following steps:
|
109
111
|
# 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
110
|
-
# 1. Wait for [actionability](../actionability.md) checks on the matched element, unless `force` option is set. If the
|
111
|
-
# element is detached during the checks, the whole action is retried.
|
112
|
+
# 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.
|
112
113
|
# 1. Scroll the element into view if needed.
|
113
114
|
# 1. Use [`property: Page.mouse`] to double click in the center of the element, or the specified `position`.
|
114
|
-
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the
|
115
|
-
# first click of the `dblclick()` triggers a navigation event, this method will throw.
|
115
|
+
# 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.
|
116
116
|
#
|
117
|
-
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
118
|
-
# zero timeout disables this.
|
117
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
118
|
+
# `TimeoutError`. Passing zero timeout disables this.
|
119
119
|
#
|
120
|
-
#
|
120
|
+
# **NOTE**: `frame.dblclick()` dispatches two `click` events and a single `dblclick` event.
|
121
121
|
def dblclick(
|
122
122
|
selector,
|
123
123
|
button: nil,
|
@@ -132,18 +132,23 @@ module Playwright
|
|
132
132
|
wrap_impl(@impl.dblclick(unwrap_impl(selector), button: unwrap_impl(button), delay: unwrap_impl(delay), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
133
133
|
end
|
134
134
|
|
135
|
-
#
|
136
|
-
# `click`
|
135
|
+
#
|
136
|
+
# The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element, `click`
|
137
|
+
# is dispatched. This is equivalent to calling
|
137
138
|
# [element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
|
138
139
|
#
|
140
|
+
# **Usage**
|
141
|
+
#
|
139
142
|
# ```python sync
|
140
143
|
# frame.dispatch_event("button#submit", "click")
|
141
144
|
# ```
|
142
145
|
#
|
143
|
-
# Under the hood, it creates an instance of an event based on the given `type`, initializes it with
|
144
|
-
# and dispatches it on the element. Events are `composed`, `cancelable` and bubble by
|
146
|
+
# Under the hood, it creates an instance of an event based on the given `type`, initializes it with
|
147
|
+
# `eventInit` properties and dispatches it on the element. Events are `composed`, `cancelable` and bubble by
|
148
|
+
# default.
|
145
149
|
#
|
146
|
-
# Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial
|
150
|
+
# Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial
|
151
|
+
# properties:
|
147
152
|
# - [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent)
|
148
153
|
# - [FocusEvent](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent)
|
149
154
|
# - [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent)
|
@@ -181,19 +186,17 @@ module Playwright
|
|
181
186
|
wrap_impl(@impl.drag_and_drop(unwrap_impl(source), unwrap_impl(target), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), sourcePosition: unwrap_impl(sourcePosition), strict: unwrap_impl(strict), targetPosition: unwrap_impl(targetPosition), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
182
187
|
end
|
183
188
|
|
184
|
-
# Returns the return value of `expression`.
|
185
189
|
#
|
186
|
-
#
|
187
|
-
# tests. Use [`method: Locator.evaluate`], other `Locator` helper methods or web-first assertions instead.
|
190
|
+
# Returns the return value of `expression`.
|
188
191
|
#
|
189
192
|
# The method finds an element matching the specified selector within the frame and passes it as a first argument to
|
190
|
-
# `expression`.
|
191
|
-
# method throws an error.
|
193
|
+
# `expression`. If no
|
194
|
+
# elements match the selector, the method throws an error.
|
192
195
|
#
|
193
|
-
# If `expression` returns a [Promise], then [`method: Frame.evalOnSelector`] would wait for the promise to resolve and
|
194
|
-
#
|
196
|
+
# If `expression` returns a [Promise], then [`method: Frame.evalOnSelector`] would wait for the promise to resolve and return its
|
197
|
+
# value.
|
195
198
|
#
|
196
|
-
#
|
199
|
+
# **Usage**
|
197
200
|
#
|
198
201
|
# ```python sync
|
199
202
|
# search_value = frame.eval_on_selector("#search", "el => el.value")
|
@@ -204,18 +207,16 @@ module Playwright
|
|
204
207
|
wrap_impl(@impl.eval_on_selector(unwrap_impl(selector), unwrap_impl(expression), arg: unwrap_impl(arg), strict: unwrap_impl(strict)))
|
205
208
|
end
|
206
209
|
|
207
|
-
# Returns the return value of `expression`.
|
208
210
|
#
|
209
|
-
#
|
210
|
-
# better job.
|
211
|
+
# Returns the return value of `expression`.
|
211
212
|
#
|
212
213
|
# The method finds all elements matching the specified selector within the frame and passes an array of matched elements
|
213
|
-
# as a first argument to `expression`.
|
214
|
+
# as a first argument to `expression`.
|
214
215
|
#
|
215
|
-
# If `expression` returns a [Promise], then [`method: Frame.evalOnSelectorAll`] would wait for the promise to resolve and
|
216
|
-
#
|
216
|
+
# If `expression` returns a [Promise], then [`method: Frame.evalOnSelectorAll`] would wait for the promise to resolve and return its
|
217
|
+
# value.
|
217
218
|
#
|
218
|
-
#
|
219
|
+
# **Usage**
|
219
220
|
#
|
220
221
|
# ```python sync
|
221
222
|
# divs_counts = frame.eval_on_selector_all("div", "(divs, min) => divs.length >= min", 10)
|
@@ -224,14 +225,17 @@ module Playwright
|
|
224
225
|
wrap_impl(@impl.eval_on_selector_all(unwrap_impl(selector), unwrap_impl(expression), arg: unwrap_impl(arg)))
|
225
226
|
end
|
226
227
|
|
228
|
+
#
|
227
229
|
# Returns the return value of `expression`.
|
228
230
|
#
|
229
|
-
# If the function passed to the [`method: Frame.evaluate`] returns a [Promise], then [`method: Frame.evaluate`] would wait
|
230
|
-
#
|
231
|
+
# If the function passed to the [`method: Frame.evaluate`] returns a [Promise], then [`method: Frame.evaluate`] would wait for the promise to
|
232
|
+
# resolve and return its value.
|
231
233
|
#
|
232
234
|
# If the function passed to the [`method: Frame.evaluate`] returns a non-[Serializable] value, then
|
233
|
-
# [`method: Frame.evaluate`] returns `undefined`. Playwright also supports transferring some
|
234
|
-
# not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`.
|
235
|
+
# [`method: Frame.evaluate`] returns `undefined`. Playwright also supports transferring some
|
236
|
+
# additional values that are not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`.
|
237
|
+
#
|
238
|
+
# **Usage**
|
235
239
|
#
|
236
240
|
# ```python sync
|
237
241
|
# result = frame.evaluate("([x, y]) => Promise.resolve(x * y)", [7, 8])
|
@@ -257,6 +261,7 @@ module Playwright
|
|
257
261
|
wrap_impl(@impl.evaluate(unwrap_impl(expression), arg: unwrap_impl(arg)))
|
258
262
|
end
|
259
263
|
|
264
|
+
#
|
260
265
|
# Returns the return value of `expression` as a `JSHandle`.
|
261
266
|
#
|
262
267
|
# The only difference between [`method: Frame.evaluate`] and [`method: Frame.evaluateHandle`] is that
|
@@ -265,6 +270,8 @@ module Playwright
|
|
265
270
|
# If the function, passed to the [`method: Frame.evaluateHandle`], returns a [Promise], then
|
266
271
|
# [`method: Frame.evaluateHandle`] would wait for the promise to resolve and return its value.
|
267
272
|
#
|
273
|
+
# **Usage**
|
274
|
+
#
|
268
275
|
# ```python sync
|
269
276
|
# a_window_handle = frame.evaluate_handle("Promise.resolve(window)")
|
270
277
|
# a_window_handle # handle for the window object.
|
@@ -288,14 +295,10 @@ module Playwright
|
|
288
295
|
wrap_impl(@impl.evaluate_handle(unwrap_impl(expression), arg: unwrap_impl(arg)))
|
289
296
|
end
|
290
297
|
|
291
|
-
# This method waits for an element matching `selector`, waits for [actionability](../actionability.md) checks, focuses the
|
292
|
-
# element, fills it and triggers an `input` event after filling. Note that you can pass an empty string to clear the input
|
293
|
-
# field.
|
294
298
|
#
|
295
|
-
#
|
296
|
-
#
|
297
|
-
# [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled
|
298
|
-
# instead.
|
299
|
+
# This method waits for an element matching `selector`, 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.
|
300
|
+
#
|
301
|
+
# 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.
|
299
302
|
#
|
300
303
|
# To send fine-grained keyboard events, use [`method: Frame.type`].
|
301
304
|
def fill(
|
@@ -308,12 +311,14 @@ module Playwright
|
|
308
311
|
wrap_impl(@impl.fill(unwrap_impl(selector), unwrap_impl(value), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
309
312
|
end
|
310
313
|
|
311
|
-
#
|
312
|
-
#
|
314
|
+
#
|
315
|
+
# This method fetches an element with `selector` and focuses it. If there's no element matching
|
316
|
+
# `selector`, the method waits until a matching element appears in the DOM.
|
313
317
|
def focus(selector, strict: nil, timeout: nil)
|
314
318
|
wrap_impl(@impl.focus(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
315
319
|
end
|
316
320
|
|
321
|
+
#
|
317
322
|
# Returns the `frame` or `iframe` element handle which corresponds to this frame.
|
318
323
|
#
|
319
324
|
# This is an inverse of [`method: ElementHandle.contentFrame`]. Note that returned handle actually belongs to the parent
|
@@ -321,6 +326,8 @@ module Playwright
|
|
321
326
|
#
|
322
327
|
# This method throws an error if the frame has been detached before `frameElement()` returns.
|
323
328
|
#
|
329
|
+
# **Usage**
|
330
|
+
#
|
324
331
|
# ```python sync
|
325
332
|
# frame_element = frame.frame_element()
|
326
333
|
# content_frame = frame_element.content_frame()
|
@@ -330,9 +337,13 @@ module Playwright
|
|
330
337
|
wrap_impl(@impl.frame_element)
|
331
338
|
end
|
332
339
|
|
333
|
-
#
|
334
|
-
#
|
335
|
-
#
|
340
|
+
#
|
341
|
+
# When working with iframes, you can create a frame locator that will enter the iframe and allow selecting elements
|
342
|
+
# in that iframe.
|
343
|
+
#
|
344
|
+
# **Usage**
|
345
|
+
#
|
346
|
+
# Following snippet locates element with text "Submit" in the iframe with id `my-frame`, like `<iframe id="my-frame">`:
|
336
347
|
#
|
337
348
|
# ```python sync
|
338
349
|
# locator = frame.frame_locator("#my-iframe").get_by_text("Submit")
|
@@ -342,11 +353,13 @@ module Playwright
|
|
342
353
|
wrap_impl(@impl.frame_locator(unwrap_impl(selector)))
|
343
354
|
end
|
344
355
|
|
356
|
+
#
|
345
357
|
# Returns element attribute value.
|
346
358
|
def get_attribute(selector, name, strict: nil, timeout: nil)
|
347
359
|
wrap_impl(@impl.get_attribute(unwrap_impl(selector), unwrap_impl(name), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
348
360
|
end
|
349
361
|
|
362
|
+
#
|
350
363
|
# Allows locating elements by their alt text. For example, this method will find the image by alt text "Castle":
|
351
364
|
#
|
352
365
|
# ```html
|
@@ -356,8 +369,8 @@ module Playwright
|
|
356
369
|
wrap_impl(@impl.get_by_alt_text(unwrap_impl(text), exact: unwrap_impl(exact)))
|
357
370
|
end
|
358
371
|
|
359
|
-
#
|
360
|
-
# label text "Password" in the following DOM:
|
372
|
+
#
|
373
|
+
# Allows locating input elements by the text of the associated label. For example, this method will find the input by label text "Password" in the following DOM:
|
361
374
|
#
|
362
375
|
# ```html
|
363
376
|
# <label for="password-input">Password:</label>
|
@@ -367,8 +380,8 @@ module Playwright
|
|
367
380
|
wrap_impl(@impl.get_by_label(unwrap_impl(text), exact: unwrap_impl(exact)))
|
368
381
|
end
|
369
382
|
|
370
|
-
#
|
371
|
-
# "Country":
|
383
|
+
#
|
384
|
+
# Allows locating input elements by the placeholder text. For example, this method will find the input by placeholder "Country":
|
372
385
|
#
|
373
386
|
# ```html
|
374
387
|
# <input placeholder="Country">
|
@@ -377,15 +390,10 @@ module Playwright
|
|
377
390
|
wrap_impl(@impl.get_by_placeholder(unwrap_impl(text), exact: unwrap_impl(exact)))
|
378
391
|
end
|
379
392
|
|
380
|
-
# Allows locating elements by their [ARIA role](https://www.w3.org/TR/wai-aria-1.2/#roles),
|
381
|
-
# [ARIA attributes](https://www.w3.org/TR/wai-aria-1.2/#aria-attributes) and
|
382
|
-
# [accessible name](https://w3c.github.io/accname/#dfn-accessible-name). Note that role selector **does not replace**
|
383
|
-
# accessibility audits and conformance tests, but rather gives early feedback about the ARIA guidelines.
|
384
393
|
#
|
385
|
-
# Note that
|
386
|
-
#
|
387
|
-
# can find all the [supported roles here](https://www.w3.org/TR/wai-aria-1.2/#role_definitions). ARIA guidelines **do not
|
388
|
-
# recommend** duplicating implicit roles and attributes by setting `role` and/or `aria-*` attributes to default values.
|
394
|
+
# Allows locating elements by their [ARIA role](https://www.w3.org/TR/wai-aria-1.2/#roles), [ARIA attributes](https://www.w3.org/TR/wai-aria-1.2/#aria-attributes) and [accessible name](https://w3c.github.io/accname/#dfn-accessible-name). Note that role selector **does not replace** accessibility audits and conformance tests, but rather gives early feedback about the ARIA guidelines.
|
395
|
+
#
|
396
|
+
# Note that many html elements have an implicitly [defined role](https://w3c.github.io/html-aam/#html-element-role-mappings) that is recognized by the role selector. You can find all the [supported roles here](https://www.w3.org/TR/wai-aria-1.2/#role_definitions). ARIA guidelines **do not recommend** duplicating implicit roles and attributes by setting `role` and/or `aria-*` attributes to default values.
|
389
397
|
def get_by_role(
|
390
398
|
role,
|
391
399
|
checked: nil,
|
@@ -400,12 +408,13 @@ module Playwright
|
|
400
408
|
wrap_impl(@impl.get_by_role(unwrap_impl(role), checked: unwrap_impl(checked), disabled: unwrap_impl(disabled), exact: unwrap_impl(exact), expanded: unwrap_impl(expanded), includeHidden: unwrap_impl(includeHidden), level: unwrap_impl(level), name: unwrap_impl(name), pressed: unwrap_impl(pressed), selected: unwrap_impl(selected)))
|
401
409
|
end
|
402
410
|
|
403
|
-
#
|
404
|
-
# [`method: Selectors.setTestIdAttribute`] to configure a different test id attribute if necessary.
|
411
|
+
#
|
412
|
+
# Locate element by the test id. By default, the `data-testid` attribute is used as a test id. Use [`method: Selectors.setTestIdAttribute`] to configure a different test id attribute if necessary.
|
405
413
|
def get_by_test_id(testId)
|
406
414
|
wrap_impl(@impl.get_by_test_id(unwrap_impl(testId)))
|
407
415
|
end
|
408
416
|
|
417
|
+
#
|
409
418
|
# Allows locating elements that contain given text. Consider the following DOM structure:
|
410
419
|
#
|
411
420
|
# ```html
|
@@ -432,17 +441,16 @@ module Playwright
|
|
432
441
|
# page.get_by_text(re.compile("^hello$", re.IGNORECASE))
|
433
442
|
# ```
|
434
443
|
#
|
435
|
-
# See also [`method: Locator.filter`] that allows to match by another criteria, like an accessible role, and then filter
|
436
|
-
#
|
444
|
+
# See also [`method: Locator.filter`] that allows to match by another criteria, like an accessible role, and then filter by the text content.
|
445
|
+
#
|
446
|
+
# **NOTE**: Matching by text always normalizes whitespace, even with exact match. For example, it turns multiple spaces into one, turns line breaks into spaces and ignores leading and trailing whitespace.
|
437
447
|
#
|
438
|
-
#
|
439
|
-
# one, turns line breaks into spaces and ignores leading and trailing whitespace.
|
440
|
-
# > NOTE: Input elements of the type `button` and `submit` are matched by their `value` instead of the text content. For
|
441
|
-
# example, locating by text `"Log in"` matches `<input type=button value="Log in">`.
|
448
|
+
# **NOTE**: Input elements of the type `button` and `submit` are matched by their `value` instead of the text content. For example, locating by text `"Log in"` matches `<input type=button value="Log in">`.
|
442
449
|
def get_by_text(text, exact: nil)
|
443
450
|
wrap_impl(@impl.get_by_text(unwrap_impl(text), exact: unwrap_impl(exact)))
|
444
451
|
end
|
445
452
|
|
453
|
+
#
|
446
454
|
# Allows locating elements by their title. For example, this method will find the button by its title "Place the order":
|
447
455
|
#
|
448
456
|
# ```html
|
@@ -452,6 +460,7 @@ module Playwright
|
|
452
460
|
wrap_impl(@impl.get_by_title(unwrap_impl(text), exact: unwrap_impl(exact)))
|
453
461
|
end
|
454
462
|
|
463
|
+
#
|
455
464
|
# Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
|
456
465
|
# last redirect.
|
457
466
|
#
|
@@ -462,28 +471,29 @@ module Playwright
|
|
462
471
|
# - the remote server does not respond or is unreachable.
|
463
472
|
# - the main resource failed to load.
|
464
473
|
#
|
465
|
-
# The method will not throw an error when any valid HTTP status code is returned by the remote server, including 404
|
466
|
-
# Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling
|
474
|
+
# The method will not throw an error when any valid HTTP status code is returned by the remote server, including 404
|
475
|
+
# "Not Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling
|
467
476
|
# [`method: Response.status`].
|
468
477
|
#
|
469
|
-
#
|
478
|
+
# **NOTE**: The method either throws an error or returns a main resource response. The only exceptions are navigation to
|
470
479
|
# `about:blank` or navigation to the same URL with a different hash, which would succeed and return `null`.
|
471
|
-
#
|
480
|
+
#
|
481
|
+
# **NOTE**: Headless mode doesn't support navigation to a PDF document. See the
|
472
482
|
# [upstream issue](https://bugs.chromium.org/p/chromium/issues/detail?id=761295).
|
473
483
|
def goto(url, referer: nil, timeout: nil, waitUntil: nil)
|
474
484
|
wrap_impl(@impl.goto(unwrap_impl(url), referer: unwrap_impl(referer), timeout: unwrap_impl(timeout), waitUntil: unwrap_impl(waitUntil)))
|
475
485
|
end
|
476
486
|
|
487
|
+
#
|
477
488
|
# This method hovers over an element matching `selector` by performing the following steps:
|
478
489
|
# 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
479
|
-
# 1. Wait for [actionability](../actionability.md) checks on the matched element, unless `force` option is set. If the
|
480
|
-
# element is detached during the checks, the whole action is retried.
|
490
|
+
# 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.
|
481
491
|
# 1. Scroll the element into view if needed.
|
482
492
|
# 1. Use [`property: Page.mouse`] to hover over the center of the element, or the specified `position`.
|
483
493
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
484
494
|
#
|
485
|
-
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
486
|
-
# zero timeout disables this.
|
495
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
496
|
+
# `TimeoutError`. Passing zero timeout disables this.
|
487
497
|
def hover(
|
488
498
|
selector,
|
489
499
|
force: nil,
|
@@ -496,64 +506,71 @@ module Playwright
|
|
496
506
|
wrap_impl(@impl.hover(unwrap_impl(selector), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
497
507
|
end
|
498
508
|
|
509
|
+
#
|
499
510
|
# Returns `element.innerHTML`.
|
500
511
|
def inner_html(selector, strict: nil, timeout: nil)
|
501
512
|
wrap_impl(@impl.inner_html(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
502
513
|
end
|
503
514
|
|
515
|
+
#
|
504
516
|
# Returns `element.innerText`.
|
505
517
|
def inner_text(selector, strict: nil, timeout: nil)
|
506
518
|
wrap_impl(@impl.inner_text(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
507
519
|
end
|
508
520
|
|
521
|
+
#
|
509
522
|
# Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element.
|
510
523
|
#
|
511
|
-
# Throws for non-input elements. However, if the element is inside the `<label>` element that has an associated
|
512
|
-
# [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), returns the value of the control.
|
524
|
+
# 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.
|
513
525
|
def input_value(selector, strict: nil, timeout: nil)
|
514
526
|
wrap_impl(@impl.input_value(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
515
527
|
end
|
516
528
|
|
529
|
+
#
|
517
530
|
# Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
|
518
531
|
def checked?(selector, strict: nil, timeout: nil)
|
519
532
|
wrap_impl(@impl.checked?(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
520
533
|
end
|
521
534
|
|
535
|
+
#
|
522
536
|
# Returns `true` if the frame has been detached, or `false` otherwise.
|
523
537
|
def detached?
|
524
538
|
wrap_impl(@impl.detached?)
|
525
539
|
end
|
526
540
|
|
541
|
+
#
|
527
542
|
# Returns whether the element is disabled, the opposite of [enabled](../actionability.md#enabled).
|
528
543
|
def disabled?(selector, strict: nil, timeout: nil)
|
529
544
|
wrap_impl(@impl.disabled?(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
530
545
|
end
|
531
546
|
|
547
|
+
#
|
532
548
|
# Returns whether the element is [editable](../actionability.md#editable).
|
533
549
|
def editable?(selector, strict: nil, timeout: nil)
|
534
550
|
wrap_impl(@impl.editable?(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
535
551
|
end
|
536
552
|
|
553
|
+
#
|
537
554
|
# Returns whether the element is [enabled](../actionability.md#enabled).
|
538
555
|
def enabled?(selector, strict: nil, timeout: nil)
|
539
556
|
wrap_impl(@impl.enabled?(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
540
557
|
end
|
541
558
|
|
542
|
-
#
|
543
|
-
# match any elements is considered hidden.
|
559
|
+
#
|
560
|
+
# Returns whether the element is hidden, the opposite of [visible](../actionability.md#visible). `selector` that does not match any elements is considered hidden.
|
544
561
|
def hidden?(selector, strict: nil, timeout: nil)
|
545
562
|
wrap_impl(@impl.hidden?(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
546
563
|
end
|
547
564
|
|
548
|
-
#
|
549
|
-
# considered not visible.
|
565
|
+
#
|
566
|
+
# Returns whether the element is [visible](../actionability.md#visible). `selector` that does not match any elements is considered not visible.
|
550
567
|
def visible?(selector, strict: nil, timeout: nil)
|
551
568
|
wrap_impl(@impl.visible?(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
552
569
|
end
|
553
570
|
|
554
|
-
#
|
555
|
-
#
|
556
|
-
# on different DOM elements. That would happen if the DOM structure between those actions has changed.
|
571
|
+
#
|
572
|
+
# The method returns an element locator that can be used to perform actions on this page / frame.
|
573
|
+
# Locator is resolved to the element immediately before performing an action, so a series of actions on the same locator can in fact be performed on different DOM elements. That would happen if the DOM structure between those actions has changed.
|
557
574
|
#
|
558
575
|
# [Learn more about locators](../locators.md).
|
559
576
|
#
|
@@ -562,27 +579,32 @@ module Playwright
|
|
562
579
|
wrap_impl(@impl.locator(unwrap_impl(selector), has: unwrap_impl(has), hasText: unwrap_impl(hasText)))
|
563
580
|
end
|
564
581
|
|
582
|
+
#
|
565
583
|
# Returns frame's name attribute as specified in the tag.
|
566
584
|
#
|
567
585
|
# If the name is empty, returns the id attribute instead.
|
568
586
|
#
|
569
|
-
#
|
587
|
+
# **NOTE**: This value is calculated once when the frame is created, and will not update if the attribute is changed later.
|
570
588
|
def name
|
571
589
|
wrap_impl(@impl.name)
|
572
590
|
end
|
573
591
|
|
592
|
+
#
|
574
593
|
# Returns the page containing this frame.
|
575
594
|
def page
|
576
595
|
wrap_impl(@impl.page)
|
577
596
|
end
|
578
597
|
|
598
|
+
#
|
579
599
|
# Parent frame, if any. Detached frames and main frames return `null`.
|
580
600
|
def parent_frame
|
581
601
|
wrap_impl(@impl.parent_frame)
|
582
602
|
end
|
583
603
|
|
584
|
-
#
|
585
|
-
#
|
604
|
+
#
|
605
|
+
# `key` can specify the intended
|
606
|
+
# [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to
|
607
|
+
# generate the text for. A superset of the `key` values can be found
|
586
608
|
# [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
|
587
609
|
#
|
588
610
|
# `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
|
@@ -592,8 +614,8 @@ module Playwright
|
|
592
614
|
#
|
593
615
|
# Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
|
594
616
|
#
|
595
|
-
# If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different
|
596
|
-
# texts.
|
617
|
+
# If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different
|
618
|
+
# respective texts.
|
597
619
|
#
|
598
620
|
# Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
|
599
621
|
# modifier, modifier is pressed and being held while the subsequent key is being pressed.
|
@@ -607,37 +629,39 @@ module Playwright
|
|
607
629
|
wrap_impl(@impl.press(unwrap_impl(selector), unwrap_impl(key), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
608
630
|
end
|
609
631
|
|
632
|
+
#
|
610
633
|
# Returns the ElementHandle pointing to the frame element.
|
611
634
|
#
|
612
|
-
#
|
635
|
+
# **NOTE**: The use of `ElementHandle` is discouraged, use `Locator` objects and web-first assertions instead.
|
613
636
|
#
|
614
|
-
# The method finds an element matching the specified selector within the frame.
|
615
|
-
#
|
637
|
+
# The method finds an element matching the specified selector within the frame. If no elements match the selector,
|
638
|
+
# returns `null`.
|
616
639
|
def query_selector(selector, strict: nil)
|
617
640
|
wrap_impl(@impl.query_selector(unwrap_impl(selector), strict: unwrap_impl(strict)))
|
618
641
|
end
|
619
642
|
|
643
|
+
#
|
620
644
|
# Returns the ElementHandles pointing to the frame elements.
|
621
645
|
#
|
622
|
-
#
|
646
|
+
# **NOTE**: The use of `ElementHandle` is discouraged, use `Locator` objects instead.
|
623
647
|
#
|
624
|
-
# The method finds all elements matching the specified selector within the frame.
|
625
|
-
#
|
648
|
+
# The method finds all elements matching the specified selector within the frame. If no elements match the selector,
|
649
|
+
# returns empty array.
|
626
650
|
def query_selector_all(selector)
|
627
651
|
wrap_impl(@impl.query_selector_all(unwrap_impl(selector)))
|
628
652
|
end
|
629
653
|
|
630
|
-
# This method waits for an element matching `selector`, waits for [actionability](../actionability.md) checks, waits until
|
631
|
-
# all specified options are present in the `<select>` element and selects these options.
|
632
654
|
#
|
633
|
-
#
|
634
|
-
#
|
635
|
-
# [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used instead.
|
655
|
+
# This method waits for an element matching `selector`, waits for [actionability](../actionability.md) checks, waits until all specified options are present in the `<select>` element and selects these options.
|
656
|
+
#
|
657
|
+
# 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.
|
636
658
|
#
|
637
659
|
# Returns the array of option values that have been successfully selected.
|
638
660
|
#
|
639
661
|
# Triggers a `change` and `input` event once all the provided options have been selected.
|
640
662
|
#
|
663
|
+
# **Usage**
|
664
|
+
#
|
641
665
|
# ```python sync
|
642
666
|
# # single selection matching the value
|
643
667
|
# frame.select_option("select#colors", "blue")
|
@@ -659,19 +683,19 @@ module Playwright
|
|
659
683
|
wrap_impl(@impl.select_option(unwrap_impl(selector), element: unwrap_impl(element), index: unwrap_impl(index), value: unwrap_impl(value), label: unwrap_impl(label), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
660
684
|
end
|
661
685
|
|
686
|
+
#
|
662
687
|
# This method checks or unchecks an element matching `selector` by performing the following steps:
|
663
688
|
# 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
664
689
|
# 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws.
|
665
690
|
# 1. If the element already has the right checked state, this method returns immediately.
|
666
|
-
# 1. Wait for [actionability](../actionability.md) checks on the matched element, unless `force` option is set. If the
|
667
|
-
# element is detached during the checks, the whole action is retried.
|
691
|
+
# 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.
|
668
692
|
# 1. Scroll the element into view if needed.
|
669
693
|
# 1. Use [`property: Page.mouse`] to click in the center of the element.
|
670
694
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
671
695
|
# 1. Ensure that the element is now checked or unchecked. If not, this method throws.
|
672
696
|
#
|
673
|
-
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
674
|
-
# zero timeout disables this.
|
697
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
698
|
+
# `TimeoutError`. Passing zero timeout disables this.
|
675
699
|
def set_checked(
|
676
700
|
selector,
|
677
701
|
checked,
|
@@ -689,13 +713,12 @@ module Playwright
|
|
689
713
|
end
|
690
714
|
alias_method :content=, :set_content
|
691
715
|
|
716
|
+
#
|
692
717
|
# Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
|
693
718
|
# are resolved relative to the current working directory. For empty array, clears the selected files.
|
694
719
|
#
|
695
720
|
# This method expects `selector` to point to an
|
696
|
-
# [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). However, if the element is inside the
|
697
|
-
# `<label>` element that has an associated
|
698
|
-
# [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), targets the control instead.
|
721
|
+
# [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.
|
699
722
|
def set_input_files(
|
700
723
|
selector,
|
701
724
|
files,
|
@@ -705,18 +728,18 @@ module Playwright
|
|
705
728
|
wrap_impl(@impl.set_input_files(unwrap_impl(selector), unwrap_impl(files), noWaitAfter: unwrap_impl(noWaitAfter), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
706
729
|
end
|
707
730
|
|
731
|
+
#
|
708
732
|
# This method taps an element matching `selector` by performing the following steps:
|
709
733
|
# 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
710
|
-
# 1. Wait for [actionability](../actionability.md) checks on the matched element, unless `force` option is set. If the
|
711
|
-
# element is detached during the checks, the whole action is retried.
|
734
|
+
# 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.
|
712
735
|
# 1. Scroll the element into view if needed.
|
713
736
|
# 1. Use [`property: Page.touchscreen`] to tap the center of the element, or the specified `position`.
|
714
737
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
715
738
|
#
|
716
|
-
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
717
|
-
# zero timeout disables this.
|
739
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
740
|
+
# `TimeoutError`. Passing zero timeout disables this.
|
718
741
|
#
|
719
|
-
#
|
742
|
+
# **NOTE**: `frame.tap()` requires that the `hasTouch` option of the browser context be set to true.
|
720
743
|
def tap_point(
|
721
744
|
selector,
|
722
745
|
force: nil,
|
@@ -729,21 +752,26 @@ module Playwright
|
|
729
752
|
wrap_impl(@impl.tap_point(unwrap_impl(selector), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
730
753
|
end
|
731
754
|
|
755
|
+
#
|
732
756
|
# Returns `element.textContent`.
|
733
757
|
def text_content(selector, strict: nil, timeout: nil)
|
734
758
|
wrap_impl(@impl.text_content(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
735
759
|
end
|
736
760
|
|
761
|
+
#
|
737
762
|
# Returns the page title.
|
738
763
|
def title
|
739
764
|
wrap_impl(@impl.title)
|
740
765
|
end
|
741
766
|
|
767
|
+
#
|
742
768
|
# Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. `frame.type` can be used to
|
743
769
|
# send fine-grained keyboard events. To fill values in form fields, use [`method: Frame.fill`].
|
744
770
|
#
|
745
771
|
# To press a special key, like `Control` or `ArrowDown`, use [`method: Keyboard.press`].
|
746
772
|
#
|
773
|
+
# **Usage**
|
774
|
+
#
|
747
775
|
# ```python sync
|
748
776
|
# frame.type("#mytextarea", "hello") # types instantly
|
749
777
|
# frame.type("#mytextarea", "world", delay=100) # types slower, like a user
|
@@ -758,19 +786,18 @@ module Playwright
|
|
758
786
|
wrap_impl(@impl.type(unwrap_impl(selector), unwrap_impl(text), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
759
787
|
end
|
760
788
|
|
789
|
+
#
|
761
790
|
# This method checks an element matching `selector` by performing the following steps:
|
762
791
|
# 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
763
|
-
# 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws. If the element is already
|
764
|
-
#
|
765
|
-
# 1. Wait for [actionability](../actionability.md) checks on the matched element, unless `force` option is set. If the
|
766
|
-
# element is detached during the checks, the whole action is retried.
|
792
|
+
# 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws. If the element is already unchecked, this method returns immediately.
|
793
|
+
# 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.
|
767
794
|
# 1. Scroll the element into view if needed.
|
768
795
|
# 1. Use [`property: Page.mouse`] to click in the center of the element.
|
769
796
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
770
797
|
# 1. Ensure that the element is now unchecked. If not, this method throws.
|
771
798
|
#
|
772
|
-
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
773
|
-
# zero timeout disables this.
|
799
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
800
|
+
# `TimeoutError`. Passing zero timeout disables this.
|
774
801
|
def uncheck(
|
775
802
|
selector,
|
776
803
|
force: nil,
|
@@ -782,13 +809,17 @@ module Playwright
|
|
782
809
|
wrap_impl(@impl.uncheck(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
783
810
|
end
|
784
811
|
|
812
|
+
#
|
785
813
|
# Returns frame's url.
|
786
814
|
def url
|
787
815
|
wrap_impl(@impl.url)
|
788
816
|
end
|
789
817
|
|
818
|
+
#
|
790
819
|
# Returns when the `expression` returns a truthy value, returns that value.
|
791
820
|
#
|
821
|
+
# **Usage**
|
822
|
+
#
|
792
823
|
# The [`method: Frame.waitForFunction`] can be used to observe viewport size change:
|
793
824
|
#
|
794
825
|
# ```python sync
|
@@ -816,11 +847,14 @@ module Playwright
|
|
816
847
|
wrap_impl(@impl.wait_for_function(unwrap_impl(expression), arg: unwrap_impl(arg), polling: unwrap_impl(polling), timeout: unwrap_impl(timeout)))
|
817
848
|
end
|
818
849
|
|
850
|
+
#
|
819
851
|
# Waits for the required load state to be reached.
|
820
852
|
#
|
821
853
|
# This returns when the frame reaches a required load state, `load` by default. The navigation must have been committed
|
822
854
|
# when this method is called. If current document has already reached the required state, resolves immediately.
|
823
855
|
#
|
856
|
+
# **Usage**
|
857
|
+
#
|
824
858
|
# ```python sync
|
825
859
|
# frame.click("button") # click triggers navigation.
|
826
860
|
# frame.wait_for_load_state() # the promise resolves after "load" event.
|
@@ -829,10 +863,13 @@ module Playwright
|
|
829
863
|
wrap_impl(@impl.wait_for_load_state(state: unwrap_impl(state), timeout: unwrap_impl(timeout)))
|
830
864
|
end
|
831
865
|
|
866
|
+
#
|
832
867
|
# Waits for the frame navigation and returns the main resource response. In case of multiple redirects, the navigation
|
833
868
|
# will resolve with the response of the last redirect. In case of navigation to a different anchor or navigation due to
|
834
869
|
# History API usage, the navigation will resolve with `null`.
|
835
870
|
#
|
871
|
+
# **Usage**
|
872
|
+
#
|
836
873
|
# This method waits for the frame to navigate to a new URL. It is useful for when you run code which will indirectly cause
|
837
874
|
# the frame to navigate. Consider this example:
|
838
875
|
#
|
@@ -842,21 +879,25 @@ module Playwright
|
|
842
879
|
# # Resolves after navigation has finished
|
843
880
|
# ```
|
844
881
|
#
|
845
|
-
#
|
846
|
-
#
|
882
|
+
# **NOTE**: Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the URL is considered
|
883
|
+
# a navigation.
|
847
884
|
def expect_navigation(timeout: nil, url: nil, waitUntil: nil, &block)
|
848
885
|
wrap_impl(@impl.expect_navigation(timeout: unwrap_impl(timeout), url: unwrap_impl(url), waitUntil: unwrap_impl(waitUntil), &wrap_block_call(block)))
|
849
886
|
end
|
850
887
|
|
888
|
+
#
|
851
889
|
# Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or
|
852
890
|
# `detached`.
|
853
891
|
#
|
854
|
-
#
|
855
|
-
# web-first assertions make the code wait-for-selector-free.
|
892
|
+
# **NOTE**: Playwright automatically waits for element to be ready before performing an action. Using
|
893
|
+
# `Locator` objects and web-first assertions make the code wait-for-selector-free.
|
856
894
|
#
|
857
|
-
# Wait for the `selector` to satisfy `state` option (either appear/disappear from dom, or become
|
858
|
-
# the moment of calling the method `selector` already satisfies the condition, the method
|
859
|
-
# selector doesn't satisfy the condition for the `timeout` milliseconds, the
|
895
|
+
# Wait for the `selector` to satisfy `state` option (either appear/disappear from dom, or become
|
896
|
+
# visible/hidden). If at the moment of calling the method `selector` already satisfies the condition, the method
|
897
|
+
# will return immediately. If the selector doesn't satisfy the condition for the `timeout` milliseconds, the
|
898
|
+
# function will throw.
|
899
|
+
#
|
900
|
+
# **Usage**
|
860
901
|
#
|
861
902
|
# This method works across navigations:
|
862
903
|
#
|
@@ -880,6 +921,7 @@ module Playwright
|
|
880
921
|
wrap_impl(@impl.wait_for_selector(unwrap_impl(selector), state: unwrap_impl(state), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
881
922
|
end
|
882
923
|
|
924
|
+
#
|
883
925
|
# Waits for the given `timeout` in milliseconds.
|
884
926
|
#
|
885
927
|
# Note that `frame.waitForTimeout()` should only be used for debugging. Tests using the timer in production are going to
|
@@ -888,8 +930,11 @@ module Playwright
|
|
888
930
|
wrap_impl(@impl.wait_for_timeout(unwrap_impl(timeout)))
|
889
931
|
end
|
890
932
|
|
933
|
+
#
|
891
934
|
# Waits for the frame to navigate to the given URL.
|
892
935
|
#
|
936
|
+
# **Usage**
|
937
|
+
#
|
893
938
|
# ```python sync
|
894
939
|
# frame.click("a.delayed-navigation") # clicking the link will indirectly cause a navigation
|
895
940
|
# frame.wait_for_url("**/target.html")
|