playwright-ruby-client 0.0.8 → 1.58.1.alpha1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/AGENTS.md +4 -0
- data/CLAUDE/api_generation.md +28 -0
- data/CLAUDE/ci_expectations.md +23 -0
- data/CLAUDE/gem_release_flow.md +39 -0
- data/CLAUDE/past_upgrade_pr_patterns.md +42 -0
- data/CLAUDE/playwright_upgrade_workflow.md +35 -0
- data/CLAUDE/rspec_debugging.md +30 -0
- data/CLAUDE/unimplemented_examples.md +18 -0
- data/CLAUDE.md +32 -0
- data/CONTRIBUTING.md +5 -0
- data/README.md +60 -16
- data/documentation/README.md +33 -0
- data/documentation/babel.config.js +3 -0
- data/documentation/docs/api/api_request.md +7 -0
- data/documentation/docs/api/api_request_context.md +298 -0
- data/documentation/docs/api/api_response.md +114 -0
- data/documentation/docs/api/browser.md +237 -0
- data/documentation/docs/api/browser_context.md +503 -0
- data/documentation/docs/api/browser_type.md +184 -0
- data/documentation/docs/api/cdp_session.md +44 -0
- data/documentation/docs/api/clock.md +154 -0
- data/documentation/docs/api/console_message.md +85 -0
- data/documentation/docs/api/dialog.md +84 -0
- data/documentation/docs/api/download.md +111 -0
- data/documentation/docs/api/element_handle.md +694 -0
- data/documentation/docs/api/experimental/_category_.yml +3 -0
- data/documentation/docs/api/experimental/android.md +42 -0
- data/documentation/docs/api/experimental/android_device.md +109 -0
- data/documentation/docs/api/experimental/android_input.md +43 -0
- data/documentation/docs/api/experimental/android_socket.md +7 -0
- data/documentation/docs/api/experimental/android_web_view.md +7 -0
- data/documentation/docs/api/file_chooser.md +53 -0
- data/documentation/docs/api/frame.md +1218 -0
- data/documentation/docs/api/frame_locator.md +348 -0
- data/documentation/docs/api/js_handle.md +121 -0
- data/documentation/docs/api/keyboard.md +170 -0
- data/documentation/docs/api/locator.md +1495 -0
- data/documentation/docs/api/locator_assertions.md +827 -0
- data/documentation/docs/api/mouse.md +86 -0
- data/documentation/docs/api/page.md +1946 -0
- data/documentation/docs/api/page_assertions.md +65 -0
- data/documentation/docs/api/playwright.md +66 -0
- data/documentation/docs/api/request.md +255 -0
- data/documentation/docs/api/response.md +176 -0
- data/documentation/docs/api/route.md +205 -0
- data/documentation/docs/api/selectors.md +63 -0
- data/documentation/docs/api/touchscreen.md +22 -0
- data/documentation/docs/api/tracing.md +129 -0
- data/documentation/docs/api/web_socket.md +51 -0
- data/documentation/docs/api/worker.md +83 -0
- data/documentation/docs/article/api_coverage.mdx +11 -0
- data/documentation/docs/article/getting_started.md +161 -0
- data/documentation/docs/article/guides/_category_.yml +3 -0
- data/documentation/docs/article/guides/download_playwright_driver.md +55 -0
- data/documentation/docs/article/guides/inspector.md +31 -0
- data/documentation/docs/article/guides/launch_browser.md +121 -0
- data/documentation/docs/article/guides/playwright_on_alpine_linux.md +112 -0
- data/documentation/docs/article/guides/rails_integration.md +278 -0
- data/documentation/docs/article/guides/rails_integration_with_null_driver.md +145 -0
- data/documentation/docs/article/guides/recording_video.md +79 -0
- data/documentation/docs/article/guides/rspec_integration.md +59 -0
- data/documentation/docs/article/guides/semi_automation.md +71 -0
- data/documentation/docs/article/guides/use_storage_state.md +78 -0
- data/documentation/docs/include/api_coverage.md +671 -0
- data/documentation/docusaurus.config.js +114 -0
- data/documentation/package.json +39 -0
- data/documentation/sidebars.js +15 -0
- data/documentation/src/components/HomepageFeatures.js +61 -0
- data/documentation/src/components/HomepageFeatures.module.css +13 -0
- data/documentation/src/css/custom.css +44 -0
- data/documentation/src/pages/index.js +49 -0
- data/documentation/src/pages/index.module.css +41 -0
- data/documentation/src/pages/markdown-page.md +7 -0
- data/documentation/static/.nojekyll +0 -0
- data/documentation/static/img/playwright-logo.svg +9 -0
- data/documentation/static/img/playwright-ruby-client.png +0 -0
- data/documentation/static/img/undraw_dropdown_menu.svg +1 -0
- data/documentation/static/img/undraw_web_development.svg +1 -0
- data/documentation/static/img/undraw_windows.svg +1 -0
- data/documentation/yarn.lock +9005 -0
- data/lib/playwright/{input_types/android_input.rb → android_input_impl.rb} +5 -1
- data/lib/playwright/api_implementation.rb +18 -0
- data/lib/playwright/api_response_impl.rb +77 -0
- data/lib/playwright/channel.rb +62 -1
- data/lib/playwright/channel_owner.rb +70 -7
- data/lib/playwright/channel_owners/android.rb +16 -3
- data/lib/playwright/channel_owners/android_device.rb +22 -66
- data/lib/playwright/channel_owners/api_request_context.rb +247 -0
- data/lib/playwright/channel_owners/artifact.rb +40 -0
- data/lib/playwright/channel_owners/binding_call.rb +70 -0
- data/lib/playwright/channel_owners/browser.rb +114 -22
- data/lib/playwright/channel_owners/browser_context.rb +589 -15
- data/lib/playwright/channel_owners/browser_type.rb +90 -1
- data/lib/playwright/channel_owners/cdp_session.rb +19 -0
- data/lib/playwright/channel_owners/dialog.rb +32 -0
- data/lib/playwright/channel_owners/element_handle.rb +107 -43
- data/lib/playwright/channel_owners/fetch_request.rb +8 -0
- data/lib/playwright/channel_owners/frame.rb +334 -104
- data/lib/playwright/channel_owners/js_handle.rb +9 -13
- data/lib/playwright/channel_owners/local_utils.rb +82 -0
- data/lib/playwright/channel_owners/page.rb +778 -95
- data/lib/playwright/channel_owners/playwright.rb +25 -30
- data/lib/playwright/channel_owners/request.rb +120 -18
- data/lib/playwright/channel_owners/response.rb +113 -0
- data/lib/playwright/channel_owners/route.rb +181 -0
- data/lib/playwright/channel_owners/stream.rb +30 -0
- data/lib/playwright/channel_owners/tracing.rb +117 -0
- data/lib/playwright/channel_owners/web_socket.rb +96 -0
- data/lib/playwright/channel_owners/worker.rb +46 -0
- data/lib/playwright/channel_owners/writable_stream.rb +14 -0
- data/lib/playwright/clock_impl.rb +67 -0
- data/lib/playwright/connection.rb +111 -63
- data/lib/playwright/console_message_impl.rb +29 -0
- data/lib/playwright/download_impl.rb +32 -0
- data/lib/playwright/errors.rb +42 -5
- data/lib/playwright/event_emitter.rb +17 -3
- data/lib/playwright/event_emitter_proxy.rb +49 -0
- data/lib/playwright/events.rb +10 -5
- data/lib/playwright/file_chooser_impl.rb +24 -0
- data/lib/playwright/frame_locator_impl.rb +66 -0
- data/lib/playwright/har_router.rb +89 -0
- data/lib/playwright/http_headers.rb +14 -0
- data/lib/playwright/input_files.rb +102 -15
- data/lib/playwright/javascript/expression.rb +7 -11
- data/lib/playwright/javascript/regex.rb +23 -0
- data/lib/playwright/javascript/source_url.rb +16 -0
- data/lib/playwright/javascript/value_parser.rb +108 -19
- data/lib/playwright/javascript/value_serializer.rb +47 -8
- data/lib/playwright/javascript/visitor_info.rb +26 -0
- data/lib/playwright/javascript.rb +2 -10
- data/lib/playwright/{input_types/keyboard.rb → keyboard_impl.rb} +6 -2
- data/lib/playwright/locator_assertions_impl.rb +571 -0
- data/lib/playwright/locator_impl.rb +544 -0
- data/lib/playwright/locator_utils.rb +136 -0
- data/lib/playwright/mouse_impl.rb +57 -0
- data/lib/playwright/page_assertions_impl.rb +154 -0
- data/lib/playwright/playwright_api.rb +102 -30
- data/lib/playwright/raw_headers.rb +61 -0
- data/lib/playwright/route_handler.rb +78 -0
- data/lib/playwright/select_option_values.rb +34 -13
- data/lib/playwright/selectors_impl.rb +45 -0
- data/lib/playwright/test.rb +102 -0
- data/lib/playwright/timeout_settings.rb +9 -4
- data/lib/playwright/touchscreen_impl.rb +14 -0
- data/lib/playwright/transport.rb +61 -10
- data/lib/playwright/url_matcher.rb +24 -2
- data/lib/playwright/utils.rb +48 -13
- data/lib/playwright/version.rb +2 -1
- data/lib/playwright/video.rb +54 -0
- data/lib/playwright/waiter.rb +166 -0
- data/lib/playwright/web_socket_client.rb +167 -0
- data/lib/playwright/web_socket_transport.rb +116 -0
- data/lib/playwright.rb +188 -11
- data/lib/playwright_api/android.rb +46 -11
- data/lib/playwright_api/android_device.rb +182 -31
- data/lib/playwright_api/android_input.rb +22 -13
- data/lib/playwright_api/android_socket.rb +18 -0
- data/lib/playwright_api/android_web_view.rb +24 -0
- data/lib/playwright_api/api_request.rb +26 -0
- data/lib/playwright_api/api_request_context.rb +311 -0
- data/lib/playwright_api/api_response.rb +92 -0
- data/lib/playwright_api/browser.rb +116 -103
- data/lib/playwright_api/browser_context.rb +290 -389
- data/lib/playwright_api/browser_type.rb +96 -118
- data/lib/playwright_api/cdp_session.rb +36 -39
- data/lib/playwright_api/clock.rb +121 -0
- data/lib/playwright_api/console_message.rb +35 -19
- data/lib/playwright_api/dialog.rb +53 -50
- data/lib/playwright_api/download.rb +49 -43
- data/lib/playwright_api/element_handle.rb +354 -402
- data/lib/playwright_api/file_chooser.rb +15 -18
- data/lib/playwright_api/frame.rb +703 -603
- data/lib/playwright_api/frame_locator.rb +285 -0
- data/lib/playwright_api/js_handle.rb +50 -76
- data/lib/playwright_api/keyboard.rb +67 -146
- data/lib/playwright_api/locator.rb +1304 -0
- data/lib/playwright_api/locator_assertions.rb +704 -0
- data/lib/playwright_api/mouse.rb +23 -29
- data/lib/playwright_api/page.rb +1196 -1176
- data/lib/playwright_api/page_assertions.rb +60 -0
- data/lib/playwright_api/playwright.rb +54 -122
- data/lib/playwright_api/request.rb +112 -74
- data/lib/playwright_api/response.rb +92 -20
- data/lib/playwright_api/route.rb +152 -62
- data/lib/playwright_api/selectors.rb +47 -61
- data/lib/playwright_api/touchscreen.rb +8 -2
- data/lib/playwright_api/tracing.rb +128 -0
- data/lib/playwright_api/web_socket.rb +43 -5
- data/lib/playwright_api/worker.rb +74 -34
- data/playwright.gemspec +14 -9
- data/sig/playwright.rbs +658 -0
- metadata +216 -50
- data/docs/api_coverage.md +0 -354
- data/lib/playwright/channel_owners/chromium_browser.rb +0 -8
- data/lib/playwright/channel_owners/chromium_browser_context.rb +0 -8
- data/lib/playwright/channel_owners/console_message.rb +0 -21
- data/lib/playwright/channel_owners/firefox_browser.rb +0 -8
- data/lib/playwright/channel_owners/selectors.rb +0 -4
- data/lib/playwright/channel_owners/webkit_browser.rb +0 -8
- data/lib/playwright/input_type.rb +0 -19
- data/lib/playwright/input_types/mouse.rb +0 -4
- data/lib/playwright/input_types/touchscreen.rb +0 -4
- data/lib/playwright/javascript/function.rb +0 -67
- data/lib/playwright/wait_helper.rb +0 -73
- data/lib/playwright_api/accessibility.rb +0 -93
- data/lib/playwright_api/binding_call.rb +0 -23
- data/lib/playwright_api/chromium_browser_context.rb +0 -57
- data/lib/playwright_api/video.rb +0 -24
|
@@ -0,0 +1,1218 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 10
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Frame
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
At every point of time, page exposes its current frame tree via the [Page#main_frame](./page#main_frame) and
|
|
9
|
+
[Frame#child_frames](./frame#child_frames) methods.
|
|
10
|
+
|
|
11
|
+
[Frame](./frame) object's lifecycle is controlled by three events, dispatched on the page object:
|
|
12
|
+
- [`event: Page.frameAttached`] - fired when the frame gets attached to the page. A Frame can be attached to the page only once.
|
|
13
|
+
- [`event: Page.frameNavigated`] - fired when the frame commits navigation to a different URL.
|
|
14
|
+
- [`event: Page.frameDetached`] - fired when the frame gets detached from the page. A Frame can be detached from the page only once.
|
|
15
|
+
|
|
16
|
+
An example of dumping frame tree:
|
|
17
|
+
|
|
18
|
+
```ruby
|
|
19
|
+
def dump_frame_tree(frame, indent = 0)
|
|
20
|
+
puts "#{' ' * indent}#{frame.name}@#{frame.url}"
|
|
21
|
+
frame.child_frames.each do |child|
|
|
22
|
+
dump_frame_tree(child, indent + 2)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
page.goto("https://www.theverge.com")
|
|
27
|
+
dump_frame_tree(page.main_frame)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## add_script_tag
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
def add_script_tag(content: nil, path: nil, type: nil, url: nil)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
Returns the added tag when the script's onload fires or when the script content was injected into frame.
|
|
38
|
+
|
|
39
|
+
Adds a `<script>` tag into the page with the desired url or content.
|
|
40
|
+
|
|
41
|
+
## add_style_tag
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
def add_style_tag(content: nil, path: nil, url: nil)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
Returns the added tag when the stylesheet's onload fires or when the CSS content was injected into frame.
|
|
49
|
+
|
|
50
|
+
Adds a `<link rel="stylesheet">` tag into the page with the desired url or a `<style type="text/css">` tag with the
|
|
51
|
+
content.
|
|
52
|
+
|
|
53
|
+
## check
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
def check(
|
|
57
|
+
selector,
|
|
58
|
+
force: nil,
|
|
59
|
+
noWaitAfter: nil,
|
|
60
|
+
position: nil,
|
|
61
|
+
strict: nil,
|
|
62
|
+
timeout: nil,
|
|
63
|
+
trial: nil)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
This method checks an element matching `selector` by performing the following steps:
|
|
68
|
+
1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
|
69
|
+
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.
|
|
70
|
+
1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
|
|
71
|
+
1. Scroll the element into view if needed.
|
|
72
|
+
1. Use [Page#mouse](./page#mouse) to click in the center of the element.
|
|
73
|
+
1. Ensure that the element is now checked. If not, this method throws.
|
|
74
|
+
|
|
75
|
+
When all steps combined have not finished during the specified `timeout`, this method throws a
|
|
76
|
+
`TimeoutError`. Passing zero timeout disables this.
|
|
77
|
+
|
|
78
|
+
## child_frames
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
def child_frames
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
## click
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
def click(
|
|
90
|
+
selector,
|
|
91
|
+
button: nil,
|
|
92
|
+
clickCount: nil,
|
|
93
|
+
delay: nil,
|
|
94
|
+
force: nil,
|
|
95
|
+
modifiers: nil,
|
|
96
|
+
noWaitAfter: nil,
|
|
97
|
+
position: nil,
|
|
98
|
+
strict: nil,
|
|
99
|
+
timeout: nil,
|
|
100
|
+
trial: nil)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
This method clicks an element matching `selector` by performing the following steps:
|
|
105
|
+
1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
|
106
|
+
1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
|
|
107
|
+
1. Scroll the element into view if needed.
|
|
108
|
+
1. Use [Page#mouse](./page#mouse) to click in the center of the element, or the specified `position`.
|
|
109
|
+
1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
|
110
|
+
|
|
111
|
+
When all steps combined have not finished during the specified `timeout`, this method throws a
|
|
112
|
+
`TimeoutError`. Passing zero timeout disables this.
|
|
113
|
+
|
|
114
|
+
## content
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
def content
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
Gets the full HTML contents of the frame, including the doctype.
|
|
122
|
+
|
|
123
|
+
## dblclick
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
def dblclick(
|
|
127
|
+
selector,
|
|
128
|
+
button: nil,
|
|
129
|
+
delay: nil,
|
|
130
|
+
force: nil,
|
|
131
|
+
modifiers: nil,
|
|
132
|
+
noWaitAfter: nil,
|
|
133
|
+
position: nil,
|
|
134
|
+
strict: nil,
|
|
135
|
+
timeout: nil,
|
|
136
|
+
trial: nil)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
This method double clicks an element matching `selector` by performing the following steps:
|
|
141
|
+
1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
|
142
|
+
1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
|
|
143
|
+
1. Scroll the element into view if needed.
|
|
144
|
+
1. Use [Page#mouse](./page#mouse) to double click in the center of the element, or the specified `position`. if the first click of the `dblclick()` triggers a navigation event, this method will throw.
|
|
145
|
+
|
|
146
|
+
When all steps combined have not finished during the specified `timeout`, this method throws a
|
|
147
|
+
`TimeoutError`. Passing zero timeout disables this.
|
|
148
|
+
|
|
149
|
+
**NOTE**: `frame.dblclick()` dispatches two `click` events and a single `dblclick` event.
|
|
150
|
+
|
|
151
|
+
## dispatch_event
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
def dispatch_event(
|
|
155
|
+
selector,
|
|
156
|
+
type,
|
|
157
|
+
eventInit: nil,
|
|
158
|
+
strict: nil,
|
|
159
|
+
timeout: nil)
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element, `click`
|
|
164
|
+
is dispatched. This is equivalent to calling
|
|
165
|
+
[element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
|
|
166
|
+
|
|
167
|
+
**Usage**
|
|
168
|
+
|
|
169
|
+
```ruby
|
|
170
|
+
frame.dispatch_event("button#submit", "click")
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Under the hood, it creates an instance of an event based on the given `type`, initializes it with
|
|
174
|
+
`eventInit` properties and dispatches it on the element. Events are `composed`, `cancelable` and bubble by
|
|
175
|
+
default.
|
|
176
|
+
|
|
177
|
+
Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial
|
|
178
|
+
properties:
|
|
179
|
+
- [DeviceMotionEvent](https://developer.mozilla.org/en-US/docs/Web/API/DeviceMotionEvent/DeviceMotionEvent)
|
|
180
|
+
- [DeviceOrientationEvent](https://developer.mozilla.org/en-US/docs/Web/API/DeviceOrientationEvent/DeviceOrientationEvent)
|
|
181
|
+
- [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent)
|
|
182
|
+
- [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event/Event)
|
|
183
|
+
- [FocusEvent](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent)
|
|
184
|
+
- [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent)
|
|
185
|
+
- [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent)
|
|
186
|
+
- [PointerEvent](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/PointerEvent)
|
|
187
|
+
- [TouchEvent](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/TouchEvent)
|
|
188
|
+
- [WheelEvent](https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/WheelEvent)
|
|
189
|
+
|
|
190
|
+
You can also specify [JSHandle](./js_handle) as the property value if you want live objects to be passed into the event:
|
|
191
|
+
|
|
192
|
+
```ruby
|
|
193
|
+
data_transfer = frame.evaluate_handle("new DataTransfer()")
|
|
194
|
+
frame.dispatch_event("#source", "dragstart", eventInit: { dataTransfer: data_transfer })
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## drag_and_drop
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
def drag_and_drop(
|
|
201
|
+
source,
|
|
202
|
+
target,
|
|
203
|
+
force: nil,
|
|
204
|
+
noWaitAfter: nil,
|
|
205
|
+
sourcePosition: nil,
|
|
206
|
+
steps: nil,
|
|
207
|
+
strict: nil,
|
|
208
|
+
targetPosition: nil,
|
|
209
|
+
timeout: nil,
|
|
210
|
+
trial: nil)
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
## eval_on_selector
|
|
216
|
+
|
|
217
|
+
```
|
|
218
|
+
def eval_on_selector(selector, expression, arg: nil, strict: nil)
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
Returns the return value of `expression`.
|
|
223
|
+
|
|
224
|
+
The method finds an element matching the specified selector within the frame and passes it as a first argument to
|
|
225
|
+
`expression`. If no
|
|
226
|
+
elements match the selector, the method throws an error.
|
|
227
|
+
|
|
228
|
+
If `expression` returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), then [Frame#eval_on_selector](./frame#eval_on_selector) would wait for the promise to resolve and return its
|
|
229
|
+
value.
|
|
230
|
+
|
|
231
|
+
**Usage**
|
|
232
|
+
|
|
233
|
+
```ruby
|
|
234
|
+
search_value = frame.eval_on_selector("#search", "el => el.value")
|
|
235
|
+
preload_href = frame.eval_on_selector("link[rel=preload]", "el => el.href")
|
|
236
|
+
html = frame.eval_on_selector(".main-container", "(e, suffix) => e.outerHTML + suffix", arg: "hello")
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## eval_on_selector_all
|
|
240
|
+
|
|
241
|
+
```
|
|
242
|
+
def eval_on_selector_all(selector, expression, arg: nil)
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
Returns the return value of `expression`.
|
|
247
|
+
|
|
248
|
+
The method finds all elements matching the specified selector within the frame and passes an array of matched elements
|
|
249
|
+
as a first argument to `expression`.
|
|
250
|
+
|
|
251
|
+
If `expression` returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), then [Frame#eval_on_selector_all](./frame#eval_on_selector_all) would wait for the promise to resolve and return its
|
|
252
|
+
value.
|
|
253
|
+
|
|
254
|
+
**Usage**
|
|
255
|
+
|
|
256
|
+
```ruby
|
|
257
|
+
divs_counts = frame.eval_on_selector_all("div", "(divs, min) => divs.length >= min", arg: 10)
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## evaluate
|
|
261
|
+
|
|
262
|
+
```
|
|
263
|
+
def evaluate(expression, arg: nil)
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
Returns the return value of `expression`.
|
|
268
|
+
|
|
269
|
+
If the function passed to the [Frame#evaluate](./frame#evaluate) returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), then [Frame#evaluate](./frame#evaluate) would wait for the promise to
|
|
270
|
+
resolve and return its value.
|
|
271
|
+
|
|
272
|
+
If the function passed to the [Frame#evaluate](./frame#evaluate) returns a non-[Serializable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#description) value, then
|
|
273
|
+
[Frame#evaluate](./frame#evaluate) returns `undefined`. Playwright also supports transferring some
|
|
274
|
+
additional values that are not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`.
|
|
275
|
+
|
|
276
|
+
**Usage**
|
|
277
|
+
|
|
278
|
+
```ruby
|
|
279
|
+
result = frame.evaluate("([x, y]) => Promise.resolve(x * y)", arg: [7, 8])
|
|
280
|
+
puts result # => "56"
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
A string can also be passed in instead of a function.
|
|
284
|
+
|
|
285
|
+
```ruby
|
|
286
|
+
puts frame.evaluate("1 + 2") # => 3
|
|
287
|
+
x = 10
|
|
288
|
+
puts frame.evaluate("1 + #{x}") # => "11"
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
[ElementHandle](./element_handle) instances can be passed as an argument to the [Frame#evaluate](./frame#evaluate):
|
|
292
|
+
|
|
293
|
+
```ruby
|
|
294
|
+
body_handle = frame.query_selector("body")
|
|
295
|
+
html = frame.evaluate("([body, suffix]) => body.innerHTML + suffix", arg: [body_handle, "hello"])
|
|
296
|
+
body_handle.dispose
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
## evaluate_handle
|
|
300
|
+
|
|
301
|
+
```
|
|
302
|
+
def evaluate_handle(expression, arg: nil)
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
Returns the return value of `expression` as a [JSHandle](./js_handle).
|
|
307
|
+
|
|
308
|
+
The only difference between [Frame#evaluate](./frame#evaluate) and [Frame#evaluate_handle](./frame#evaluate_handle) is that
|
|
309
|
+
[Frame#evaluate_handle](./frame#evaluate_handle) returns [JSHandle](./js_handle).
|
|
310
|
+
|
|
311
|
+
If the function, passed to the [Frame#evaluate_handle](./frame#evaluate_handle), returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), then
|
|
312
|
+
[Frame#evaluate_handle](./frame#evaluate_handle) would wait for the promise to resolve and return its value.
|
|
313
|
+
|
|
314
|
+
**Usage**
|
|
315
|
+
|
|
316
|
+
```ruby
|
|
317
|
+
a_window_handle = frame.evaluate_handle("Promise.resolve(window)")
|
|
318
|
+
a_window_handle # handle for the window object.
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
A string can also be passed in instead of a function.
|
|
322
|
+
|
|
323
|
+
```ruby
|
|
324
|
+
a_handle = page.evaluate_handle("document") # handle for the "document"
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
[JSHandle](./js_handle) instances can be passed as an argument to the [Frame#evaluate_handle](./frame#evaluate_handle):
|
|
328
|
+
|
|
329
|
+
```ruby
|
|
330
|
+
body_handle = page.evaluate_handle("document.body")
|
|
331
|
+
result_handle = page.evaluate_handle("body => body.innerHTML", arg: body_handle)
|
|
332
|
+
puts result_handle.json_value
|
|
333
|
+
result_handle.dispose
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
## fill
|
|
337
|
+
|
|
338
|
+
```
|
|
339
|
+
def fill(
|
|
340
|
+
selector,
|
|
341
|
+
value,
|
|
342
|
+
force: nil,
|
|
343
|
+
noWaitAfter: nil,
|
|
344
|
+
strict: nil,
|
|
345
|
+
timeout: nil)
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
This method waits for an element matching `selector`, waits for [actionability](https://playwright.dev/python/docs/actionability) 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.
|
|
350
|
+
|
|
351
|
+
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.
|
|
352
|
+
|
|
353
|
+
To send fine-grained keyboard events, use [Locator#press_sequentially](./locator#press_sequentially).
|
|
354
|
+
|
|
355
|
+
## focus
|
|
356
|
+
|
|
357
|
+
```
|
|
358
|
+
def focus(selector, strict: nil, timeout: nil)
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
This method fetches an element with `selector` and focuses it. If there's no element matching
|
|
363
|
+
`selector`, the method waits until a matching element appears in the DOM.
|
|
364
|
+
|
|
365
|
+
## frame_element
|
|
366
|
+
|
|
367
|
+
```
|
|
368
|
+
def frame_element
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
Returns the `frame` or `iframe` element handle which corresponds to this frame.
|
|
373
|
+
|
|
374
|
+
This is an inverse of [ElementHandle#content_frame](./element_handle#content_frame). Note that returned handle actually belongs to the parent
|
|
375
|
+
frame.
|
|
376
|
+
|
|
377
|
+
This method throws an error if the frame has been detached before `frameElement()` returns.
|
|
378
|
+
|
|
379
|
+
**Usage**
|
|
380
|
+
|
|
381
|
+
```ruby
|
|
382
|
+
frame_element = frame.frame_element
|
|
383
|
+
content_frame = frame_element.content_frame
|
|
384
|
+
puts frame == content_frame # => true
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
## frame_locator
|
|
388
|
+
|
|
389
|
+
```
|
|
390
|
+
def frame_locator(selector)
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
When working with iframes, you can create a frame locator that will enter the iframe and allow selecting elements
|
|
395
|
+
in that iframe.
|
|
396
|
+
|
|
397
|
+
**Usage**
|
|
398
|
+
|
|
399
|
+
Following snippet locates element with text "Submit" in the iframe with id `my-frame`, like `<iframe id="my-frame">`:
|
|
400
|
+
|
|
401
|
+
```ruby
|
|
402
|
+
locator = frame.frame_locator("#my-iframe").get_by_text("Submit")
|
|
403
|
+
locator.click
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
## get_attribute
|
|
407
|
+
|
|
408
|
+
```
|
|
409
|
+
def get_attribute(selector, name, strict: nil, timeout: nil)
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
Returns element attribute value.
|
|
414
|
+
|
|
415
|
+
## get_by_alt_text
|
|
416
|
+
|
|
417
|
+
```
|
|
418
|
+
def get_by_alt_text(text, exact: nil)
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
Allows locating elements by their alt text.
|
|
423
|
+
|
|
424
|
+
**Usage**
|
|
425
|
+
|
|
426
|
+
For example, this method will find the image by alt text "Playwright logo":
|
|
427
|
+
|
|
428
|
+
```html
|
|
429
|
+
<img alt='Playwright logo'>
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
```ruby
|
|
433
|
+
page.get_by_alt_text("Playwright logo").click
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
## get_by_label
|
|
437
|
+
|
|
438
|
+
```
|
|
439
|
+
def get_by_label(text, exact: nil)
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
Allows locating input elements by the text of the associated `<label>` or `aria-labelledby` element, or by the `aria-label` attribute.
|
|
444
|
+
|
|
445
|
+
**Usage**
|
|
446
|
+
|
|
447
|
+
For example, this method will find inputs by label "Username" and "Password" in the following DOM:
|
|
448
|
+
|
|
449
|
+
```html
|
|
450
|
+
<input aria-label="Username">
|
|
451
|
+
<label for="password-input">Password:</label>
|
|
452
|
+
<input id="password-input">
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
```ruby
|
|
456
|
+
page.get_by_label("Username").fill("john")
|
|
457
|
+
page.get_by_label("Password").fill("secret")
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
## get_by_placeholder
|
|
461
|
+
|
|
462
|
+
```
|
|
463
|
+
def get_by_placeholder(text, exact: nil)
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
Allows locating input elements by the placeholder text.
|
|
468
|
+
|
|
469
|
+
**Usage**
|
|
470
|
+
|
|
471
|
+
For example, consider the following DOM structure.
|
|
472
|
+
|
|
473
|
+
```html
|
|
474
|
+
<input type="email" placeholder="name@example.com" />
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
You can fill the input after locating it by the placeholder text:
|
|
478
|
+
|
|
479
|
+
```ruby
|
|
480
|
+
page.get_by_placeholder("name@example.com").fill("playwright@microsoft.com")
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
## get_by_role
|
|
484
|
+
|
|
485
|
+
```
|
|
486
|
+
def get_by_role(
|
|
487
|
+
role,
|
|
488
|
+
checked: nil,
|
|
489
|
+
disabled: nil,
|
|
490
|
+
exact: nil,
|
|
491
|
+
expanded: nil,
|
|
492
|
+
includeHidden: nil,
|
|
493
|
+
level: nil,
|
|
494
|
+
name: nil,
|
|
495
|
+
pressed: nil,
|
|
496
|
+
selected: nil)
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
|
|
500
|
+
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).
|
|
501
|
+
|
|
502
|
+
**Usage**
|
|
503
|
+
|
|
504
|
+
Consider the following DOM structure.
|
|
505
|
+
|
|
506
|
+
```html
|
|
507
|
+
<h3>Sign up</h3>
|
|
508
|
+
<label>
|
|
509
|
+
<input type="checkbox" /> Subscribe
|
|
510
|
+
</label>
|
|
511
|
+
<br/>
|
|
512
|
+
<button>Submit</button>
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
You can locate each element by it's implicit role:
|
|
516
|
+
|
|
517
|
+
```ruby
|
|
518
|
+
page.get_by_role("heading", name: "Sign up").visible? # => true
|
|
519
|
+
page.get_by_role("checkbox", name: "Subscribe").check
|
|
520
|
+
page.get_by_role("button", name: /submit/i).click
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
**Details**
|
|
524
|
+
|
|
525
|
+
Role selector **does not replace** accessibility audits and conformance tests, but rather gives early feedback about the ARIA guidelines.
|
|
526
|
+
|
|
527
|
+
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.
|
|
528
|
+
|
|
529
|
+
## get_by_test_id
|
|
530
|
+
|
|
531
|
+
```
|
|
532
|
+
def get_by_test_id(testId)
|
|
533
|
+
```
|
|
534
|
+
alias: `get_by_testid`
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
Locate element by the test id.
|
|
538
|
+
|
|
539
|
+
**Usage**
|
|
540
|
+
|
|
541
|
+
Consider the following DOM structure.
|
|
542
|
+
|
|
543
|
+
```html
|
|
544
|
+
<button data-testid="directions">Itinéraire</button>
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
You can locate the element by it's test id:
|
|
548
|
+
|
|
549
|
+
```ruby
|
|
550
|
+
page.get_by_test_id("directions").click
|
|
551
|
+
```
|
|
552
|
+
|
|
553
|
+
**Details**
|
|
554
|
+
|
|
555
|
+
By default, the `data-testid` attribute is used as a test id. Use [Selectors#set_test_id_attribute](./selectors#set_test_id_attribute) to configure a different test id attribute if necessary.
|
|
556
|
+
|
|
557
|
+
## get_by_text
|
|
558
|
+
|
|
559
|
+
```
|
|
560
|
+
def get_by_text(text, exact: nil)
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
Allows locating elements that contain given text.
|
|
565
|
+
|
|
566
|
+
See also [Locator#filter](./locator#filter) that allows to match by another criteria, like an accessible role, and then filter by the text content.
|
|
567
|
+
|
|
568
|
+
**Usage**
|
|
569
|
+
|
|
570
|
+
Consider the following DOM structure:
|
|
571
|
+
|
|
572
|
+
```html
|
|
573
|
+
<div>Hello <span>world</span></div>
|
|
574
|
+
<div>Hello</div>
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
You can locate by text substring, exact string, or a regular expression:
|
|
578
|
+
|
|
579
|
+
```ruby
|
|
580
|
+
page.content = <<~HTML
|
|
581
|
+
<div>Hello <span>world</span></div>
|
|
582
|
+
<div>Hello</div>
|
|
583
|
+
HTML
|
|
584
|
+
|
|
585
|
+
# Matches <span>
|
|
586
|
+
locator = page.get_by_text("world")
|
|
587
|
+
expect(locator.evaluate('e => e.outerHTML')).to eq('<span>world</span>')
|
|
588
|
+
|
|
589
|
+
# Matches first <div>
|
|
590
|
+
locator = page.get_by_text("Hello world")
|
|
591
|
+
expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello <span>world</span></div>')
|
|
592
|
+
|
|
593
|
+
# Matches second <div>
|
|
594
|
+
locator = page.get_by_text("Hello", exact: true)
|
|
595
|
+
expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
|
|
596
|
+
|
|
597
|
+
# Matches both <div>s
|
|
598
|
+
locator = page.get_by_text(/Hello/)
|
|
599
|
+
expect(locator.count).to eq(2)
|
|
600
|
+
expect(locator.first.evaluate('e => e.outerHTML')).to eq('<div>Hello <span>world</span></div>')
|
|
601
|
+
expect(locator.last.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
|
|
602
|
+
|
|
603
|
+
# Matches second <div>
|
|
604
|
+
locator = page.get_by_text(/^hello$/i)
|
|
605
|
+
expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
**Details**
|
|
609
|
+
|
|
610
|
+
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.
|
|
611
|
+
|
|
612
|
+
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">`.
|
|
613
|
+
|
|
614
|
+
## get_by_title
|
|
615
|
+
|
|
616
|
+
```
|
|
617
|
+
def get_by_title(text, exact: nil)
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
Allows locating elements by their title attribute.
|
|
622
|
+
|
|
623
|
+
**Usage**
|
|
624
|
+
|
|
625
|
+
Consider the following DOM structure.
|
|
626
|
+
|
|
627
|
+
```html
|
|
628
|
+
<span title='Issues count'>25 issues</span>
|
|
629
|
+
```
|
|
630
|
+
|
|
631
|
+
You can check the issues count after locating it by the title text:
|
|
632
|
+
|
|
633
|
+
```ruby
|
|
634
|
+
page.get_by_title("Issues count").text_content # => "25 issues"
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
## goto
|
|
638
|
+
|
|
639
|
+
```
|
|
640
|
+
def goto(url, referer: nil, timeout: nil, waitUntil: nil)
|
|
641
|
+
```
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
|
|
645
|
+
last redirect.
|
|
646
|
+
|
|
647
|
+
The method will throw an error if:
|
|
648
|
+
- there's an SSL error (e.g. in case of self-signed certificates).
|
|
649
|
+
- target URL is invalid.
|
|
650
|
+
- the `timeout` is exceeded during navigation.
|
|
651
|
+
- the remote server does not respond or is unreachable.
|
|
652
|
+
- the main resource failed to load.
|
|
653
|
+
|
|
654
|
+
The method will not throw an error when any valid HTTP status code is returned by the remote server, including 404
|
|
655
|
+
"Not Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling
|
|
656
|
+
[Response#status](./response#status).
|
|
657
|
+
|
|
658
|
+
**NOTE**: The method either throws an error or returns a main resource response. The only exceptions are navigation to
|
|
659
|
+
`about:blank` or navigation to the same URL with a different hash, which would succeed and return `null`.
|
|
660
|
+
|
|
661
|
+
**NOTE**: Headless mode doesn't support navigation to a PDF document. See the
|
|
662
|
+
[upstream issue](https://bugs.chromium.org/p/chromium/issues/detail?id=761295).
|
|
663
|
+
|
|
664
|
+
## hover
|
|
665
|
+
|
|
666
|
+
```
|
|
667
|
+
def hover(
|
|
668
|
+
selector,
|
|
669
|
+
force: nil,
|
|
670
|
+
modifiers: nil,
|
|
671
|
+
noWaitAfter: nil,
|
|
672
|
+
position: nil,
|
|
673
|
+
strict: nil,
|
|
674
|
+
timeout: nil,
|
|
675
|
+
trial: nil)
|
|
676
|
+
```
|
|
677
|
+
|
|
678
|
+
|
|
679
|
+
This method hovers over an element matching `selector` by performing the following steps:
|
|
680
|
+
1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
|
681
|
+
1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
|
|
682
|
+
1. Scroll the element into view if needed.
|
|
683
|
+
1. Use [Page#mouse](./page#mouse) to hover over the center of the element, or the specified `position`.
|
|
684
|
+
|
|
685
|
+
When all steps combined have not finished during the specified `timeout`, this method throws a
|
|
686
|
+
`TimeoutError`. Passing zero timeout disables this.
|
|
687
|
+
|
|
688
|
+
## inner_html
|
|
689
|
+
|
|
690
|
+
```
|
|
691
|
+
def inner_html(selector, strict: nil, timeout: nil)
|
|
692
|
+
```
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
Returns `element.innerHTML`.
|
|
696
|
+
|
|
697
|
+
## inner_text
|
|
698
|
+
|
|
699
|
+
```
|
|
700
|
+
def inner_text(selector, strict: nil, timeout: nil)
|
|
701
|
+
```
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
Returns `element.innerText`.
|
|
705
|
+
|
|
706
|
+
## input_value
|
|
707
|
+
|
|
708
|
+
```
|
|
709
|
+
def input_value(selector, strict: nil, timeout: nil)
|
|
710
|
+
```
|
|
711
|
+
|
|
712
|
+
|
|
713
|
+
Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element.
|
|
714
|
+
|
|
715
|
+
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.
|
|
716
|
+
|
|
717
|
+
## checked?
|
|
718
|
+
|
|
719
|
+
```
|
|
720
|
+
def checked?(selector, strict: nil, timeout: nil)
|
|
721
|
+
```
|
|
722
|
+
|
|
723
|
+
|
|
724
|
+
Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
|
|
725
|
+
|
|
726
|
+
## detached?
|
|
727
|
+
|
|
728
|
+
```
|
|
729
|
+
def detached?
|
|
730
|
+
```
|
|
731
|
+
|
|
732
|
+
|
|
733
|
+
Returns `true` if the frame has been detached, or `false` otherwise.
|
|
734
|
+
|
|
735
|
+
## disabled?
|
|
736
|
+
|
|
737
|
+
```
|
|
738
|
+
def disabled?(selector, strict: nil, timeout: nil)
|
|
739
|
+
```
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
Returns whether the element is disabled, the opposite of [enabled](https://playwright.dev/python/docs/actionability#enabled).
|
|
743
|
+
|
|
744
|
+
## editable?
|
|
745
|
+
|
|
746
|
+
```
|
|
747
|
+
def editable?(selector, strict: nil, timeout: nil)
|
|
748
|
+
```
|
|
749
|
+
|
|
750
|
+
|
|
751
|
+
Returns whether the element is [editable](https://playwright.dev/python/docs/actionability#editable).
|
|
752
|
+
|
|
753
|
+
## enabled?
|
|
754
|
+
|
|
755
|
+
```
|
|
756
|
+
def enabled?(selector, strict: nil, timeout: nil)
|
|
757
|
+
```
|
|
758
|
+
|
|
759
|
+
|
|
760
|
+
Returns whether the element is [enabled](https://playwright.dev/python/docs/actionability#enabled).
|
|
761
|
+
|
|
762
|
+
## hidden?
|
|
763
|
+
|
|
764
|
+
```
|
|
765
|
+
def hidden?(selector, strict: nil, timeout: nil)
|
|
766
|
+
```
|
|
767
|
+
|
|
768
|
+
|
|
769
|
+
Returns whether the element is hidden, the opposite of [visible](https://playwright.dev/python/docs/actionability#visible). `selector` that does not match any elements is considered hidden.
|
|
770
|
+
|
|
771
|
+
## visible?
|
|
772
|
+
|
|
773
|
+
```
|
|
774
|
+
def visible?(selector, strict: nil, timeout: nil)
|
|
775
|
+
```
|
|
776
|
+
|
|
777
|
+
|
|
778
|
+
Returns whether the element is [visible](https://playwright.dev/python/docs/actionability#visible). `selector` that does not match any elements is considered not visible.
|
|
779
|
+
|
|
780
|
+
## locator
|
|
781
|
+
|
|
782
|
+
```
|
|
783
|
+
def locator(
|
|
784
|
+
selector,
|
|
785
|
+
has: nil,
|
|
786
|
+
hasNot: nil,
|
|
787
|
+
hasNotText: nil,
|
|
788
|
+
hasText: nil)
|
|
789
|
+
```
|
|
790
|
+
|
|
791
|
+
|
|
792
|
+
The method returns an element locator that can be used to perform actions on this page / frame.
|
|
793
|
+
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.
|
|
794
|
+
|
|
795
|
+
[Learn more about locators](https://playwright.dev/python/docs/locators).
|
|
796
|
+
|
|
797
|
+
[Learn more about locators](https://playwright.dev/python/docs/locators).
|
|
798
|
+
|
|
799
|
+
## name
|
|
800
|
+
|
|
801
|
+
```
|
|
802
|
+
def name
|
|
803
|
+
```
|
|
804
|
+
|
|
805
|
+
|
|
806
|
+
Returns frame's name attribute as specified in the tag.
|
|
807
|
+
|
|
808
|
+
If the name is empty, returns the id attribute instead.
|
|
809
|
+
|
|
810
|
+
**NOTE**: This value is calculated once when the frame is created, and will not update if the attribute is changed later.
|
|
811
|
+
|
|
812
|
+
## page
|
|
813
|
+
|
|
814
|
+
```
|
|
815
|
+
def page
|
|
816
|
+
```
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
Returns the page containing this frame.
|
|
820
|
+
|
|
821
|
+
## parent_frame
|
|
822
|
+
|
|
823
|
+
```
|
|
824
|
+
def parent_frame
|
|
825
|
+
```
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
Parent frame, if any. Detached frames and main frames return `null`.
|
|
829
|
+
|
|
830
|
+
## press
|
|
831
|
+
|
|
832
|
+
```
|
|
833
|
+
def press(
|
|
834
|
+
selector,
|
|
835
|
+
key,
|
|
836
|
+
delay: nil,
|
|
837
|
+
noWaitAfter: nil,
|
|
838
|
+
strict: nil,
|
|
839
|
+
timeout: nil)
|
|
840
|
+
```
|
|
841
|
+
|
|
842
|
+
|
|
843
|
+
`key` can specify the intended
|
|
844
|
+
[keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to
|
|
845
|
+
generate the text for. A superset of the `key` values can be found
|
|
846
|
+
[here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
|
|
847
|
+
|
|
848
|
+
`F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
|
|
849
|
+
`Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
|
|
850
|
+
|
|
851
|
+
Following modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`, `ControlOrMeta`.
|
|
852
|
+
`ControlOrMeta` resolves to `Control` on Windows and Linux and to `Meta` on macOS.
|
|
853
|
+
|
|
854
|
+
Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
|
|
855
|
+
|
|
856
|
+
If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different
|
|
857
|
+
respective texts.
|
|
858
|
+
|
|
859
|
+
Shortcuts such as `key: "Control+o"`, `key: "Control++` or `key: "Control+Shift+T"` are supported as well. When specified with the
|
|
860
|
+
modifier, modifier is pressed and being held while the subsequent key is being pressed.
|
|
861
|
+
|
|
862
|
+
## query_selector
|
|
863
|
+
|
|
864
|
+
```
|
|
865
|
+
def query_selector(selector, strict: nil)
|
|
866
|
+
```
|
|
867
|
+
|
|
868
|
+
|
|
869
|
+
Returns the ElementHandle pointing to the frame element.
|
|
870
|
+
|
|
871
|
+
**NOTE**: The use of [ElementHandle](./element_handle) is discouraged, use [Locator](./locator) objects and web-first assertions instead.
|
|
872
|
+
|
|
873
|
+
The method finds an element matching the specified selector within the frame. If no elements match the selector,
|
|
874
|
+
returns `null`.
|
|
875
|
+
|
|
876
|
+
## query_selector_all
|
|
877
|
+
|
|
878
|
+
```
|
|
879
|
+
def query_selector_all(selector)
|
|
880
|
+
```
|
|
881
|
+
|
|
882
|
+
|
|
883
|
+
Returns the ElementHandles pointing to the frame elements.
|
|
884
|
+
|
|
885
|
+
**NOTE**: The use of [ElementHandle](./element_handle) is discouraged, use [Locator](./locator) objects instead.
|
|
886
|
+
|
|
887
|
+
The method finds all elements matching the specified selector within the frame. If no elements match the selector,
|
|
888
|
+
returns empty array.
|
|
889
|
+
|
|
890
|
+
## select_option
|
|
891
|
+
|
|
892
|
+
```
|
|
893
|
+
def select_option(
|
|
894
|
+
selector,
|
|
895
|
+
element: nil,
|
|
896
|
+
index: nil,
|
|
897
|
+
value: nil,
|
|
898
|
+
label: nil,
|
|
899
|
+
force: nil,
|
|
900
|
+
noWaitAfter: nil,
|
|
901
|
+
strict: nil,
|
|
902
|
+
timeout: nil)
|
|
903
|
+
```
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
This method waits for an element matching `selector`, waits for [actionability](https://playwright.dev/python/docs/actionability) checks, waits until all specified options are present in the `<select>` element and selects these options.
|
|
907
|
+
|
|
908
|
+
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.
|
|
909
|
+
|
|
910
|
+
Returns the array of option values that have been successfully selected.
|
|
911
|
+
|
|
912
|
+
Triggers a `change` and `input` event once all the provided options have been selected.
|
|
913
|
+
|
|
914
|
+
**Usage**
|
|
915
|
+
|
|
916
|
+
```ruby
|
|
917
|
+
# single selection matching the value
|
|
918
|
+
frame.select_option("select#colors", value: "blue")
|
|
919
|
+
# single selection matching both the label
|
|
920
|
+
frame.select_option("select#colors", label: "blue")
|
|
921
|
+
# multiple selection
|
|
922
|
+
frame.select_option("select#colors", value: ["red", "green", "blue"])
|
|
923
|
+
```
|
|
924
|
+
|
|
925
|
+
## set_checked
|
|
926
|
+
|
|
927
|
+
```
|
|
928
|
+
def set_checked(
|
|
929
|
+
selector,
|
|
930
|
+
checked,
|
|
931
|
+
force: nil,
|
|
932
|
+
noWaitAfter: nil,
|
|
933
|
+
position: nil,
|
|
934
|
+
strict: nil,
|
|
935
|
+
timeout: nil,
|
|
936
|
+
trial: nil)
|
|
937
|
+
```
|
|
938
|
+
|
|
939
|
+
|
|
940
|
+
This method checks or unchecks an element matching `selector` by performing the following steps:
|
|
941
|
+
1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
|
942
|
+
1. Ensure that matched element is a checkbox or a radio input. If not, this method throws.
|
|
943
|
+
1. If the element already has the right checked state, this method returns immediately.
|
|
944
|
+
1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
|
|
945
|
+
1. Scroll the element into view if needed.
|
|
946
|
+
1. Use [Page#mouse](./page#mouse) to click in the center of the element.
|
|
947
|
+
1. Ensure that the element is now checked or unchecked. If not, this method throws.
|
|
948
|
+
|
|
949
|
+
When all steps combined have not finished during the specified `timeout`, this method throws a
|
|
950
|
+
`TimeoutError`. Passing zero timeout disables this.
|
|
951
|
+
|
|
952
|
+
## set_content
|
|
953
|
+
|
|
954
|
+
```
|
|
955
|
+
def set_content(html, timeout: nil, waitUntil: nil)
|
|
956
|
+
```
|
|
957
|
+
alias: `content=`
|
|
958
|
+
|
|
959
|
+
|
|
960
|
+
This method internally calls [document.write()](https://developer.mozilla.org/en-US/docs/Web/API/Document/write), inheriting all its specific characteristics and behaviors.
|
|
961
|
+
|
|
962
|
+
## set_input_files
|
|
963
|
+
|
|
964
|
+
```
|
|
965
|
+
def set_input_files(
|
|
966
|
+
selector,
|
|
967
|
+
files,
|
|
968
|
+
noWaitAfter: nil,
|
|
969
|
+
strict: nil,
|
|
970
|
+
timeout: nil)
|
|
971
|
+
```
|
|
972
|
+
|
|
973
|
+
|
|
974
|
+
Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
|
|
975
|
+
are resolved relative to the current working directory. For empty array, clears the selected files.
|
|
976
|
+
|
|
977
|
+
This method expects `selector` to point to an
|
|
978
|
+
[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.
|
|
979
|
+
|
|
980
|
+
## tap_point
|
|
981
|
+
|
|
982
|
+
```
|
|
983
|
+
def tap_point(
|
|
984
|
+
selector,
|
|
985
|
+
force: nil,
|
|
986
|
+
modifiers: nil,
|
|
987
|
+
noWaitAfter: nil,
|
|
988
|
+
position: nil,
|
|
989
|
+
strict: nil,
|
|
990
|
+
timeout: nil,
|
|
991
|
+
trial: nil)
|
|
992
|
+
```
|
|
993
|
+
|
|
994
|
+
|
|
995
|
+
This method taps an element matching `selector` by performing the following steps:
|
|
996
|
+
1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
|
997
|
+
1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
|
|
998
|
+
1. Scroll the element into view if needed.
|
|
999
|
+
1. Use [Page#touchscreen](./page#touchscreen) to tap the center of the element, or the specified `position`.
|
|
1000
|
+
|
|
1001
|
+
When all steps combined have not finished during the specified `timeout`, this method throws a
|
|
1002
|
+
`TimeoutError`. Passing zero timeout disables this.
|
|
1003
|
+
|
|
1004
|
+
**NOTE**: `frame.tap()` requires that the `hasTouch` option of the browser context be set to true.
|
|
1005
|
+
|
|
1006
|
+
## text_content
|
|
1007
|
+
|
|
1008
|
+
```
|
|
1009
|
+
def text_content(selector, strict: nil, timeout: nil)
|
|
1010
|
+
```
|
|
1011
|
+
|
|
1012
|
+
|
|
1013
|
+
Returns `element.textContent`.
|
|
1014
|
+
|
|
1015
|
+
## title
|
|
1016
|
+
|
|
1017
|
+
```
|
|
1018
|
+
def title
|
|
1019
|
+
```
|
|
1020
|
+
|
|
1021
|
+
|
|
1022
|
+
Returns the page title.
|
|
1023
|
+
|
|
1024
|
+
## type
|
|
1025
|
+
|
|
1026
|
+
```
|
|
1027
|
+
def type(
|
|
1028
|
+
selector,
|
|
1029
|
+
text,
|
|
1030
|
+
delay: nil,
|
|
1031
|
+
noWaitAfter: nil,
|
|
1032
|
+
strict: nil,
|
|
1033
|
+
timeout: nil)
|
|
1034
|
+
```
|
|
1035
|
+
|
|
1036
|
+
:::warning
|
|
1037
|
+
|
|
1038
|
+
In most cases, you should use [Locator#fill](./locator#fill) instead. You only need to press keys one by one if there is special keyboard handling on the page - in this case use [Locator#press_sequentially](./locator#press_sequentially).
|
|
1039
|
+
|
|
1040
|
+
:::
|
|
1041
|
+
|
|
1042
|
+
|
|
1043
|
+
Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. `frame.type` can be used to
|
|
1044
|
+
send fine-grained keyboard events. To fill values in form fields, use [Frame#fill](./frame#fill).
|
|
1045
|
+
|
|
1046
|
+
To press a special key, like `Control` or `ArrowDown`, use [Keyboard#press](./keyboard#press).
|
|
1047
|
+
|
|
1048
|
+
**Usage**
|
|
1049
|
+
|
|
1050
|
+
## uncheck
|
|
1051
|
+
|
|
1052
|
+
```
|
|
1053
|
+
def uncheck(
|
|
1054
|
+
selector,
|
|
1055
|
+
force: nil,
|
|
1056
|
+
noWaitAfter: nil,
|
|
1057
|
+
position: nil,
|
|
1058
|
+
strict: nil,
|
|
1059
|
+
timeout: nil,
|
|
1060
|
+
trial: nil)
|
|
1061
|
+
```
|
|
1062
|
+
|
|
1063
|
+
|
|
1064
|
+
This method checks an element matching `selector` by performing the following steps:
|
|
1065
|
+
1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
|
1066
|
+
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.
|
|
1067
|
+
1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
|
|
1068
|
+
1. Scroll the element into view if needed.
|
|
1069
|
+
1. Use [Page#mouse](./page#mouse) to click in the center of the element.
|
|
1070
|
+
1. Ensure that the element is now unchecked. If not, this method throws.
|
|
1071
|
+
|
|
1072
|
+
When all steps combined have not finished during the specified `timeout`, this method throws a
|
|
1073
|
+
`TimeoutError`. Passing zero timeout disables this.
|
|
1074
|
+
|
|
1075
|
+
## url
|
|
1076
|
+
|
|
1077
|
+
```
|
|
1078
|
+
def url
|
|
1079
|
+
```
|
|
1080
|
+
|
|
1081
|
+
|
|
1082
|
+
Returns frame's url.
|
|
1083
|
+
|
|
1084
|
+
## wait_for_function
|
|
1085
|
+
|
|
1086
|
+
```
|
|
1087
|
+
def wait_for_function(expression, arg: nil, polling: nil, timeout: nil)
|
|
1088
|
+
```
|
|
1089
|
+
|
|
1090
|
+
|
|
1091
|
+
Returns when the `expression` returns a truthy value, returns that value.
|
|
1092
|
+
|
|
1093
|
+
**Usage**
|
|
1094
|
+
|
|
1095
|
+
The [Frame#wait_for_function](./frame#wait_for_function) can be used to observe viewport size change:
|
|
1096
|
+
|
|
1097
|
+
```ruby
|
|
1098
|
+
frame.evaluate("window.x = 0; setTimeout(() => { window.x = 100 }, 1000);")
|
|
1099
|
+
frame.wait_for_function("() => window.x > 0")
|
|
1100
|
+
```
|
|
1101
|
+
|
|
1102
|
+
To pass an argument to the predicate of `frame.waitForFunction` function:
|
|
1103
|
+
|
|
1104
|
+
```ruby
|
|
1105
|
+
selector = ".foo"
|
|
1106
|
+
frame.wait_for_function("selector => !!document.querySelector(selector)", arg: selector)
|
|
1107
|
+
```
|
|
1108
|
+
|
|
1109
|
+
## wait_for_load_state
|
|
1110
|
+
|
|
1111
|
+
```
|
|
1112
|
+
def wait_for_load_state(state: nil, timeout: nil)
|
|
1113
|
+
```
|
|
1114
|
+
|
|
1115
|
+
|
|
1116
|
+
Waits for the required load state to be reached.
|
|
1117
|
+
|
|
1118
|
+
This returns when the frame reaches a required load state, `load` by default. The navigation must have been committed
|
|
1119
|
+
when this method is called. If current document has already reached the required state, resolves immediately.
|
|
1120
|
+
|
|
1121
|
+
**NOTE**: Most of the time, this method is not needed because Playwright [auto-waits before every action](https://playwright.dev/python/docs/actionability).
|
|
1122
|
+
|
|
1123
|
+
**Usage**
|
|
1124
|
+
|
|
1125
|
+
```ruby
|
|
1126
|
+
frame.click("button") # click triggers navigation.
|
|
1127
|
+
frame.wait_for_load_state # the promise resolves after "load" event.
|
|
1128
|
+
```
|
|
1129
|
+
|
|
1130
|
+
## expect_navigation
|
|
1131
|
+
|
|
1132
|
+
```
|
|
1133
|
+
def expect_navigation(timeout: nil, url: nil, waitUntil: nil, &block)
|
|
1134
|
+
```
|
|
1135
|
+
|
|
1136
|
+
:::warning
|
|
1137
|
+
|
|
1138
|
+
This method is inherently racy, please use [Frame#wait_for_url](./frame#wait_for_url) instead.
|
|
1139
|
+
|
|
1140
|
+
:::
|
|
1141
|
+
|
|
1142
|
+
|
|
1143
|
+
Waits for the frame navigation and returns the main resource response. In case of multiple redirects, the navigation
|
|
1144
|
+
will resolve with the response of the last redirect. In case of navigation to a different anchor or navigation due to
|
|
1145
|
+
History API usage, the navigation will resolve with `null`.
|
|
1146
|
+
|
|
1147
|
+
**Usage**
|
|
1148
|
+
|
|
1149
|
+
This method waits for the frame to navigate to a new URL. It is useful for when you run code which will indirectly cause
|
|
1150
|
+
the frame to navigate. Consider this example:
|
|
1151
|
+
|
|
1152
|
+
```ruby
|
|
1153
|
+
frame.expect_navigation do
|
|
1154
|
+
frame.click("a.delayed-navigation") # clicking the link will indirectly cause a navigation
|
|
1155
|
+
end # Resolves after navigation has finished
|
|
1156
|
+
```
|
|
1157
|
+
|
|
1158
|
+
**NOTE**: Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the URL is considered
|
|
1159
|
+
a navigation.
|
|
1160
|
+
|
|
1161
|
+
## wait_for_selector
|
|
1162
|
+
|
|
1163
|
+
```
|
|
1164
|
+
def wait_for_selector(selector, state: nil, strict: nil, timeout: nil)
|
|
1165
|
+
```
|
|
1166
|
+
|
|
1167
|
+
|
|
1168
|
+
Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or
|
|
1169
|
+
`detached`.
|
|
1170
|
+
|
|
1171
|
+
**NOTE**: Playwright automatically waits for element to be ready before performing an action. Using
|
|
1172
|
+
[Locator](./locator) objects and web-first assertions make the code wait-for-selector-free.
|
|
1173
|
+
|
|
1174
|
+
Wait for the `selector` to satisfy `state` option (either appear/disappear from dom, or become
|
|
1175
|
+
visible/hidden). If at the moment of calling the method `selector` already satisfies the condition, the method
|
|
1176
|
+
will return immediately. If the selector doesn't satisfy the condition for the `timeout` milliseconds, the
|
|
1177
|
+
function will throw.
|
|
1178
|
+
|
|
1179
|
+
**Usage**
|
|
1180
|
+
|
|
1181
|
+
This method works across navigations:
|
|
1182
|
+
|
|
1183
|
+
```ruby
|
|
1184
|
+
%w[https://google.com https://bbc.com].each do |current_url|
|
|
1185
|
+
page.goto(current_url, waitUntil: "domcontentloaded")
|
|
1186
|
+
frame = page.main_frame
|
|
1187
|
+
element = frame.wait_for_selector("img")
|
|
1188
|
+
puts "Loaded image: #{element["src"]}"
|
|
1189
|
+
end
|
|
1190
|
+
```
|
|
1191
|
+
|
|
1192
|
+
## wait_for_timeout
|
|
1193
|
+
|
|
1194
|
+
```
|
|
1195
|
+
def wait_for_timeout(timeout)
|
|
1196
|
+
```
|
|
1197
|
+
|
|
1198
|
+
|
|
1199
|
+
Waits for the given `timeout` in milliseconds.
|
|
1200
|
+
|
|
1201
|
+
Note that `frame.waitForTimeout()` should only be used for debugging. Tests using the timer in production are going to
|
|
1202
|
+
be flaky. Use signals such as network events, selectors becoming visible and others instead.
|
|
1203
|
+
|
|
1204
|
+
## wait_for_url
|
|
1205
|
+
|
|
1206
|
+
```
|
|
1207
|
+
def wait_for_url(url, timeout: nil, waitUntil: nil)
|
|
1208
|
+
```
|
|
1209
|
+
|
|
1210
|
+
|
|
1211
|
+
Waits for the frame to navigate to the given URL.
|
|
1212
|
+
|
|
1213
|
+
**Usage**
|
|
1214
|
+
|
|
1215
|
+
```ruby
|
|
1216
|
+
frame.click("a.delayed-navigation") # clicking the link will indirectly cause a navigation
|
|
1217
|
+
frame.wait_for_url("**/target.html")
|
|
1218
|
+
```
|