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,694 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 10
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# ElementHandle
|
|
6
|
+
|
|
7
|
+
- extends: [JSHandle](./js_handle)
|
|
8
|
+
|
|
9
|
+
ElementHandle represents an in-page DOM element. ElementHandles can be created with the [Page#query_selector](./page#query_selector) method.
|
|
10
|
+
|
|
11
|
+
**NOTE**: The use of ElementHandle is discouraged, use [Locator](./locator) objects and web-first assertions instead.
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
href_element = page.query_selector("a")
|
|
15
|
+
href_element.click
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
ElementHandle prevents DOM element from garbage collection unless the handle is disposed with
|
|
19
|
+
[JSHandle#dispose](./js_handle#dispose). ElementHandles are auto-disposed when their origin frame gets navigated.
|
|
20
|
+
|
|
21
|
+
ElementHandle instances can be used as an argument in [Page#eval_on_selector](./page#eval_on_selector) and [Page#evaluate](./page#evaluate) methods.
|
|
22
|
+
|
|
23
|
+
The difference between the [Locator](./locator) and ElementHandle is that the ElementHandle points to a particular element, while [Locator](./locator) captures the logic of how to retrieve an element.
|
|
24
|
+
|
|
25
|
+
In the example below, handle points to a particular DOM element on page. If that element changes text or is used by React to render an entirely different component, handle is still pointing to that very DOM element. This can lead to unexpected behaviors.
|
|
26
|
+
|
|
27
|
+
```ruby
|
|
28
|
+
handle = page.query_selector("text=Submit")
|
|
29
|
+
handle.hover
|
|
30
|
+
handle.click
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
With the locator, every time the `element` is used, up-to-date DOM element is located in the page using the selector. So in the snippet below, underlying DOM element is going to be located twice.
|
|
34
|
+
|
|
35
|
+
```ruby
|
|
36
|
+
locator = page.get_by_text("Submit")
|
|
37
|
+
locator.hover
|
|
38
|
+
locator.click
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## bounding_box
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
def bounding_box
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
This method returns the bounding box of the element, or `null` if the element is not visible. The bounding box is
|
|
49
|
+
calculated relative to the main frame viewport - which is usually the same as the browser window.
|
|
50
|
+
|
|
51
|
+
Scrolling affects the returned bounding box, similarly to
|
|
52
|
+
[Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect). That
|
|
53
|
+
means `x` and/or `y` may be negative.
|
|
54
|
+
|
|
55
|
+
Elements from child frames return the bounding box relative to the main frame, unlike the
|
|
56
|
+
[Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect).
|
|
57
|
+
|
|
58
|
+
Assuming the page is static, it is safe to use bounding box coordinates to perform input. For example, the following
|
|
59
|
+
snippet should click the center of the element.
|
|
60
|
+
|
|
61
|
+
**Usage**
|
|
62
|
+
|
|
63
|
+
```ruby
|
|
64
|
+
box = element_handle.bounding_box
|
|
65
|
+
page.mouse.click(
|
|
66
|
+
box["x"] + box["width"] / 2,
|
|
67
|
+
box["y"] + box["height"] / 2,
|
|
68
|
+
)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## check
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
def check(
|
|
75
|
+
force: nil,
|
|
76
|
+
noWaitAfter: nil,
|
|
77
|
+
position: nil,
|
|
78
|
+
timeout: nil,
|
|
79
|
+
trial: nil)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
This method checks the element by performing the following steps:
|
|
84
|
+
1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already checked, this method returns immediately.
|
|
85
|
+
1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the element, unless `force` option is set.
|
|
86
|
+
1. Scroll the element into view if needed.
|
|
87
|
+
1. Use [Page#mouse](./page#mouse) to click in the center of the element.
|
|
88
|
+
1. Ensure that the element is now checked. If not, this method throws.
|
|
89
|
+
|
|
90
|
+
If the element is detached from the DOM at any moment during the action, this method throws.
|
|
91
|
+
|
|
92
|
+
When all steps combined have not finished during the specified `timeout`, this method throws a
|
|
93
|
+
`TimeoutError`. Passing zero timeout disables this.
|
|
94
|
+
|
|
95
|
+
## click
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
def click(
|
|
99
|
+
button: nil,
|
|
100
|
+
clickCount: nil,
|
|
101
|
+
delay: nil,
|
|
102
|
+
force: nil,
|
|
103
|
+
modifiers: nil,
|
|
104
|
+
noWaitAfter: nil,
|
|
105
|
+
position: nil,
|
|
106
|
+
steps: nil,
|
|
107
|
+
timeout: nil,
|
|
108
|
+
trial: nil)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
This method clicks the element by performing the following steps:
|
|
113
|
+
1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the element, unless `force` option is set.
|
|
114
|
+
1. Scroll the element into view if needed.
|
|
115
|
+
1. Use [Page#mouse](./page#mouse) to click in the center of the element, or the specified `position`.
|
|
116
|
+
1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
|
117
|
+
|
|
118
|
+
If the element is detached from the DOM at any moment during the action, this method throws.
|
|
119
|
+
|
|
120
|
+
When all steps combined have not finished during the specified `timeout`, this method throws a
|
|
121
|
+
`TimeoutError`. Passing zero timeout disables this.
|
|
122
|
+
|
|
123
|
+
## content_frame
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
def content_frame
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
Returns the content frame for element handles referencing iframe nodes, or `null` otherwise
|
|
131
|
+
|
|
132
|
+
## dblclick
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
def dblclick(
|
|
136
|
+
button: nil,
|
|
137
|
+
delay: nil,
|
|
138
|
+
force: nil,
|
|
139
|
+
modifiers: nil,
|
|
140
|
+
noWaitAfter: nil,
|
|
141
|
+
position: nil,
|
|
142
|
+
steps: nil,
|
|
143
|
+
timeout: nil,
|
|
144
|
+
trial: nil)
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
This method double clicks the element by performing the following steps:
|
|
149
|
+
1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the element, unless `force` option is set.
|
|
150
|
+
1. Scroll the element into view if needed.
|
|
151
|
+
1. Use [Page#mouse](./page#mouse) to double click in the center of the element, or the specified `position`.
|
|
152
|
+
|
|
153
|
+
If the element is detached from the DOM at any moment during the action, this method throws.
|
|
154
|
+
|
|
155
|
+
When all steps combined have not finished during the specified `timeout`, this method throws a
|
|
156
|
+
`TimeoutError`. Passing zero timeout disables this.
|
|
157
|
+
|
|
158
|
+
**NOTE**: `elementHandle.dblclick()` dispatches two `click` events and a single `dblclick` event.
|
|
159
|
+
|
|
160
|
+
## dispatch_event
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
def dispatch_event(type, eventInit: nil)
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element, `click`
|
|
168
|
+
is dispatched. This is equivalent to calling
|
|
169
|
+
[element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
|
|
170
|
+
|
|
171
|
+
**Usage**
|
|
172
|
+
|
|
173
|
+
```ruby
|
|
174
|
+
element_handle.dispatch_event("click")
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Under the hood, it creates an instance of an event based on the given `type`, initializes it with
|
|
178
|
+
`eventInit` properties and dispatches it on the element. Events are `composed`, `cancelable` and bubble by
|
|
179
|
+
default.
|
|
180
|
+
|
|
181
|
+
Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial
|
|
182
|
+
properties:
|
|
183
|
+
- [DeviceMotionEvent](https://developer.mozilla.org/en-US/docs/Web/API/DeviceMotionEvent/DeviceMotionEvent)
|
|
184
|
+
- [DeviceOrientationEvent](https://developer.mozilla.org/en-US/docs/Web/API/DeviceOrientationEvent/DeviceOrientationEvent)
|
|
185
|
+
- [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent)
|
|
186
|
+
- [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event/Event)
|
|
187
|
+
- [FocusEvent](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent)
|
|
188
|
+
- [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent)
|
|
189
|
+
- [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent)
|
|
190
|
+
- [PointerEvent](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/PointerEvent)
|
|
191
|
+
- [TouchEvent](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/TouchEvent)
|
|
192
|
+
- [WheelEvent](https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/WheelEvent)
|
|
193
|
+
|
|
194
|
+
You can also specify [JSHandle](./js_handle) as the property value if you want live objects to be passed into the event:
|
|
195
|
+
|
|
196
|
+
```ruby
|
|
197
|
+
data_transfer = page.evaluate_handle("new DataTransfer()")
|
|
198
|
+
element_handle.dispatch_event("dragstart", eventInit: { dataTransfer: data_transfer })
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## eval_on_selector
|
|
202
|
+
|
|
203
|
+
```
|
|
204
|
+
def eval_on_selector(selector, expression, arg: nil)
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
Returns the return value of `expression`.
|
|
209
|
+
|
|
210
|
+
The method finds an element matching the specified selector in the [ElementHandle](./element_handle)s subtree and passes it as a first
|
|
211
|
+
argument to `expression`. If no elements match the selector, the method throws an error.
|
|
212
|
+
|
|
213
|
+
If `expression` returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), then [ElementHandle#eval_on_selector](./element_handle#eval_on_selector) would wait for the promise to resolve and return its
|
|
214
|
+
value.
|
|
215
|
+
|
|
216
|
+
**Usage**
|
|
217
|
+
|
|
218
|
+
```ruby
|
|
219
|
+
tweet_handle = page.query_selector(".tweet")
|
|
220
|
+
tweet_handle.eval_on_selector(".like", "node => node.innerText") # => "100"
|
|
221
|
+
tweet_handle.eval_on_selector(".retweets", "node => node.innerText") # => "10"
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## eval_on_selector_all
|
|
225
|
+
|
|
226
|
+
```
|
|
227
|
+
def eval_on_selector_all(selector, expression, arg: nil)
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
Returns the return value of `expression`.
|
|
232
|
+
|
|
233
|
+
The method finds all elements matching the specified selector in the [ElementHandle](./element_handle)'s subtree and passes an array of
|
|
234
|
+
matched elements as a first argument to `expression`.
|
|
235
|
+
|
|
236
|
+
If `expression` returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), then [ElementHandle#eval_on_selector_all](./element_handle#eval_on_selector_all) would wait for the promise to resolve and return its
|
|
237
|
+
value.
|
|
238
|
+
|
|
239
|
+
**Usage**
|
|
240
|
+
|
|
241
|
+
```html
|
|
242
|
+
<div class="feed">
|
|
243
|
+
<div class="tweet">Hello!</div>
|
|
244
|
+
<div class="tweet">Hi!</div>
|
|
245
|
+
</div>
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
```ruby
|
|
249
|
+
feed_handle = page.query_selector(".feed")
|
|
250
|
+
feed_handle.eval_on_selector_all(".tweet", "nodes => nodes.map(n => n.innerText)") # => ["hello!", "hi!"]
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## fill
|
|
254
|
+
|
|
255
|
+
```
|
|
256
|
+
def fill(value, force: nil, noWaitAfter: nil, timeout: nil)
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
This method 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.
|
|
261
|
+
|
|
262
|
+
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.
|
|
263
|
+
|
|
264
|
+
To send fine-grained keyboard events, use [Locator#press_sequentially](./locator#press_sequentially).
|
|
265
|
+
|
|
266
|
+
## focus
|
|
267
|
+
|
|
268
|
+
```
|
|
269
|
+
def focus
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
Calls [focus](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the element.
|
|
274
|
+
|
|
275
|
+
## get_attribute
|
|
276
|
+
|
|
277
|
+
```
|
|
278
|
+
def get_attribute(name)
|
|
279
|
+
```
|
|
280
|
+
alias: `[]`
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
Returns element attribute value.
|
|
284
|
+
|
|
285
|
+
## hover
|
|
286
|
+
|
|
287
|
+
```
|
|
288
|
+
def hover(
|
|
289
|
+
force: nil,
|
|
290
|
+
modifiers: nil,
|
|
291
|
+
noWaitAfter: nil,
|
|
292
|
+
position: nil,
|
|
293
|
+
timeout: nil,
|
|
294
|
+
trial: nil)
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
This method hovers over the element by performing the following steps:
|
|
299
|
+
1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the element, unless `force` option is set.
|
|
300
|
+
1. Scroll the element into view if needed.
|
|
301
|
+
1. Use [Page#mouse](./page#mouse) to hover over the center of the element, or the specified `position`.
|
|
302
|
+
|
|
303
|
+
If the element is detached from the DOM at any moment during the action, this method throws.
|
|
304
|
+
|
|
305
|
+
When all steps combined have not finished during the specified `timeout`, this method throws a
|
|
306
|
+
`TimeoutError`. Passing zero timeout disables this.
|
|
307
|
+
|
|
308
|
+
## inner_html
|
|
309
|
+
|
|
310
|
+
```
|
|
311
|
+
def inner_html
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
Returns the `element.innerHTML`.
|
|
316
|
+
|
|
317
|
+
## inner_text
|
|
318
|
+
|
|
319
|
+
```
|
|
320
|
+
def inner_text
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
Returns the `element.innerText`.
|
|
325
|
+
|
|
326
|
+
## input_value
|
|
327
|
+
|
|
328
|
+
```
|
|
329
|
+
def input_value(timeout: nil)
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element.
|
|
334
|
+
|
|
335
|
+
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.
|
|
336
|
+
|
|
337
|
+
## checked?
|
|
338
|
+
|
|
339
|
+
```
|
|
340
|
+
def checked?
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
|
|
345
|
+
|
|
346
|
+
## disabled?
|
|
347
|
+
|
|
348
|
+
```
|
|
349
|
+
def disabled?
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
Returns whether the element is disabled, the opposite of [enabled](https://playwright.dev/python/docs/actionability#enabled).
|
|
354
|
+
|
|
355
|
+
## editable?
|
|
356
|
+
|
|
357
|
+
```
|
|
358
|
+
def editable?
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
Returns whether the element is [editable](https://playwright.dev/python/docs/actionability#editable).
|
|
363
|
+
|
|
364
|
+
## enabled?
|
|
365
|
+
|
|
366
|
+
```
|
|
367
|
+
def enabled?
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
Returns whether the element is [enabled](https://playwright.dev/python/docs/actionability#enabled).
|
|
372
|
+
|
|
373
|
+
## hidden?
|
|
374
|
+
|
|
375
|
+
```
|
|
376
|
+
def hidden?
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
Returns whether the element is hidden, the opposite of [visible](https://playwright.dev/python/docs/actionability#visible).
|
|
381
|
+
|
|
382
|
+
## visible?
|
|
383
|
+
|
|
384
|
+
```
|
|
385
|
+
def visible?
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
Returns whether the element is [visible](https://playwright.dev/python/docs/actionability#visible).
|
|
390
|
+
|
|
391
|
+
## owner_frame
|
|
392
|
+
|
|
393
|
+
```
|
|
394
|
+
def owner_frame
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
Returns the frame containing the given element.
|
|
399
|
+
|
|
400
|
+
## press
|
|
401
|
+
|
|
402
|
+
```
|
|
403
|
+
def press(key, delay: nil, noWaitAfter: nil, timeout: nil)
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
Focuses the element, and then uses [Keyboard#down](./keyboard#down) and [Keyboard#up](./keyboard#up).
|
|
408
|
+
|
|
409
|
+
`key` can specify the intended
|
|
410
|
+
[keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to
|
|
411
|
+
generate the text for. A superset of the `key` values can be found
|
|
412
|
+
[here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
|
|
413
|
+
|
|
414
|
+
`F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
|
|
415
|
+
`Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
|
|
416
|
+
|
|
417
|
+
Following modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`, `ControlOrMeta`.
|
|
418
|
+
|
|
419
|
+
Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
|
|
420
|
+
|
|
421
|
+
If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different
|
|
422
|
+
respective texts.
|
|
423
|
+
|
|
424
|
+
Shortcuts such as `key: "Control+o"`, `key: "Control++` or `key: "Control+Shift+T"` are supported as well. When specified with the
|
|
425
|
+
modifier, modifier is pressed and being held while the subsequent key is being pressed.
|
|
426
|
+
|
|
427
|
+
## query_selector
|
|
428
|
+
|
|
429
|
+
```
|
|
430
|
+
def query_selector(selector)
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
The method finds an element matching the specified selector in the [ElementHandle](./element_handle)'s subtree. If no elements match the selector,
|
|
435
|
+
returns `null`.
|
|
436
|
+
|
|
437
|
+
## query_selector_all
|
|
438
|
+
|
|
439
|
+
```
|
|
440
|
+
def query_selector_all(selector)
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
The method finds all elements matching the specified selector in the [ElementHandle](./element_handle)s subtree. If no elements match the selector,
|
|
445
|
+
returns empty array.
|
|
446
|
+
|
|
447
|
+
## screenshot
|
|
448
|
+
|
|
449
|
+
```
|
|
450
|
+
def screenshot(
|
|
451
|
+
animations: nil,
|
|
452
|
+
caret: nil,
|
|
453
|
+
mask: nil,
|
|
454
|
+
maskColor: nil,
|
|
455
|
+
omitBackground: nil,
|
|
456
|
+
path: nil,
|
|
457
|
+
quality: nil,
|
|
458
|
+
scale: nil,
|
|
459
|
+
style: nil,
|
|
460
|
+
timeout: nil,
|
|
461
|
+
type: nil)
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
This method captures a screenshot of the page, clipped to the size and position of this particular element. If the element is covered by other elements, it will not be actually visible on the screenshot. If the element is a scrollable container, only the currently scrolled content will be visible on the screenshot.
|
|
466
|
+
|
|
467
|
+
This method waits for the [actionability](https://playwright.dev/python/docs/actionability) checks, then scrolls element into view before taking a
|
|
468
|
+
screenshot. If the element is detached from DOM, the method throws an error.
|
|
469
|
+
|
|
470
|
+
Returns the buffer with the captured screenshot.
|
|
471
|
+
|
|
472
|
+
## scroll_into_view_if_needed
|
|
473
|
+
|
|
474
|
+
```
|
|
475
|
+
def scroll_into_view_if_needed(timeout: nil)
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
This method waits for [actionability](https://playwright.dev/python/docs/actionability) checks, then tries to scroll element into view, unless it is
|
|
480
|
+
completely visible as defined by
|
|
481
|
+
[IntersectionObserver](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API)'s `ratio`.
|
|
482
|
+
|
|
483
|
+
Throws when `elementHandle` does not point to an element
|
|
484
|
+
[connected](https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected) to a Document or a ShadowRoot.
|
|
485
|
+
|
|
486
|
+
See [scrolling](https://playwright.dev/python/docs/input#scrolling) for alternative ways to scroll.
|
|
487
|
+
|
|
488
|
+
## select_option
|
|
489
|
+
|
|
490
|
+
```
|
|
491
|
+
def select_option(
|
|
492
|
+
element: nil,
|
|
493
|
+
index: nil,
|
|
494
|
+
value: nil,
|
|
495
|
+
label: nil,
|
|
496
|
+
force: nil,
|
|
497
|
+
noWaitAfter: nil,
|
|
498
|
+
timeout: nil)
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
This method 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.
|
|
503
|
+
|
|
504
|
+
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.
|
|
505
|
+
|
|
506
|
+
Returns the array of option values that have been successfully selected.
|
|
507
|
+
|
|
508
|
+
Triggers a `change` and `input` event once all the provided options have been selected.
|
|
509
|
+
|
|
510
|
+
**Usage**
|
|
511
|
+
|
|
512
|
+
```ruby
|
|
513
|
+
# single selection matching the value
|
|
514
|
+
element_handle.select_option(value: "blue")
|
|
515
|
+
# single selection matching both the label
|
|
516
|
+
element_handle.select_option(label: "blue")
|
|
517
|
+
# multiple selection
|
|
518
|
+
element_handle.select_option(value: ["red", "green", "blue"])
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
## select_text
|
|
522
|
+
|
|
523
|
+
```
|
|
524
|
+
def select_text(force: nil, timeout: nil)
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
This method waits for [actionability](https://playwright.dev/python/docs/actionability) checks, then focuses the element and selects all its text
|
|
529
|
+
content.
|
|
530
|
+
|
|
531
|
+
If the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), focuses and selects text in the control instead.
|
|
532
|
+
|
|
533
|
+
## set_checked
|
|
534
|
+
|
|
535
|
+
```
|
|
536
|
+
def set_checked(
|
|
537
|
+
checked,
|
|
538
|
+
force: nil,
|
|
539
|
+
noWaitAfter: nil,
|
|
540
|
+
position: nil,
|
|
541
|
+
timeout: nil,
|
|
542
|
+
trial: nil)
|
|
543
|
+
```
|
|
544
|
+
alias: `checked=`
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
This method checks or unchecks an element by performing the following steps:
|
|
548
|
+
1. Ensure that element is a checkbox or a radio input. If not, this method throws.
|
|
549
|
+
1. If the element already has the right checked state, this method returns immediately.
|
|
550
|
+
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.
|
|
551
|
+
1. Scroll the element into view if needed.
|
|
552
|
+
1. Use [Page#mouse](./page#mouse) to click in the center of the element.
|
|
553
|
+
1. Ensure that the element is now checked or unchecked. If not, this method throws.
|
|
554
|
+
|
|
555
|
+
When all steps combined have not finished during the specified `timeout`, this method throws a
|
|
556
|
+
`TimeoutError`. Passing zero timeout disables this.
|
|
557
|
+
|
|
558
|
+
## set_input_files
|
|
559
|
+
|
|
560
|
+
```
|
|
561
|
+
def set_input_files(files, noWaitAfter: nil, timeout: nil)
|
|
562
|
+
```
|
|
563
|
+
alias: `input_files=`
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
|
|
567
|
+
are resolved relative to the current working directory. For empty array, clears the selected files.
|
|
568
|
+
For inputs with a `[webkitdirectory]` attribute, only a single directory path is supported.
|
|
569
|
+
|
|
570
|
+
This method expects [ElementHandle](./element_handle) to point to an
|
|
571
|
+
[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.
|
|
572
|
+
|
|
573
|
+
## tap_point
|
|
574
|
+
|
|
575
|
+
```
|
|
576
|
+
def tap_point(
|
|
577
|
+
force: nil,
|
|
578
|
+
modifiers: nil,
|
|
579
|
+
noWaitAfter: nil,
|
|
580
|
+
position: nil,
|
|
581
|
+
timeout: nil,
|
|
582
|
+
trial: nil)
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
This method taps the element by performing the following steps:
|
|
587
|
+
1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the element, unless `force` option is set.
|
|
588
|
+
1. Scroll the element into view if needed.
|
|
589
|
+
1. Use [Page#touchscreen](./page#touchscreen) to tap the center of the element, or the specified `position`.
|
|
590
|
+
|
|
591
|
+
If the element is detached from the DOM at any moment during the action, this method throws.
|
|
592
|
+
|
|
593
|
+
When all steps combined have not finished during the specified `timeout`, this method throws a
|
|
594
|
+
`TimeoutError`. Passing zero timeout disables this.
|
|
595
|
+
|
|
596
|
+
**NOTE**: `elementHandle.tap()` requires that the `hasTouch` option of the browser context be set to true.
|
|
597
|
+
|
|
598
|
+
## text_content
|
|
599
|
+
|
|
600
|
+
```
|
|
601
|
+
def text_content
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
Returns the `node.textContent`.
|
|
606
|
+
|
|
607
|
+
## type
|
|
608
|
+
|
|
609
|
+
```
|
|
610
|
+
def type(text, delay: nil, noWaitAfter: nil, timeout: nil)
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
:::warning
|
|
614
|
+
|
|
615
|
+
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).
|
|
616
|
+
|
|
617
|
+
:::
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
Focuses the element, and then sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
|
|
621
|
+
|
|
622
|
+
To press a special key, like `Control` or `ArrowDown`, use [ElementHandle#press](./element_handle#press).
|
|
623
|
+
|
|
624
|
+
**Usage**
|
|
625
|
+
|
|
626
|
+
## uncheck
|
|
627
|
+
|
|
628
|
+
```
|
|
629
|
+
def uncheck(
|
|
630
|
+
force: nil,
|
|
631
|
+
noWaitAfter: nil,
|
|
632
|
+
position: nil,
|
|
633
|
+
timeout: nil,
|
|
634
|
+
trial: nil)
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
|
|
638
|
+
This method checks the element by performing the following steps:
|
|
639
|
+
1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already unchecked, this method returns immediately.
|
|
640
|
+
1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the element, unless `force` option is set.
|
|
641
|
+
1. Scroll the element into view if needed.
|
|
642
|
+
1. Use [Page#mouse](./page#mouse) to click in the center of the element.
|
|
643
|
+
1. Ensure that the element is now unchecked. If not, this method throws.
|
|
644
|
+
|
|
645
|
+
If the element is detached from the DOM at any moment during the action, this method throws.
|
|
646
|
+
|
|
647
|
+
When all steps combined have not finished during the specified `timeout`, this method throws a
|
|
648
|
+
`TimeoutError`. Passing zero timeout disables this.
|
|
649
|
+
|
|
650
|
+
## wait_for_element_state
|
|
651
|
+
|
|
652
|
+
```
|
|
653
|
+
def wait_for_element_state(state, timeout: nil)
|
|
654
|
+
```
|
|
655
|
+
|
|
656
|
+
|
|
657
|
+
Returns when the element satisfies the `state`.
|
|
658
|
+
|
|
659
|
+
Depending on the `state` parameter, this method waits for one of the [actionability](https://playwright.dev/python/docs/actionability) checks
|
|
660
|
+
to pass. This method throws when the element is detached while waiting, unless waiting for the `"hidden"` state.
|
|
661
|
+
- `"visible"` Wait until the element is [visible](https://playwright.dev/python/docs/actionability#visible).
|
|
662
|
+
- `"hidden"` Wait until the element is [not visible](https://playwright.dev/python/docs/actionability#visible) or not attached. Note that waiting for hidden does not throw when the element detaches.
|
|
663
|
+
- `"stable"` Wait until the element is both [visible](https://playwright.dev/python/docs/actionability#visible) and [stable](https://playwright.dev/python/docs/actionability#stable).
|
|
664
|
+
- `"enabled"` Wait until the element is [enabled](https://playwright.dev/python/docs/actionability#enabled).
|
|
665
|
+
- `"disabled"` Wait until the element is [not enabled](https://playwright.dev/python/docs/actionability#enabled).
|
|
666
|
+
- `"editable"` Wait until the element is [editable](https://playwright.dev/python/docs/actionability#editable).
|
|
667
|
+
|
|
668
|
+
If the element does not satisfy the condition for the `timeout` milliseconds, this method will throw.
|
|
669
|
+
|
|
670
|
+
## wait_for_selector
|
|
671
|
+
|
|
672
|
+
```
|
|
673
|
+
def wait_for_selector(selector, state: nil, strict: nil, timeout: nil)
|
|
674
|
+
```
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
Returns element specified by selector when it satisfies `state` option. Returns `null` if waiting for `hidden`
|
|
678
|
+
or `detached`.
|
|
679
|
+
|
|
680
|
+
Wait for the `selector` relative to the element handle to satisfy `state` option (either
|
|
681
|
+
appear/disappear from dom, or become visible/hidden). If at the moment of calling the method `selector` already
|
|
682
|
+
satisfies the condition, the method will return immediately. If the selector doesn't satisfy the condition for the
|
|
683
|
+
`timeout` milliseconds, the function will throw.
|
|
684
|
+
|
|
685
|
+
**Usage**
|
|
686
|
+
|
|
687
|
+
```ruby
|
|
688
|
+
page.content = "<div><span></span></div>"
|
|
689
|
+
div = page.query_selector("div")
|
|
690
|
+
# waiting for the "span" selector relative to the div.
|
|
691
|
+
span = div.wait_for_selector("span", state: "attached")
|
|
692
|
+
```
|
|
693
|
+
|
|
694
|
+
**NOTE**: This method does not work across navigations, use [Page#wait_for_selector](./page#wait_for_selector) instead.
|