playwright-ruby-client 0.5.9 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/documentation/README.md +33 -0
- data/documentation/babel.config.js +3 -0
- data/documentation/docs/api/accessibility.md +7 -0
- data/documentation/docs/api/browser.md +187 -0
- data/documentation/docs/api/browser_context.md +397 -0
- data/documentation/docs/api/browser_type.md +105 -0
- data/documentation/docs/api/cdp_session.md +7 -0
- data/documentation/docs/api/console_message.md +41 -0
- data/documentation/docs/api/dialog.md +71 -0
- data/documentation/docs/api/element_handle.md +618 -0
- data/documentation/docs/api/experimental/_category_.yml +3 -0
- data/documentation/docs/api/experimental/android.md +25 -0
- data/documentation/docs/api/experimental/android_device.md +92 -0
- data/documentation/docs/api/experimental/android_input.md +38 -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 +50 -0
- data/documentation/docs/api/frame.md +866 -0
- data/documentation/docs/api/js_handle.md +113 -0
- data/documentation/docs/api/keyboard.md +157 -0
- data/documentation/docs/api/mouse.md +69 -0
- data/documentation/docs/api/page.md +1402 -0
- data/documentation/docs/api/playwright.md +63 -0
- data/documentation/docs/api/request.md +188 -0
- data/documentation/docs/api/response.md +97 -0
- data/documentation/docs/api/route.md +80 -0
- data/documentation/docs/api/selectors.md +23 -0
- data/documentation/docs/api/touchscreen.md +8 -0
- data/documentation/docs/api/tracing.md +54 -0
- data/documentation/docs/api/web_socket.md +7 -0
- data/documentation/docs/api/worker.md +24 -0
- data/documentation/docs/article/api_coverage.mdx +11 -0
- data/documentation/docs/article/getting_started.md +152 -0
- data/documentation/docs/article/guides/_category_.yml +3 -0
- data/documentation/docs/article/guides/download_playwright_driver.md +49 -0
- data/documentation/docs/article/guides/launch_browser.md +119 -0
- data/documentation/docs/article/guides/rails_integration.md +162 -0
- data/{docs → documentation/docs/include}/api_coverage.md +12 -1
- data/documentation/docusaurus.config.js +107 -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 +50 -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/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 +8805 -0
- data/lib/playwright/channel_owners/binding_call.rb +33 -0
- data/lib/playwright/channel_owners/browser.rb +11 -2
- data/lib/playwright/channel_owners/browser_context.rb +58 -6
- data/lib/playwright/channel_owners/browser_type.rb +8 -1
- data/lib/playwright/channel_owners/element_handle.rb +17 -16
- data/lib/playwright/channel_owners/frame.rb +24 -34
- data/lib/playwright/channel_owners/js_handle.rb +2 -10
- data/lib/playwright/channel_owners/page.rb +37 -52
- data/lib/playwright/channel_owners/worker.rb +4 -0
- data/lib/playwright/download.rb +3 -2
- data/lib/playwright/events.rb +4 -0
- data/lib/playwright/input_files.rb +0 -8
- data/lib/playwright/javascript.rb +0 -10
- data/lib/playwright/javascript/expression.rb +2 -7
- data/lib/playwright/playwright_api.rb +16 -1
- data/lib/playwright/tracing_impl.rb +31 -0
- data/lib/playwright/version.rb +2 -1
- data/lib/playwright_api/accessibility.rb +7 -88
- data/lib/playwright_api/android.rb +2 -59
- data/lib/playwright_api/android_device.rb +6 -5
- data/lib/playwright_api/browser.rb +13 -122
- data/lib/playwright_api/browser_context.rb +66 -433
- data/lib/playwright_api/browser_type.rb +28 -78
- data/lib/playwright_api/cdp_session.rb +2 -25
- data/lib/playwright_api/console_message.rb +2 -0
- data/lib/playwright_api/dialog.rb +5 -63
- data/lib/playwright_api/element_handle.rb +96 -294
- data/lib/playwright_api/file_chooser.rb +0 -21
- data/lib/playwright_api/frame.rb +98 -564
- data/lib/playwright_api/js_handle.rb +10 -67
- data/lib/playwright_api/keyboard.rb +22 -166
- data/lib/playwright_api/mouse.rb +1 -45
- data/lib/playwright_api/page.rb +223 -1224
- data/lib/playwright_api/playwright.rb +8 -93
- data/lib/playwright_api/request.rb +9 -87
- data/lib/playwright_api/response.rb +1 -1
- data/lib/playwright_api/route.rb +3 -80
- data/lib/playwright_api/selectors.rb +0 -66
- data/lib/playwright_api/tracing.rb +39 -0
- data/lib/playwright_api/web_socket.rb +1 -1
- data/lib/playwright_api/worker.rb +28 -42
- data/playwright.gemspec +2 -2
- metadata +60 -20
- data/lib/playwright/javascript/function.rb +0 -67
|
@@ -1,27 +1,6 @@
|
|
|
1
1
|
module Playwright
|
|
2
2
|
# `FileChooser` objects are dispatched by the page in the [`event: Page.fileChooser`] event.
|
|
3
|
-
#
|
|
4
3
|
#
|
|
5
|
-
# ```js
|
|
6
|
-
# const [fileChooser] = await Promise.all([
|
|
7
|
-
# page.waitForEvent('filechooser'),
|
|
8
|
-
# page.click('upload')
|
|
9
|
-
# ]);
|
|
10
|
-
# await fileChooser.setFiles('myfile.pdf');
|
|
11
|
-
# ```
|
|
12
|
-
#
|
|
13
|
-
# ```java
|
|
14
|
-
# FileChooser fileChooser = page.waitForFileChooser(() -> page.click("upload"));
|
|
15
|
-
# fileChooser.setFiles(Paths.get("myfile.pdf"));
|
|
16
|
-
# ```
|
|
17
|
-
#
|
|
18
|
-
# ```python async
|
|
19
|
-
# async with page.expect_file_chooser() as fc_info:
|
|
20
|
-
# await page.click("upload")
|
|
21
|
-
# file_chooser = await fc_info.value
|
|
22
|
-
# await file_chooser.set_files("myfile.pdf")
|
|
23
|
-
# ```
|
|
24
|
-
#
|
|
25
4
|
# ```python sync
|
|
26
5
|
# with page.expect_file_chooser() as fc_info:
|
|
27
6
|
# page.click("upload")
|
data/lib/playwright_api/frame.rb
CHANGED
|
@@ -1,85 +1,19 @@
|
|
|
1
1
|
module Playwright
|
|
2
2
|
# At every point of time, page exposes its current frame tree via the [`method: Page.mainFrame`] and
|
|
3
3
|
# [`method: Frame.childFrames`] methods.
|
|
4
|
-
#
|
|
4
|
+
#
|
|
5
5
|
# `Frame` object's lifecycle is controlled by three events, dispatched on the page object:
|
|
6
6
|
# - [`event: Page.frameAttached`] - fired when the frame gets attached to the page. A Frame can be attached to the page
|
|
7
7
|
# only once.
|
|
8
8
|
# - [`event: Page.frameNavigated`] - fired when the frame commits navigation to a different URL.
|
|
9
9
|
# - [`event: Page.frameDetached`] - fired when the frame gets detached from the page. A Frame can be detached from the
|
|
10
10
|
# page only once.
|
|
11
|
-
#
|
|
11
|
+
#
|
|
12
12
|
# An example of dumping frame tree:
|
|
13
|
-
#
|
|
14
13
|
#
|
|
15
|
-
# ```js
|
|
16
|
-
# const { firefox } = require('playwright'); // Or 'chromium' or 'webkit'.
|
|
17
|
-
#
|
|
18
|
-
# (async () => {
|
|
19
|
-
# const browser = await firefox.launch();
|
|
20
|
-
# const page = await browser.newPage();
|
|
21
|
-
# await page.goto('https://www.google.com/chrome/browser/canary.html');
|
|
22
|
-
# dumpFrameTree(page.mainFrame(), '');
|
|
23
|
-
# await browser.close();
|
|
24
|
-
#
|
|
25
|
-
# function dumpFrameTree(frame, indent) {
|
|
26
|
-
# console.log(indent + frame.url());
|
|
27
|
-
# for (const child of frame.childFrames()) {
|
|
28
|
-
# dumpFrameTree(child, indent + ' ');
|
|
29
|
-
# }
|
|
30
|
-
# }
|
|
31
|
-
# })();
|
|
32
|
-
# ```
|
|
33
|
-
#
|
|
34
|
-
# ```java
|
|
35
|
-
# import com.microsoft.playwright.*;
|
|
36
|
-
#
|
|
37
|
-
# public class Example {
|
|
38
|
-
# public static void main(String[] args) {
|
|
39
|
-
# try (Playwright playwright = Playwright.create()) {
|
|
40
|
-
# BrowserType firefox = playwright.firefox();
|
|
41
|
-
# Browser browser = firefox.launch();
|
|
42
|
-
# Page page = browser.newPage();
|
|
43
|
-
# page.navigate("https://www.google.com/chrome/browser/canary.html");
|
|
44
|
-
# dumpFrameTree(page.mainFrame(), "");
|
|
45
|
-
# browser.close();
|
|
46
|
-
# }
|
|
47
|
-
# }
|
|
48
|
-
# static void dumpFrameTree(Frame frame, String indent) {
|
|
49
|
-
# System.out.println(indent + frame.url());
|
|
50
|
-
# for (Frame child : frame.childFrames()) {
|
|
51
|
-
# dumpFrameTree(child, indent + " ");
|
|
52
|
-
# }
|
|
53
|
-
# }
|
|
54
|
-
# }
|
|
55
|
-
# ```
|
|
56
|
-
#
|
|
57
|
-
# ```python async
|
|
58
|
-
# import asyncio
|
|
59
|
-
# from playwright.async_api import async_playwright
|
|
60
|
-
#
|
|
61
|
-
# async def run(playwright):
|
|
62
|
-
# firefox = playwright.firefox
|
|
63
|
-
# browser = await firefox.launch()
|
|
64
|
-
# page = await browser.new_page()
|
|
65
|
-
# await page.goto("https://www.theverge.com")
|
|
66
|
-
# dump_frame_tree(page.main_frame, "")
|
|
67
|
-
# await browser.close()
|
|
68
|
-
#
|
|
69
|
-
# def dump_frame_tree(frame, indent):
|
|
70
|
-
# print(indent + frame.name + '@' + frame.url)
|
|
71
|
-
# for child in frame.child_frames:
|
|
72
|
-
# dump_frame_tree(child, indent + " ")
|
|
73
|
-
#
|
|
74
|
-
# async def main():
|
|
75
|
-
# async with async_playwright() as playwright:
|
|
76
|
-
# await run(playwright)
|
|
77
|
-
# asyncio.run(main())
|
|
78
|
-
# ```
|
|
79
|
-
#
|
|
80
14
|
# ```python sync
|
|
81
15
|
# from playwright.sync_api import sync_playwright
|
|
82
|
-
#
|
|
16
|
+
#
|
|
83
17
|
# def run(playwright):
|
|
84
18
|
# firefox = playwright.firefox
|
|
85
19
|
# browser = firefox.launch()
|
|
@@ -87,26 +21,26 @@ module Playwright
|
|
|
87
21
|
# page.goto("https://www.theverge.com")
|
|
88
22
|
# dump_frame_tree(page.main_frame, "")
|
|
89
23
|
# browser.close()
|
|
90
|
-
#
|
|
24
|
+
#
|
|
91
25
|
# def dump_frame_tree(frame, indent):
|
|
92
26
|
# print(indent + frame.name + '@' + frame.url)
|
|
93
27
|
# for child in frame.child_frames:
|
|
94
28
|
# dump_frame_tree(child, indent + " ")
|
|
95
|
-
#
|
|
29
|
+
#
|
|
96
30
|
# with sync_playwright() as playwright:
|
|
97
31
|
# run(playwright)
|
|
98
32
|
# ```
|
|
99
33
|
class Frame < PlaywrightApi
|
|
100
34
|
|
|
101
35
|
# Returns the added tag when the script's onload fires or when the script content was injected into frame.
|
|
102
|
-
#
|
|
36
|
+
#
|
|
103
37
|
# Adds a `<script>` tag into the page with the desired url or content.
|
|
104
38
|
def add_script_tag(content: nil, path: nil, type: nil, url: nil)
|
|
105
39
|
wrap_impl(@impl.add_script_tag(content: unwrap_impl(content), path: unwrap_impl(path), type: unwrap_impl(type), url: unwrap_impl(url)))
|
|
106
40
|
end
|
|
107
41
|
|
|
108
42
|
# Returns the added tag when the stylesheet's onload fires or when the CSS content was injected into frame.
|
|
109
|
-
#
|
|
43
|
+
#
|
|
110
44
|
# Adds a `<link rel="stylesheet">` tag into the page with the desired url or a `<style type="text/css">` tag with the
|
|
111
45
|
# content.
|
|
112
46
|
def add_style_tag(content: nil, path: nil, url: nil)
|
|
@@ -123,7 +57,7 @@ module Playwright
|
|
|
123
57
|
# 1. Use [`property: Page.mouse`] to click in the center of the element.
|
|
124
58
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
|
125
59
|
# 1. Ensure that the element is now checked. If not, this method throws.
|
|
126
|
-
#
|
|
60
|
+
#
|
|
127
61
|
# When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
|
|
128
62
|
# zero timeout disables this.
|
|
129
63
|
def check(
|
|
@@ -131,8 +65,9 @@ module Playwright
|
|
|
131
65
|
force: nil,
|
|
132
66
|
noWaitAfter: nil,
|
|
133
67
|
position: nil,
|
|
134
|
-
timeout: nil
|
|
135
|
-
|
|
68
|
+
timeout: nil,
|
|
69
|
+
trial: nil)
|
|
70
|
+
wrap_impl(@impl.check(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
|
136
71
|
end
|
|
137
72
|
|
|
138
73
|
def child_frames
|
|
@@ -146,7 +81,7 @@ module Playwright
|
|
|
146
81
|
# 1. Scroll the element into view if needed.
|
|
147
82
|
# 1. Use [`property: Page.mouse`] to click in the center of the element, or the specified `position`.
|
|
148
83
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
|
149
|
-
#
|
|
84
|
+
#
|
|
150
85
|
# When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
|
|
151
86
|
# zero timeout disables this.
|
|
152
87
|
def click(
|
|
@@ -158,8 +93,9 @@ module Playwright
|
|
|
158
93
|
modifiers: nil,
|
|
159
94
|
noWaitAfter: nil,
|
|
160
95
|
position: nil,
|
|
161
|
-
timeout: nil
|
|
162
|
-
|
|
96
|
+
timeout: nil,
|
|
97
|
+
trial: nil)
|
|
98
|
+
wrap_impl(@impl.click(unwrap_impl(selector), button: unwrap_impl(button), clickCount: unwrap_impl(clickCount), delay: unwrap_impl(delay), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
|
163
99
|
end
|
|
164
100
|
|
|
165
101
|
# Gets the full HTML contents of the frame, including the doctype.
|
|
@@ -175,10 +111,10 @@ module Playwright
|
|
|
175
111
|
# 1. Use [`property: Page.mouse`] to double click in the center of the element, or the specified `position`.
|
|
176
112
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the
|
|
177
113
|
# first click of the `dblclick()` triggers a navigation event, this method will throw.
|
|
178
|
-
#
|
|
114
|
+
#
|
|
179
115
|
# When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
|
|
180
116
|
# zero timeout disables this.
|
|
181
|
-
#
|
|
117
|
+
#
|
|
182
118
|
# > NOTE: `frame.dblclick()` dispatches two `click` events and a single `dblclick` event.
|
|
183
119
|
def dblclick(
|
|
184
120
|
selector,
|
|
@@ -188,34 +124,22 @@ module Playwright
|
|
|
188
124
|
modifiers: nil,
|
|
189
125
|
noWaitAfter: nil,
|
|
190
126
|
position: nil,
|
|
191
|
-
timeout: nil
|
|
192
|
-
|
|
127
|
+
timeout: nil,
|
|
128
|
+
trial: nil)
|
|
129
|
+
wrap_impl(@impl.dblclick(unwrap_impl(selector), button: unwrap_impl(button), delay: unwrap_impl(delay), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
|
193
130
|
end
|
|
194
131
|
|
|
195
132
|
# The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element,
|
|
196
133
|
# `click` is dispatched. This is equivalent to calling
|
|
197
134
|
# [element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
|
|
198
|
-
#
|
|
199
135
|
#
|
|
200
|
-
# ```js
|
|
201
|
-
# await frame.dispatchEvent('button#submit', 'click');
|
|
202
|
-
# ```
|
|
203
|
-
#
|
|
204
|
-
# ```java
|
|
205
|
-
# frame.dispatchEvent("button#submit", "click");
|
|
206
|
-
# ```
|
|
207
|
-
#
|
|
208
|
-
# ```python async
|
|
209
|
-
# await frame.dispatch_event("button#submit", "click")
|
|
210
|
-
# ```
|
|
211
|
-
#
|
|
212
136
|
# ```python sync
|
|
213
137
|
# frame.dispatch_event("button#submit", "click")
|
|
214
138
|
# ```
|
|
215
|
-
#
|
|
139
|
+
#
|
|
216
140
|
# Under the hood, it creates an instance of an event based on the given `type`, initializes it with `eventInit` properties
|
|
217
141
|
# and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default.
|
|
218
|
-
#
|
|
142
|
+
#
|
|
219
143
|
# Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial properties:
|
|
220
144
|
# - [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent)
|
|
221
145
|
# - [FocusEvent](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent)
|
|
@@ -224,30 +148,9 @@ module Playwright
|
|
|
224
148
|
# - [PointerEvent](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/PointerEvent)
|
|
225
149
|
# - [TouchEvent](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/TouchEvent)
|
|
226
150
|
# - [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event/Event)
|
|
227
|
-
#
|
|
151
|
+
#
|
|
228
152
|
# You can also specify `JSHandle` as the property value if you want live objects to be passed into the event:
|
|
229
|
-
#
|
|
230
153
|
#
|
|
231
|
-
# ```js
|
|
232
|
-
# // Note you can only create DataTransfer in Chromium and Firefox
|
|
233
|
-
# const dataTransfer = await frame.evaluateHandle(() => new DataTransfer());
|
|
234
|
-
# await frame.dispatchEvent('#source', 'dragstart', { dataTransfer });
|
|
235
|
-
# ```
|
|
236
|
-
#
|
|
237
|
-
# ```java
|
|
238
|
-
# // Note you can only create DataTransfer in Chromium and Firefox
|
|
239
|
-
# JSHandle dataTransfer = frame.evaluateHandle("() => new DataTransfer()");
|
|
240
|
-
# Map<String, Object> arg = new HashMap<>();
|
|
241
|
-
# arg.put("dataTransfer", dataTransfer);
|
|
242
|
-
# frame.dispatchEvent("#source", "dragstart", arg);
|
|
243
|
-
# ```
|
|
244
|
-
#
|
|
245
|
-
# ```python async
|
|
246
|
-
# # note you can only create data_transfer in chromium and firefox
|
|
247
|
-
# data_transfer = await frame.evaluate_handle("new DataTransfer()")
|
|
248
|
-
# await frame.dispatch_event("#source", "dragstart", { "dataTransfer": data_transfer })
|
|
249
|
-
# ```
|
|
250
|
-
#
|
|
251
154
|
# ```python sync
|
|
252
155
|
# # note you can only create data_transfer in chromium and firefox
|
|
253
156
|
# data_transfer = frame.evaluate_handle("new DataTransfer()")
|
|
@@ -258,35 +161,16 @@ module Playwright
|
|
|
258
161
|
end
|
|
259
162
|
|
|
260
163
|
# Returns the return value of `expression`.
|
|
261
|
-
#
|
|
164
|
+
#
|
|
262
165
|
# The method finds an element matching the specified selector within the frame and passes it as a first argument to
|
|
263
166
|
# `expression`. See [Working with selectors](./selectors.md) for more details. If no elements match the selector, the
|
|
264
167
|
# method throws an error.
|
|
265
|
-
#
|
|
168
|
+
#
|
|
266
169
|
# If `expression` returns a [Promise], then [`method: Frame.evalOnSelector`] would wait for the promise to resolve and
|
|
267
170
|
# return its value.
|
|
268
|
-
#
|
|
171
|
+
#
|
|
269
172
|
# Examples:
|
|
270
|
-
#
|
|
271
173
|
#
|
|
272
|
-
# ```js
|
|
273
|
-
# const searchValue = await frame.$eval('#search', el => el.value);
|
|
274
|
-
# const preloadHref = await frame.$eval('link[rel=preload]', el => el.href);
|
|
275
|
-
# const html = await frame.$eval('.main-container', (e, suffix) => e.outerHTML + suffix, 'hello');
|
|
276
|
-
# ```
|
|
277
|
-
#
|
|
278
|
-
# ```java
|
|
279
|
-
# String searchValue = (String) frame.evalOnSelector("#search", "el => el.value");
|
|
280
|
-
# String preloadHref = (String) frame.evalOnSelector("link[rel=preload]", "el => el.href");
|
|
281
|
-
# String html = (String) frame.evalOnSelector(".main-container", "(e, suffix) => e.outerHTML + suffix", "hello");
|
|
282
|
-
# ```
|
|
283
|
-
#
|
|
284
|
-
# ```python async
|
|
285
|
-
# search_value = await frame.eval_on_selector("#search", "el => el.value")
|
|
286
|
-
# preload_href = await frame.eval_on_selector("link[rel=preload]", "el => el.href")
|
|
287
|
-
# html = await frame.eval_on_selector(".main-container", "(e, suffix) => e.outerHTML + suffix", "hello")
|
|
288
|
-
# ```
|
|
289
|
-
#
|
|
290
174
|
# ```python sync
|
|
291
175
|
# search_value = frame.eval_on_selector("#search", "el => el.value")
|
|
292
176
|
# preload_href = frame.eval_on_selector("link[rel=preload]", "el => el.href")
|
|
@@ -297,28 +181,15 @@ module Playwright
|
|
|
297
181
|
end
|
|
298
182
|
|
|
299
183
|
# Returns the return value of `expression`.
|
|
300
|
-
#
|
|
184
|
+
#
|
|
301
185
|
# The method finds all elements matching the specified selector within the frame and passes an array of matched elements
|
|
302
186
|
# as a first argument to `expression`. See [Working with selectors](./selectors.md) for more details.
|
|
303
|
-
#
|
|
187
|
+
#
|
|
304
188
|
# If `expression` returns a [Promise], then [`method: Frame.evalOnSelectorAll`] would wait for the promise to resolve and
|
|
305
189
|
# return its value.
|
|
306
|
-
#
|
|
190
|
+
#
|
|
307
191
|
# Examples:
|
|
308
|
-
#
|
|
309
192
|
#
|
|
310
|
-
# ```js
|
|
311
|
-
# const divsCounts = await frame.$$eval('div', (divs, min) => divs.length >= min, 10);
|
|
312
|
-
# ```
|
|
313
|
-
#
|
|
314
|
-
# ```java
|
|
315
|
-
# boolean divsCounts = (boolean) page.evalOnSelectorAll("div", "(divs, min) => divs.length >= min", 10);
|
|
316
|
-
# ```
|
|
317
|
-
#
|
|
318
|
-
# ```python async
|
|
319
|
-
# divs_counts = await frame.eval_on_selector_all("div", "(divs, min) => divs.length >= min", 10)
|
|
320
|
-
# ```
|
|
321
|
-
#
|
|
322
193
|
# ```python sync
|
|
323
194
|
# divs_counts = frame.eval_on_selector_all("div", "(divs, min) => divs.length >= min", 10)
|
|
324
195
|
# ```
|
|
@@ -327,83 +198,29 @@ module Playwright
|
|
|
327
198
|
end
|
|
328
199
|
|
|
329
200
|
# Returns the return value of `expression`.
|
|
330
|
-
#
|
|
201
|
+
#
|
|
331
202
|
# If the function passed to the [`method: Frame.evaluate`] returns a [Promise], then [`method: Frame.evaluate`] would wait
|
|
332
203
|
# for the promise to resolve and return its value.
|
|
333
|
-
#
|
|
204
|
+
#
|
|
334
205
|
# If the function passed to the [`method: Frame.evaluate`] returns a non-[Serializable] value, then
|
|
335
206
|
# [`method: Frame.evaluate`] returns `undefined`. Playwright also supports transferring some additional values that are
|
|
336
207
|
# not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`.
|
|
337
|
-
#
|
|
338
208
|
#
|
|
339
|
-
# ```js
|
|
340
|
-
# const result = await frame.evaluate(([x, y]) => {
|
|
341
|
-
# return Promise.resolve(x * y);
|
|
342
|
-
# }, [7, 8]);
|
|
343
|
-
# console.log(result); // prints "56"
|
|
344
|
-
# ```
|
|
345
|
-
#
|
|
346
|
-
# ```java
|
|
347
|
-
# Object result = frame.evaluate("([x, y]) => {\n" +
|
|
348
|
-
# " return Promise.resolve(x * y);\n" +
|
|
349
|
-
# "}", Arrays.asList(7, 8));
|
|
350
|
-
# System.out.println(result); // prints "56"
|
|
351
|
-
# ```
|
|
352
|
-
#
|
|
353
|
-
# ```python async
|
|
354
|
-
# result = await frame.evaluate("([x, y]) => Promise.resolve(x * y)", [7, 8])
|
|
355
|
-
# print(result) # prints "56"
|
|
356
|
-
# ```
|
|
357
|
-
#
|
|
358
209
|
# ```python sync
|
|
359
210
|
# result = frame.evaluate("([x, y]) => Promise.resolve(x * y)", [7, 8])
|
|
360
211
|
# print(result) # prints "56"
|
|
361
212
|
# ```
|
|
362
|
-
#
|
|
213
|
+
#
|
|
363
214
|
# A string can also be passed in instead of a function.
|
|
364
|
-
#
|
|
365
215
|
#
|
|
366
|
-
# ```js
|
|
367
|
-
# console.log(await frame.evaluate('1 + 2')); // prints "3"
|
|
368
|
-
# ```
|
|
369
|
-
#
|
|
370
|
-
# ```java
|
|
371
|
-
# System.out.println(frame.evaluate("1 + 2")); // prints "3"
|
|
372
|
-
# ```
|
|
373
|
-
#
|
|
374
|
-
# ```python async
|
|
375
|
-
# print(await frame.evaluate("1 + 2")) # prints "3"
|
|
376
|
-
# x = 10
|
|
377
|
-
# print(await frame.evaluate(f"1 + {x}")) # prints "11"
|
|
378
|
-
# ```
|
|
379
|
-
#
|
|
380
216
|
# ```python sync
|
|
381
217
|
# print(frame.evaluate("1 + 2")) # prints "3"
|
|
382
218
|
# x = 10
|
|
383
219
|
# print(frame.evaluate(f"1 + {x}")) # prints "11"
|
|
384
220
|
# ```
|
|
385
|
-
#
|
|
221
|
+
#
|
|
386
222
|
# `ElementHandle` instances can be passed as an argument to the [`method: Frame.evaluate`]:
|
|
387
|
-
#
|
|
388
223
|
#
|
|
389
|
-
# ```js
|
|
390
|
-
# const bodyHandle = await frame.$('body');
|
|
391
|
-
# const html = await frame.evaluate(([body, suffix]) => body.innerHTML + suffix, [bodyHandle, 'hello']);
|
|
392
|
-
# await bodyHandle.dispose();
|
|
393
|
-
# ```
|
|
394
|
-
#
|
|
395
|
-
# ```java
|
|
396
|
-
# ElementHandle bodyHandle = frame.querySelector("body");
|
|
397
|
-
# String html = (String) frame.evaluate("([body, suffix]) => body.innerHTML + suffix", Arrays.asList(bodyHandle, "hello"));
|
|
398
|
-
# bodyHandle.dispose();
|
|
399
|
-
# ```
|
|
400
|
-
#
|
|
401
|
-
# ```python async
|
|
402
|
-
# body_handle = await frame.query_selector("body")
|
|
403
|
-
# html = await frame.evaluate("([body, suffix]) => body.innerHTML + suffix", [body_handle, "hello"])
|
|
404
|
-
# await body_handle.dispose()
|
|
405
|
-
# ```
|
|
406
|
-
#
|
|
407
224
|
# ```python sync
|
|
408
225
|
# body_handle = frame.query_selector("body")
|
|
409
226
|
# html = frame.evaluate("([body, suffix]) => body.innerHTML + suffix", [body_handle, "hello"])
|
|
@@ -414,77 +231,26 @@ module Playwright
|
|
|
414
231
|
end
|
|
415
232
|
|
|
416
233
|
# Returns the return value of `expression` as a `JSHandle`.
|
|
417
|
-
#
|
|
234
|
+
#
|
|
418
235
|
# The only difference between [`method: Frame.evaluate`] and [`method: Frame.evaluateHandle`] is that
|
|
419
236
|
# [`method: Frame.evaluateHandle`] returns `JSHandle`.
|
|
420
|
-
#
|
|
237
|
+
#
|
|
421
238
|
# If the function, passed to the [`method: Frame.evaluateHandle`], returns a [Promise], then
|
|
422
239
|
# [`method: Frame.evaluateHandle`] would wait for the promise to resolve and return its value.
|
|
423
|
-
#
|
|
424
240
|
#
|
|
425
|
-
# ```js
|
|
426
|
-
# const aWindowHandle = await frame.evaluateHandle(() => Promise.resolve(window));
|
|
427
|
-
# aWindowHandle; // Handle for the window object.
|
|
428
|
-
# ```
|
|
429
|
-
#
|
|
430
|
-
# ```java
|
|
431
|
-
# // Handle for the window object.
|
|
432
|
-
# JSHandle aWindowHandle = frame.evaluateHandle("() => Promise.resolve(window)");
|
|
433
|
-
# ```
|
|
434
|
-
#
|
|
435
|
-
# ```python async
|
|
436
|
-
# a_window_handle = await frame.evaluate_handle("Promise.resolve(window)")
|
|
437
|
-
# a_window_handle # handle for the window object.
|
|
438
|
-
# ```
|
|
439
|
-
#
|
|
440
241
|
# ```python sync
|
|
441
242
|
# a_window_handle = frame.evaluate_handle("Promise.resolve(window)")
|
|
442
243
|
# a_window_handle # handle for the window object.
|
|
443
244
|
# ```
|
|
444
|
-
#
|
|
245
|
+
#
|
|
445
246
|
# A string can also be passed in instead of a function.
|
|
446
|
-
#
|
|
447
247
|
#
|
|
448
|
-
# ```js
|
|
449
|
-
# const aHandle = await frame.evaluateHandle('document'); // Handle for the 'document'.
|
|
450
|
-
# ```
|
|
451
|
-
#
|
|
452
|
-
# ```java
|
|
453
|
-
# JSHandle aHandle = frame.evaluateHandle("document"); // Handle for the "document".
|
|
454
|
-
# ```
|
|
455
|
-
#
|
|
456
|
-
# ```python async
|
|
457
|
-
# a_handle = await page.evaluate_handle("document") # handle for the "document"
|
|
458
|
-
# ```
|
|
459
|
-
#
|
|
460
248
|
# ```python sync
|
|
461
249
|
# a_handle = page.evaluate_handle("document") # handle for the "document"
|
|
462
250
|
# ```
|
|
463
|
-
#
|
|
251
|
+
#
|
|
464
252
|
# `JSHandle` instances can be passed as an argument to the [`method: Frame.evaluateHandle`]:
|
|
465
|
-
#
|
|
466
253
|
#
|
|
467
|
-
# ```js
|
|
468
|
-
# const aHandle = await frame.evaluateHandle(() => document.body);
|
|
469
|
-
# const resultHandle = await frame.evaluateHandle(([body, suffix]) => body.innerHTML + suffix, [aHandle, 'hello']);
|
|
470
|
-
# console.log(await resultHandle.jsonValue());
|
|
471
|
-
# await resultHandle.dispose();
|
|
472
|
-
# ```
|
|
473
|
-
#
|
|
474
|
-
# ```java
|
|
475
|
-
# JSHandle aHandle = frame.evaluateHandle("() => document.body");
|
|
476
|
-
# JSHandle resultHandle = frame.evaluateHandle("([body, suffix]) => body.innerHTML + suffix", Arrays.asList(aHandle, "hello"));
|
|
477
|
-
# System.out.println(resultHandle.jsonValue());
|
|
478
|
-
# resultHandle.dispose();
|
|
479
|
-
# ```
|
|
480
|
-
#
|
|
481
|
-
# ```python async
|
|
482
|
-
# a_handle = await page.evaluate_handle("document.body")
|
|
483
|
-
# result_handle = await page.evaluate_handle("body => body.innerHTML", a_handle)
|
|
484
|
-
# print(await result_handle.json_value())
|
|
485
|
-
# await result_handle.dispose()
|
|
486
|
-
# ```
|
|
487
|
-
#
|
|
488
254
|
# ```python sync
|
|
489
255
|
# a_handle = page.evaluate_handle("document.body")
|
|
490
256
|
# result_handle = page.evaluate_handle("body => body.innerHTML", a_handle)
|
|
@@ -496,11 +262,14 @@ module Playwright
|
|
|
496
262
|
end
|
|
497
263
|
|
|
498
264
|
# This method waits for an element matching `selector`, waits for [actionability](./actionability.md) checks, focuses the
|
|
499
|
-
# element, fills it and triggers an `input` event after filling.
|
|
500
|
-
#
|
|
501
|
-
#
|
|
502
|
-
#
|
|
503
|
-
#
|
|
265
|
+
# element, fills it and triggers an `input` event after filling. Note that you can pass an empty string to clear the input
|
|
266
|
+
# field.
|
|
267
|
+
#
|
|
268
|
+
# If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error.
|
|
269
|
+
# However, if the element is inside the `<label>` element that has an associated
|
|
270
|
+
# [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled
|
|
271
|
+
# instead.
|
|
272
|
+
#
|
|
504
273
|
# To send fine-grained keyboard events, use [`method: Frame.type`].
|
|
505
274
|
def fill(selector, value, noWaitAfter: nil, timeout: nil)
|
|
506
275
|
wrap_impl(@impl.fill(unwrap_impl(selector), unwrap_impl(value), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
|
@@ -513,31 +282,12 @@ module Playwright
|
|
|
513
282
|
end
|
|
514
283
|
|
|
515
284
|
# Returns the `frame` or `iframe` element handle which corresponds to this frame.
|
|
516
|
-
#
|
|
285
|
+
#
|
|
517
286
|
# This is an inverse of [`method: ElementHandle.contentFrame`]. Note that returned handle actually belongs to the parent
|
|
518
287
|
# frame.
|
|
519
|
-
#
|
|
288
|
+
#
|
|
520
289
|
# This method throws an error if the frame has been detached before `frameElement()` returns.
|
|
521
|
-
#
|
|
522
290
|
#
|
|
523
|
-
# ```js
|
|
524
|
-
# const frameElement = await frame.frameElement();
|
|
525
|
-
# const contentFrame = await frameElement.contentFrame();
|
|
526
|
-
# console.log(frame === contentFrame); // -> true
|
|
527
|
-
# ```
|
|
528
|
-
#
|
|
529
|
-
# ```java
|
|
530
|
-
# ElementHandle frameElement = frame.frameElement();
|
|
531
|
-
# Frame contentFrame = frameElement.contentFrame();
|
|
532
|
-
# System.out.println(frame == contentFrame); // -> true
|
|
533
|
-
# ```
|
|
534
|
-
#
|
|
535
|
-
# ```python async
|
|
536
|
-
# frame_element = await frame.frame_element()
|
|
537
|
-
# content_frame = await frame_element.content_frame()
|
|
538
|
-
# assert frame == content_frame
|
|
539
|
-
# ```
|
|
540
|
-
#
|
|
541
291
|
# ```python sync
|
|
542
292
|
# frame_element = frame.frame_element()
|
|
543
293
|
# content_frame = frame_element.content_frame()
|
|
@@ -554,18 +304,18 @@ module Playwright
|
|
|
554
304
|
|
|
555
305
|
# Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
|
|
556
306
|
# last redirect.
|
|
557
|
-
#
|
|
307
|
+
#
|
|
558
308
|
# `frame.goto` will throw an error if:
|
|
559
309
|
# - there's an SSL error (e.g. in case of self-signed certificates).
|
|
560
310
|
# - target URL is invalid.
|
|
561
311
|
# - the `timeout` is exceeded during navigation.
|
|
562
312
|
# - the remote server does not respond or is unreachable.
|
|
563
313
|
# - the main resource failed to load.
|
|
564
|
-
#
|
|
314
|
+
#
|
|
565
315
|
# `frame.goto` will not throw an error when any valid HTTP status code is returned by the remote server, including 404
|
|
566
316
|
# "Not Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling
|
|
567
317
|
# [`method: Response.status`].
|
|
568
|
-
#
|
|
318
|
+
#
|
|
569
319
|
# > NOTE: `frame.goto` either throws an error or returns a main resource response. The only exceptions are navigation to
|
|
570
320
|
# `about:blank` or navigation to the same URL with a different hash, which would succeed and return `null`.
|
|
571
321
|
# > NOTE: Headless mode doesn't support navigation to a PDF document. See the
|
|
@@ -581,7 +331,7 @@ module Playwright
|
|
|
581
331
|
# 1. Scroll the element into view if needed.
|
|
582
332
|
# 1. Use [`property: Page.mouse`] to hover over the center of the element, or the specified `position`.
|
|
583
333
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
|
584
|
-
#
|
|
334
|
+
#
|
|
585
335
|
# When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
|
|
586
336
|
# zero timeout disables this.
|
|
587
337
|
def hover(
|
|
@@ -589,8 +339,9 @@ module Playwright
|
|
|
589
339
|
force: nil,
|
|
590
340
|
modifiers: nil,
|
|
591
341
|
position: nil,
|
|
592
|
-
timeout: nil
|
|
593
|
-
|
|
342
|
+
timeout: nil,
|
|
343
|
+
trial: nil)
|
|
344
|
+
wrap_impl(@impl.hover(unwrap_impl(selector), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
|
594
345
|
end
|
|
595
346
|
|
|
596
347
|
# Returns `element.innerHTML`.
|
|
@@ -641,9 +392,9 @@ module Playwright
|
|
|
641
392
|
end
|
|
642
393
|
|
|
643
394
|
# Returns frame's name attribute as specified in the tag.
|
|
644
|
-
#
|
|
395
|
+
#
|
|
645
396
|
# If the name is empty, returns the id attribute instead.
|
|
646
|
-
#
|
|
397
|
+
#
|
|
647
398
|
# > NOTE: This value is calculated once when the frame is created, and will not update if the attribute is changed later.
|
|
648
399
|
def name
|
|
649
400
|
wrap_impl(@impl.name)
|
|
@@ -662,17 +413,17 @@ module Playwright
|
|
|
662
413
|
# `key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)
|
|
663
414
|
# value or a single character to generate the text for. A superset of the `key` values can be found
|
|
664
415
|
# [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
|
|
665
|
-
#
|
|
416
|
+
#
|
|
666
417
|
# `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
|
|
667
418
|
# `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
|
|
668
|
-
#
|
|
419
|
+
#
|
|
669
420
|
# Following modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`.
|
|
670
|
-
#
|
|
421
|
+
#
|
|
671
422
|
# Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
|
|
672
|
-
#
|
|
423
|
+
#
|
|
673
424
|
# If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
|
|
674
425
|
# texts.
|
|
675
|
-
#
|
|
426
|
+
#
|
|
676
427
|
# Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
|
|
677
428
|
# modifier, modifier is pressed and being held while the subsequent key is being pressed.
|
|
678
429
|
def press(
|
|
@@ -685,7 +436,7 @@ module Playwright
|
|
|
685
436
|
end
|
|
686
437
|
|
|
687
438
|
# Returns the ElementHandle pointing to the frame element.
|
|
688
|
-
#
|
|
439
|
+
#
|
|
689
440
|
# The method finds an element matching the specified selector within the frame. See
|
|
690
441
|
# [Working with selectors](./selectors.md) for more details. If no elements match the selector, returns `null`.
|
|
691
442
|
def query_selector(selector)
|
|
@@ -693,50 +444,24 @@ module Playwright
|
|
|
693
444
|
end
|
|
694
445
|
|
|
695
446
|
# Returns the ElementHandles pointing to the frame elements.
|
|
696
|
-
#
|
|
447
|
+
#
|
|
697
448
|
# The method finds all elements matching the specified selector within the frame. See
|
|
698
449
|
# [Working with selectors](./selectors.md) for more details. If no elements match the selector, returns empty array.
|
|
699
450
|
def query_selector_all(selector)
|
|
700
451
|
wrap_impl(@impl.query_selector_all(unwrap_impl(selector)))
|
|
701
452
|
end
|
|
702
453
|
|
|
454
|
+
# This method waits for an element matching `selector`, waits for [actionability](./actionability.md) checks, waits until
|
|
455
|
+
# all specified options are present in the `<select>` element and selects these options.
|
|
456
|
+
#
|
|
457
|
+
# If the target element is not a `<select>` element, this method throws an error. However, if the element is inside the
|
|
458
|
+
# `<label>` element that has an associated
|
|
459
|
+
# [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used instead.
|
|
460
|
+
#
|
|
703
461
|
# Returns the array of option values that have been successfully selected.
|
|
704
|
-
#
|
|
705
|
-
# Triggers a `change` and `input` event once all the provided options have been selected.
|
|
706
|
-
#
|
|
707
|
-
#
|
|
708
|
-
# Will wait until all specified options are present in the `<select>` element.
|
|
709
|
-
#
|
|
710
|
-
#
|
|
711
|
-
# ```js
|
|
712
|
-
# // single selection matching the value
|
|
713
|
-
# frame.selectOption('select#colors', 'blue');
|
|
714
|
-
#
|
|
715
|
-
# // single selection matching both the value and the label
|
|
716
|
-
# frame.selectOption('select#colors', { label: 'Blue' });
|
|
717
|
-
#
|
|
718
|
-
# // multiple selection
|
|
719
|
-
# frame.selectOption('select#colors', 'red', 'green', 'blue');
|
|
720
|
-
# ```
|
|
721
|
-
#
|
|
722
|
-
# ```java
|
|
723
|
-
# // single selection matching the value
|
|
724
|
-
# frame.selectOption("select#colors", "blue");
|
|
725
|
-
# // single selection matching both the value and the label
|
|
726
|
-
# frame.selectOption("select#colors", new SelectOption().setLabel("Blue"));
|
|
727
|
-
# // multiple selection
|
|
728
|
-
# frame.selectOption("select#colors", new String[] {"red", "green", "blue"});
|
|
729
|
-
# ```
|
|
730
|
-
#
|
|
731
|
-
# ```python async
|
|
732
|
-
# # single selection matching the value
|
|
733
|
-
# await frame.select_option("select#colors", "blue")
|
|
734
|
-
# # single selection matching the label
|
|
735
|
-
# await frame.select_option("select#colors", label="blue")
|
|
736
|
-
# # multiple selection
|
|
737
|
-
# await frame.select_option("select#colors", value=["red", "green", "blue"])
|
|
738
|
-
# ```
|
|
739
|
-
#
|
|
462
|
+
#
|
|
463
|
+
# Triggers a `change` and `input` event once all the provided options have been selected.
|
|
464
|
+
#
|
|
740
465
|
# ```python sync
|
|
741
466
|
# # single selection matching the value
|
|
742
467
|
# frame.select_option("select#colors", "blue")
|
|
@@ -763,7 +488,7 @@ module Playwright
|
|
|
763
488
|
|
|
764
489
|
# This method expects `selector` to point to an
|
|
765
490
|
# [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
|
|
766
|
-
#
|
|
491
|
+
#
|
|
767
492
|
# Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
|
|
768
493
|
# are resolved relative to the the current working directory. For empty array, clears the selected files.
|
|
769
494
|
def set_input_files(selector, files, noWaitAfter: nil, timeout: nil)
|
|
@@ -777,10 +502,10 @@ module Playwright
|
|
|
777
502
|
# 1. Scroll the element into view if needed.
|
|
778
503
|
# 1. Use [`property: Page.touchscreen`] to tap the center of the element, or the specified `position`.
|
|
779
504
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
|
780
|
-
#
|
|
505
|
+
#
|
|
781
506
|
# When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
|
|
782
507
|
# zero timeout disables this.
|
|
783
|
-
#
|
|
508
|
+
#
|
|
784
509
|
# > NOTE: `frame.tap()` requires that the `hasTouch` option of the browser context be set to true.
|
|
785
510
|
def tap_point(
|
|
786
511
|
selector,
|
|
@@ -788,8 +513,9 @@ module Playwright
|
|
|
788
513
|
modifiers: nil,
|
|
789
514
|
noWaitAfter: nil,
|
|
790
515
|
position: nil,
|
|
791
|
-
timeout: nil
|
|
792
|
-
|
|
516
|
+
timeout: nil,
|
|
517
|
+
trial: nil)
|
|
518
|
+
wrap_impl(@impl.tap_point(unwrap_impl(selector), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
|
793
519
|
end
|
|
794
520
|
|
|
795
521
|
# Returns `element.textContent`.
|
|
@@ -804,27 +530,9 @@ module Playwright
|
|
|
804
530
|
|
|
805
531
|
# Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. `frame.type` can be used to
|
|
806
532
|
# send fine-grained keyboard events. To fill values in form fields, use [`method: Frame.fill`].
|
|
807
|
-
#
|
|
533
|
+
#
|
|
808
534
|
# To press a special key, like `Control` or `ArrowDown`, use [`method: Keyboard.press`].
|
|
809
|
-
#
|
|
810
535
|
#
|
|
811
|
-
# ```js
|
|
812
|
-
# await frame.type('#mytextarea', 'Hello'); // Types instantly
|
|
813
|
-
# await frame.type('#mytextarea', 'World', {delay: 100}); // Types slower, like a user
|
|
814
|
-
# ```
|
|
815
|
-
#
|
|
816
|
-
# ```java
|
|
817
|
-
# // Types instantly
|
|
818
|
-
# frame.type("#mytextarea", "Hello");
|
|
819
|
-
# // Types slower, like a user
|
|
820
|
-
# frame.type("#mytextarea", "World", new Frame.TypeOptions().setDelay(100));
|
|
821
|
-
# ```
|
|
822
|
-
#
|
|
823
|
-
# ```python async
|
|
824
|
-
# await frame.type("#mytextarea", "hello") # types instantly
|
|
825
|
-
# await frame.type("#mytextarea", "world", delay=100) # types slower, like a user
|
|
826
|
-
# ```
|
|
827
|
-
#
|
|
828
536
|
# ```python sync
|
|
829
537
|
# frame.type("#mytextarea", "hello") # types instantly
|
|
830
538
|
# frame.type("#mytextarea", "world", delay=100) # types slower, like a user
|
|
@@ -848,7 +556,7 @@ module Playwright
|
|
|
848
556
|
# 1. Use [`property: Page.mouse`] to click in the center of the element.
|
|
849
557
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
|
850
558
|
# 1. Ensure that the element is now unchecked. If not, this method throws.
|
|
851
|
-
#
|
|
559
|
+
#
|
|
852
560
|
# When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
|
|
853
561
|
# zero timeout disables this.
|
|
854
562
|
def uncheck(
|
|
@@ -856,8 +564,9 @@ module Playwright
|
|
|
856
564
|
force: nil,
|
|
857
565
|
noWaitAfter: nil,
|
|
858
566
|
position: nil,
|
|
859
|
-
timeout: nil
|
|
860
|
-
|
|
567
|
+
timeout: nil,
|
|
568
|
+
trial: nil)
|
|
569
|
+
wrap_impl(@impl.uncheck(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
|
861
570
|
end
|
|
862
571
|
|
|
863
572
|
# Returns frame's url.
|
|
@@ -866,61 +575,12 @@ module Playwright
|
|
|
866
575
|
end
|
|
867
576
|
|
|
868
577
|
# Returns when the `expression` returns a truthy value, returns that value.
|
|
869
|
-
#
|
|
578
|
+
#
|
|
870
579
|
# The [`method: Frame.waitForFunction`] can be used to observe viewport size change:
|
|
871
|
-
#
|
|
872
|
-
#
|
|
873
|
-
# ```js
|
|
874
|
-
# const { firefox } = require('playwright'); // Or 'chromium' or 'webkit'.
|
|
875
|
-
#
|
|
876
|
-
# (async () => {
|
|
877
|
-
# const browser = await firefox.launch();
|
|
878
|
-
# const page = await browser.newPage();
|
|
879
|
-
# const watchDog = page.mainFrame().waitForFunction('window.innerWidth < 100');
|
|
880
|
-
# page.setViewportSize({width: 50, height: 50});
|
|
881
|
-
# await watchDog;
|
|
882
|
-
# await browser.close();
|
|
883
|
-
# })();
|
|
884
|
-
# ```
|
|
885
|
-
#
|
|
886
|
-
# ```java
|
|
887
|
-
# import com.microsoft.playwright.*;
|
|
888
|
-
#
|
|
889
|
-
# public class Example {
|
|
890
|
-
# public static void main(String[] args) {
|
|
891
|
-
# try (Playwright playwright = Playwright.create()) {
|
|
892
|
-
# BrowserType firefox = playwright.firefox();
|
|
893
|
-
# Browser browser = firefox.launch();
|
|
894
|
-
# Page page = browser.newPage();
|
|
895
|
-
# page.setViewportSize(50, 50);
|
|
896
|
-
# page.mainFrame().waitForFunction("window.innerWidth < 100");
|
|
897
|
-
# browser.close();
|
|
898
|
-
# }
|
|
899
|
-
# }
|
|
900
|
-
# }
|
|
901
|
-
# ```
|
|
902
|
-
#
|
|
903
|
-
# ```python async
|
|
904
|
-
# import asyncio
|
|
905
|
-
# from playwright.async_api import async_playwright
|
|
906
|
-
#
|
|
907
|
-
# async def run(playwright):
|
|
908
|
-
# webkit = playwright.webkit
|
|
909
|
-
# browser = await webkit.launch()
|
|
910
|
-
# page = await browser.new_page()
|
|
911
|
-
# await page.evaluate("window.x = 0; setTimeout(() => { window.x = 100 }, 1000);")
|
|
912
|
-
# await page.main_frame.wait_for_function("() => window.x > 0")
|
|
913
|
-
# await browser.close()
|
|
914
|
-
#
|
|
915
|
-
# async def main():
|
|
916
|
-
# async with async_playwright() as playwright:
|
|
917
|
-
# await run(playwright)
|
|
918
|
-
# asyncio.run(main())
|
|
919
|
-
# ```
|
|
920
|
-
#
|
|
580
|
+
#
|
|
921
581
|
# ```python sync
|
|
922
582
|
# from playwright.sync_api import sync_playwright
|
|
923
|
-
#
|
|
583
|
+
#
|
|
924
584
|
# def run(playwright):
|
|
925
585
|
# webkit = playwright.webkit
|
|
926
586
|
# browser = webkit.launch()
|
|
@@ -928,29 +588,13 @@ module Playwright
|
|
|
928
588
|
# page.evaluate("window.x = 0; setTimeout(() => { window.x = 100 }, 1000);")
|
|
929
589
|
# page.main_frame.wait_for_function("() => window.x > 0")
|
|
930
590
|
# browser.close()
|
|
931
|
-
#
|
|
591
|
+
#
|
|
932
592
|
# with sync_playwright() as playwright:
|
|
933
593
|
# run(playwright)
|
|
934
594
|
# ```
|
|
935
|
-
#
|
|
595
|
+
#
|
|
936
596
|
# To pass an argument to the predicate of `frame.waitForFunction` function:
|
|
937
|
-
#
|
|
938
597
|
#
|
|
939
|
-
# ```js
|
|
940
|
-
# const selector = '.foo';
|
|
941
|
-
# await frame.waitForFunction(selector => !!document.querySelector(selector), selector);
|
|
942
|
-
# ```
|
|
943
|
-
#
|
|
944
|
-
# ```java
|
|
945
|
-
# String selector = ".foo";
|
|
946
|
-
# frame.waitForFunction("selector => !!document.querySelector(selector)", selector);
|
|
947
|
-
# ```
|
|
948
|
-
#
|
|
949
|
-
# ```python async
|
|
950
|
-
# selector = ".foo"
|
|
951
|
-
# await frame.wait_for_function("selector => !!document.querySelector(selector)", selector)
|
|
952
|
-
# ```
|
|
953
|
-
#
|
|
954
598
|
# ```python sync
|
|
955
599
|
# selector = ".foo"
|
|
956
600
|
# frame.wait_for_function("selector => !!document.querySelector(selector)", selector)
|
|
@@ -960,26 +604,10 @@ module Playwright
|
|
|
960
604
|
end
|
|
961
605
|
|
|
962
606
|
# Waits for the required load state to be reached.
|
|
963
|
-
#
|
|
607
|
+
#
|
|
964
608
|
# This returns when the frame reaches a required load state, `load` by default. The navigation must have been committed
|
|
965
609
|
# when this method is called. If current document has already reached the required state, resolves immediately.
|
|
966
|
-
#
|
|
967
610
|
#
|
|
968
|
-
# ```js
|
|
969
|
-
# await frame.click('button'); // Click triggers navigation.
|
|
970
|
-
# await frame.waitForLoadState(); // Waits for 'load' state by default.
|
|
971
|
-
# ```
|
|
972
|
-
#
|
|
973
|
-
# ```java
|
|
974
|
-
# frame.click("button"); // Click triggers navigation.
|
|
975
|
-
# frame.waitForLoadState(); // Waits for "load" state by default.
|
|
976
|
-
# ```
|
|
977
|
-
#
|
|
978
|
-
# ```python async
|
|
979
|
-
# await frame.click("button") # click triggers navigation.
|
|
980
|
-
# await frame.wait_for_load_state() # the promise resolves after "load" event.
|
|
981
|
-
# ```
|
|
982
|
-
#
|
|
983
611
|
# ```python sync
|
|
984
612
|
# frame.click("button") # click triggers navigation.
|
|
985
613
|
# frame.wait_for_load_state() # the promise resolves after "load" event.
|
|
@@ -991,38 +619,16 @@ module Playwright
|
|
|
991
619
|
# Waits for the frame navigation and returns the main resource response. In case of multiple redirects, the navigation
|
|
992
620
|
# will resolve with the response of the last redirect. In case of navigation to a different anchor or navigation due to
|
|
993
621
|
# History API usage, the navigation will resolve with `null`.
|
|
994
|
-
#
|
|
622
|
+
#
|
|
995
623
|
# This method waits for the frame to navigate to a new URL. It is useful for when you run code which will indirectly cause
|
|
996
624
|
# the frame to navigate. Consider this example:
|
|
997
|
-
#
|
|
998
625
|
#
|
|
999
|
-
# ```js
|
|
1000
|
-
# const [response] = await Promise.all([
|
|
1001
|
-
# frame.waitForNavigation(), // The promise resolves after navigation has finished
|
|
1002
|
-
# frame.click('a.delayed-navigation'), // Clicking the link will indirectly cause a navigation
|
|
1003
|
-
# ]);
|
|
1004
|
-
# ```
|
|
1005
|
-
#
|
|
1006
|
-
# ```java
|
|
1007
|
-
# // The method returns after navigation has finished
|
|
1008
|
-
# Response response = frame.waitForNavigation(() -> {
|
|
1009
|
-
# // Clicking the link will indirectly cause a navigation
|
|
1010
|
-
# frame.click("a.delayed-navigation");
|
|
1011
|
-
# });
|
|
1012
|
-
# ```
|
|
1013
|
-
#
|
|
1014
|
-
# ```python async
|
|
1015
|
-
# async with frame.expect_navigation():
|
|
1016
|
-
# await frame.click("a.delayed-navigation") # clicking the link will indirectly cause a navigation
|
|
1017
|
-
# # Resolves after navigation has finished
|
|
1018
|
-
# ```
|
|
1019
|
-
#
|
|
1020
626
|
# ```python sync
|
|
1021
627
|
# with frame.expect_navigation():
|
|
1022
628
|
# frame.click("a.delayed-navigation") # clicking the link will indirectly cause a navigation
|
|
1023
629
|
# # Resolves after navigation has finished
|
|
1024
630
|
# ```
|
|
1025
|
-
#
|
|
631
|
+
#
|
|
1026
632
|
# > NOTE: Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the URL is
|
|
1027
633
|
# considered a navigation.
|
|
1028
634
|
def expect_navigation(timeout: nil, url: nil, waitUntil: nil, &block)
|
|
@@ -1031,72 +637,16 @@ module Playwright
|
|
|
1031
637
|
|
|
1032
638
|
# Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or
|
|
1033
639
|
# `detached`.
|
|
1034
|
-
#
|
|
640
|
+
#
|
|
1035
641
|
# Wait for the `selector` to satisfy `state` option (either appear/disappear from dom, or become visible/hidden). If at
|
|
1036
642
|
# the moment of calling the method `selector` already satisfies the condition, the method will return immediately. If the
|
|
1037
643
|
# selector doesn't satisfy the condition for the `timeout` milliseconds, the function will throw.
|
|
1038
|
-
#
|
|
644
|
+
#
|
|
1039
645
|
# This method works across navigations:
|
|
1040
|
-
#
|
|
1041
|
-
#
|
|
1042
|
-
# ```js
|
|
1043
|
-
# const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.
|
|
1044
|
-
#
|
|
1045
|
-
# (async () => {
|
|
1046
|
-
# const browser = await chromium.launch();
|
|
1047
|
-
# const page = await browser.newPage();
|
|
1048
|
-
# for (let currentURL of ['https://google.com', 'https://bbc.com']) {
|
|
1049
|
-
# await page.goto(currentURL);
|
|
1050
|
-
# const element = await page.mainFrame().waitForSelector('img');
|
|
1051
|
-
# console.log('Loaded image: ' + await element.getAttribute('src'));
|
|
1052
|
-
# }
|
|
1053
|
-
# await browser.close();
|
|
1054
|
-
# })();
|
|
1055
|
-
# ```
|
|
1056
|
-
#
|
|
1057
|
-
# ```java
|
|
1058
|
-
# import com.microsoft.playwright.*;
|
|
1059
|
-
#
|
|
1060
|
-
# public class Example {
|
|
1061
|
-
# public static void main(String[] args) {
|
|
1062
|
-
# try (Playwright playwright = Playwright.create()) {
|
|
1063
|
-
# BrowserType chromium = playwright.chromium();
|
|
1064
|
-
# Browser browser = chromium.launch();
|
|
1065
|
-
# Page page = browser.newPage();
|
|
1066
|
-
# for (String currentURL : Arrays.asList("https://google.com", "https://bbc.com")) {
|
|
1067
|
-
# page.navigate(currentURL);
|
|
1068
|
-
# ElementHandle element = page.mainFrame().waitForSelector("img");
|
|
1069
|
-
# System.out.println("Loaded image: " + element.getAttribute("src"));
|
|
1070
|
-
# }
|
|
1071
|
-
# browser.close();
|
|
1072
|
-
# }
|
|
1073
|
-
# }
|
|
1074
|
-
# }
|
|
1075
|
-
# ```
|
|
1076
|
-
#
|
|
1077
|
-
# ```python async
|
|
1078
|
-
# import asyncio
|
|
1079
|
-
# from playwright.async_api import async_playwright
|
|
1080
|
-
#
|
|
1081
|
-
# async def run(playwright):
|
|
1082
|
-
# chromium = playwright.chromium
|
|
1083
|
-
# browser = await chromium.launch()
|
|
1084
|
-
# page = await browser.new_page()
|
|
1085
|
-
# for current_url in ["https://google.com", "https://bbc.com"]:
|
|
1086
|
-
# await page.goto(current_url, wait_until="domcontentloaded")
|
|
1087
|
-
# element = await page.main_frame.wait_for_selector("img")
|
|
1088
|
-
# print("Loaded image: " + str(await element.get_attribute("src")))
|
|
1089
|
-
# await browser.close()
|
|
1090
|
-
#
|
|
1091
|
-
# async def main():
|
|
1092
|
-
# async with async_playwright() as playwright:
|
|
1093
|
-
# await run(playwright)
|
|
1094
|
-
# asyncio.run(main())
|
|
1095
|
-
# ```
|
|
1096
|
-
#
|
|
646
|
+
#
|
|
1097
647
|
# ```python sync
|
|
1098
648
|
# from playwright.sync_api import sync_playwright
|
|
1099
|
-
#
|
|
649
|
+
#
|
|
1100
650
|
# def run(playwright):
|
|
1101
651
|
# chromium = playwright.chromium
|
|
1102
652
|
# browser = chromium.launch()
|
|
@@ -1106,7 +656,7 @@ module Playwright
|
|
|
1106
656
|
# element = page.main_frame.wait_for_selector("img")
|
|
1107
657
|
# print("Loaded image: " + str(element.get_attribute("src")))
|
|
1108
658
|
# browser.close()
|
|
1109
|
-
#
|
|
659
|
+
#
|
|
1110
660
|
# with sync_playwright() as playwright:
|
|
1111
661
|
# run(playwright)
|
|
1112
662
|
# ```
|
|
@@ -1115,7 +665,7 @@ module Playwright
|
|
|
1115
665
|
end
|
|
1116
666
|
|
|
1117
667
|
# Waits for the given `timeout` in milliseconds.
|
|
1118
|
-
#
|
|
668
|
+
#
|
|
1119
669
|
# Note that `frame.waitForTimeout()` should only be used for debugging. Tests using the timer in production are going to
|
|
1120
670
|
# be flaky. Use signals such as network events, selectors becoming visible and others instead.
|
|
1121
671
|
def wait_for_timeout(timeout)
|
|
@@ -1123,23 +673,7 @@ module Playwright
|
|
|
1123
673
|
end
|
|
1124
674
|
|
|
1125
675
|
# Waits for the frame to navigate to the given URL.
|
|
1126
|
-
#
|
|
1127
676
|
#
|
|
1128
|
-
# ```js
|
|
1129
|
-
# await frame.click('a.delayed-navigation'); // Clicking the link will indirectly cause a navigation
|
|
1130
|
-
# await frame.waitForURL('**/target.html');
|
|
1131
|
-
# ```
|
|
1132
|
-
#
|
|
1133
|
-
# ```java
|
|
1134
|
-
# frame.click("a.delayed-navigation"); // Clicking the link will indirectly cause a navigation
|
|
1135
|
-
# frame.waitForURL("**/target.html");
|
|
1136
|
-
# ```
|
|
1137
|
-
#
|
|
1138
|
-
# ```python async
|
|
1139
|
-
# await frame.click("a.delayed-navigation") # clicking the link will indirectly cause a navigation
|
|
1140
|
-
# await frame.wait_for_url("**/target.html")
|
|
1141
|
-
# ```
|
|
1142
|
-
#
|
|
1143
677
|
# ```python sync
|
|
1144
678
|
# frame.click("a.delayed-navigation") # clicking the link will indirectly cause a navigation
|
|
1145
679
|
# frame.wait_for_url("**/target.html")
|