playwright-ruby-client 0.3.0 → 0.5.6
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 +17 -5
- data/docs/api_coverage.md +14 -25
- data/lib/playwright.rb +47 -9
- data/lib/playwright/channel.rb +19 -9
- data/lib/playwright/channel_owners/artifact.rb +30 -0
- data/lib/playwright/channel_owners/browser.rb +21 -0
- data/lib/playwright/channel_owners/browser_context.rb +5 -0
- data/lib/playwright/channel_owners/browser_type.rb +28 -0
- data/lib/playwright/channel_owners/element_handle.rb +7 -7
- data/lib/playwright/channel_owners/frame.rb +26 -5
- data/lib/playwright/channel_owners/js_handle.rb +2 -2
- data/lib/playwright/channel_owners/page.rb +78 -15
- data/lib/playwright/channel_owners/playwright.rb +22 -29
- data/lib/playwright/channel_owners/stream.rb +15 -0
- data/lib/playwright/connection.rb +11 -32
- data/lib/playwright/download.rb +27 -0
- data/lib/playwright/errors.rb +6 -0
- data/lib/playwright/events.rb +2 -5
- data/lib/playwright/keyboard_impl.rb +1 -1
- data/lib/playwright/mouse_impl.rb +41 -0
- data/lib/playwright/playwright_api.rb +5 -3
- data/lib/playwright/route_handler_entry.rb +1 -9
- data/lib/playwright/select_option_values.rb +31 -22
- data/lib/playwright/transport.rb +29 -7
- data/lib/playwright/url_matcher.rb +1 -1
- data/lib/playwright/utils.rb +8 -0
- data/lib/playwright/version.rb +1 -1
- data/lib/playwright/video.rb +51 -0
- data/lib/playwright/wait_helper.rb +2 -2
- data/lib/playwright_api/accessibility.rb +39 -1
- data/lib/playwright_api/android.rb +10 -10
- data/lib/playwright_api/android_device.rb +10 -9
- data/lib/playwright_api/browser.rb +83 -8
- data/lib/playwright_api/browser_context.rb +157 -9
- data/lib/playwright_api/browser_type.rb +35 -4
- data/lib/playwright_api/console_message.rb +6 -6
- data/lib/playwright_api/dialog.rb +28 -8
- data/lib/playwright_api/element_handle.rb +111 -37
- data/lib/playwright_api/file_chooser.rb +5 -0
- data/lib/playwright_api/frame.rb +228 -37
- data/lib/playwright_api/js_handle.rb +26 -3
- data/lib/playwright_api/keyboard.rb +48 -1
- data/lib/playwright_api/mouse.rb +26 -5
- data/lib/playwright_api/page.rb +454 -46
- data/lib/playwright_api/playwright.rb +26 -9
- data/lib/playwright_api/request.rb +34 -6
- data/lib/playwright_api/response.rb +6 -6
- data/lib/playwright_api/route.rb +30 -6
- data/lib/playwright_api/selectors.rb +32 -6
- data/lib/playwright_api/touchscreen.rb +1 -1
- data/lib/playwright_api/worker.rb +25 -1
- data/playwright.gemspec +4 -2
- metadata +37 -14
- 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/download.rb +0 -27
- data/lib/playwright/channel_owners/firefox_browser.rb +0 -8
- data/lib/playwright/channel_owners/webkit_browser.rb +0 -8
- data/lib/playwright_api/binding_call.rb +0 -32
- data/lib/playwright_api/chromium_browser_context.rb +0 -59
- data/lib/playwright_api/download.rb +0 -95
- data/lib/playwright_api/video.rb +0 -24
@@ -15,6 +15,23 @@ module Playwright
|
|
15
15
|
# })();
|
16
16
|
# ```
|
17
17
|
#
|
18
|
+
# ```java
|
19
|
+
# import com.microsoft.playwright.*;
|
20
|
+
#
|
21
|
+
# public class Example {
|
22
|
+
# public static void main(String[] args) {
|
23
|
+
# try (Playwright playwright = Playwright.create()) {
|
24
|
+
# BrowserType chromium = playwright.chromium();
|
25
|
+
# Browser browser = chromium.launch();
|
26
|
+
# Page page = browser.newPage();
|
27
|
+
# page.navigate("https://example.com");
|
28
|
+
# // other actions...
|
29
|
+
# browser.close();
|
30
|
+
# }
|
31
|
+
# }
|
32
|
+
# }
|
33
|
+
# ```
|
34
|
+
#
|
18
35
|
# ```python async
|
19
36
|
# import asyncio
|
20
37
|
# from playwright.async_api import async_playwright
|
@@ -65,6 +82,12 @@ module Playwright
|
|
65
82
|
# });
|
66
83
|
# ```
|
67
84
|
#
|
85
|
+
# ```java
|
86
|
+
# // Or "firefox" or "webkit".
|
87
|
+
# Browser browser = chromium.launch(new BrowserType.LaunchOptions()
|
88
|
+
# .setIgnoreDefaultArgs(Arrays.asList("--mute-audio")));
|
89
|
+
# ```
|
90
|
+
#
|
68
91
|
# ```python async
|
69
92
|
# browser = await playwright.chromium.launch( # or "firefox" or "webkit".
|
70
93
|
# ignore_default_args=["--mute-audio"]
|
@@ -93,6 +116,7 @@ module Playwright
|
|
93
116
|
# describes some differences for Linux users.
|
94
117
|
def launch(
|
95
118
|
args: nil,
|
119
|
+
channel: nil,
|
96
120
|
chromiumSandbox: nil,
|
97
121
|
devtools: nil,
|
98
122
|
downloadsPath: nil,
|
@@ -108,7 +132,7 @@ module Playwright
|
|
108
132
|
slowMo: nil,
|
109
133
|
timeout: nil,
|
110
134
|
&block)
|
111
|
-
wrap_impl(@impl.launch(args: unwrap_impl(args), chromiumSandbox: unwrap_impl(chromiumSandbox), devtools: unwrap_impl(devtools), downloadsPath: unwrap_impl(downloadsPath), env: unwrap_impl(env), executablePath: unwrap_impl(executablePath), firefoxUserPrefs: unwrap_impl(firefoxUserPrefs), handleSIGHUP: unwrap_impl(handleSIGHUP), handleSIGINT: unwrap_impl(handleSIGINT), handleSIGTERM: unwrap_impl(handleSIGTERM), headless: unwrap_impl(headless), ignoreDefaultArgs: unwrap_impl(ignoreDefaultArgs), proxy: unwrap_impl(proxy), slowMo: unwrap_impl(slowMo), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
|
135
|
+
wrap_impl(@impl.launch(args: unwrap_impl(args), channel: unwrap_impl(channel), chromiumSandbox: unwrap_impl(chromiumSandbox), devtools: unwrap_impl(devtools), downloadsPath: unwrap_impl(downloadsPath), env: unwrap_impl(env), executablePath: unwrap_impl(executablePath), firefoxUserPrefs: unwrap_impl(firefoxUserPrefs), handleSIGHUP: unwrap_impl(handleSIGHUP), handleSIGINT: unwrap_impl(handleSIGINT), handleSIGTERM: unwrap_impl(handleSIGTERM), headless: unwrap_impl(headless), ignoreDefaultArgs: unwrap_impl(ignoreDefaultArgs), proxy: unwrap_impl(proxy), slowMo: unwrap_impl(slowMo), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
|
112
136
|
end
|
113
137
|
|
114
138
|
# Returns the persistent browser context instance.
|
@@ -120,6 +144,7 @@ module Playwright
|
|
120
144
|
acceptDownloads: nil,
|
121
145
|
args: nil,
|
122
146
|
bypassCSP: nil,
|
147
|
+
channel: nil,
|
123
148
|
chromiumSandbox: nil,
|
124
149
|
colorScheme: nil,
|
125
150
|
deviceScaleFactor: nil,
|
@@ -148,6 +173,7 @@ module Playwright
|
|
148
173
|
record_har_path: nil,
|
149
174
|
record_video_dir: nil,
|
150
175
|
record_video_size: nil,
|
176
|
+
screen: nil,
|
151
177
|
slowMo: nil,
|
152
178
|
timeout: nil,
|
153
179
|
timezoneId: nil,
|
@@ -161,10 +187,9 @@ module Playwright
|
|
161
187
|
wrap_impl(@impl.name)
|
162
188
|
end
|
163
189
|
|
164
|
-
# -- inherited from EventEmitter --
|
165
190
|
# @nodoc
|
166
|
-
def
|
167
|
-
|
191
|
+
def connect_over_cdp(endpointURL, slowMo: nil, timeout: nil, &block)
|
192
|
+
wrap_impl(@impl.connect_over_cdp(unwrap_impl(endpointURL), slowMo: unwrap_impl(slowMo), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
|
168
193
|
end
|
169
194
|
|
170
195
|
# -- inherited from EventEmitter --
|
@@ -179,6 +204,12 @@ module Playwright
|
|
179
204
|
event_emitter_proxy.on(event, callback)
|
180
205
|
end
|
181
206
|
|
207
|
+
# -- inherited from EventEmitter --
|
208
|
+
# @nodoc
|
209
|
+
def off(event, callback)
|
210
|
+
event_emitter_proxy.off(event, callback)
|
211
|
+
end
|
212
|
+
|
182
213
|
private def event_emitter_proxy
|
183
214
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
184
215
|
end
|
@@ -21,12 +21,6 @@ module Playwright
|
|
21
21
|
wrap_impl(@impl.type)
|
22
22
|
end
|
23
23
|
|
24
|
-
# -- inherited from EventEmitter --
|
25
|
-
# @nodoc
|
26
|
-
def off(event, callback)
|
27
|
-
event_emitter_proxy.off(event, callback)
|
28
|
-
end
|
29
|
-
|
30
24
|
# -- inherited from EventEmitter --
|
31
25
|
# @nodoc
|
32
26
|
def once(event, callback)
|
@@ -39,6 +33,12 @@ module Playwright
|
|
39
33
|
event_emitter_proxy.on(event, callback)
|
40
34
|
end
|
41
35
|
|
36
|
+
# -- inherited from EventEmitter --
|
37
|
+
# @nodoc
|
38
|
+
def off(event, callback)
|
39
|
+
event_emitter_proxy.off(event, callback)
|
40
|
+
end
|
41
|
+
|
42
42
|
private def event_emitter_proxy
|
43
43
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
44
44
|
end
|
@@ -13,12 +13,32 @@ module Playwright
|
|
13
13
|
# page.on('dialog', async dialog => {
|
14
14
|
# console.log(dialog.message());
|
15
15
|
# await dialog.dismiss();
|
16
|
-
# await browser.close();
|
17
16
|
# });
|
18
|
-
# page.evaluate(() => alert('1'));
|
17
|
+
# await page.evaluate(() => alert('1'));
|
18
|
+
# await browser.close();
|
19
19
|
# })();
|
20
20
|
# ```
|
21
21
|
#
|
22
|
+
# ```java
|
23
|
+
# import com.microsoft.playwright.*;
|
24
|
+
#
|
25
|
+
# public class Example {
|
26
|
+
# public static void main(String[] args) {
|
27
|
+
# try (Playwright playwright = Playwright.create()) {
|
28
|
+
# BrowserType chromium = playwright.chromium();
|
29
|
+
# Browser browser = chromium.launch();
|
30
|
+
# Page page = browser.newPage();
|
31
|
+
# page.onDialog(dialog -> {
|
32
|
+
# System.out.println(dialog.message());
|
33
|
+
# dialog.dismiss();
|
34
|
+
# });
|
35
|
+
# page.evaluate("alert('1')");
|
36
|
+
# browser.close();
|
37
|
+
# }
|
38
|
+
# }
|
39
|
+
# }
|
40
|
+
# ```
|
41
|
+
#
|
22
42
|
# ```python async
|
23
43
|
# import asyncio
|
24
44
|
# from playwright.async_api import async_playwright
|
@@ -96,12 +116,6 @@ module Playwright
|
|
96
116
|
wrap_impl(@impl.accept_async(promptText: unwrap_impl(promptText)))
|
97
117
|
end
|
98
118
|
|
99
|
-
# -- inherited from EventEmitter --
|
100
|
-
# @nodoc
|
101
|
-
def off(event, callback)
|
102
|
-
event_emitter_proxy.off(event, callback)
|
103
|
-
end
|
104
|
-
|
105
119
|
# -- inherited from EventEmitter --
|
106
120
|
# @nodoc
|
107
121
|
def once(event, callback)
|
@@ -114,6 +128,12 @@ module Playwright
|
|
114
128
|
event_emitter_proxy.on(event, callback)
|
115
129
|
end
|
116
130
|
|
131
|
+
# -- inherited from EventEmitter --
|
132
|
+
# @nodoc
|
133
|
+
def off(event, callback)
|
134
|
+
event_emitter_proxy.off(event, callback)
|
135
|
+
end
|
136
|
+
|
117
137
|
private def event_emitter_proxy
|
118
138
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
119
139
|
end
|
@@ -20,6 +20,24 @@ module Playwright
|
|
20
20
|
# })();
|
21
21
|
# ```
|
22
22
|
#
|
23
|
+
# ```java
|
24
|
+
# import com.microsoft.playwright.*;
|
25
|
+
#
|
26
|
+
# public class Example {
|
27
|
+
# public static void main(String[] args) {
|
28
|
+
# try (Playwright playwright = Playwright.create()) {
|
29
|
+
# BrowserType chromium = playwright.chromium();
|
30
|
+
# Browser browser = chromium.launch();
|
31
|
+
# Page page = browser.newPage();
|
32
|
+
# page.navigate("https://example.com");
|
33
|
+
# ElementHandle hrefElement = page.querySelector("a");
|
34
|
+
# hrefElement.click();
|
35
|
+
# // ...
|
36
|
+
# }
|
37
|
+
# }
|
38
|
+
# }
|
39
|
+
# ```
|
40
|
+
#
|
23
41
|
# ```python async
|
24
42
|
# import asyncio
|
25
43
|
# from playwright.async_api import async_playwright
|
@@ -81,6 +99,11 @@ module Playwright
|
|
81
99
|
# await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2);
|
82
100
|
# ```
|
83
101
|
#
|
102
|
+
# ```java
|
103
|
+
# BoundingBox box = elementHandle.boundingBox();
|
104
|
+
# page.mouse().click(box.x + box.width / 2, box.y + box.height / 2);
|
105
|
+
# ```
|
106
|
+
#
|
84
107
|
# ```python async
|
85
108
|
# box = await element_handle.bounding_box()
|
86
109
|
# await page.mouse.click(box["x"] + box["width"] / 2, box["y"] + box["height"] / 2)
|
@@ -95,20 +118,20 @@ module Playwright
|
|
95
118
|
end
|
96
119
|
|
97
120
|
# This method checks the element by performing the following steps:
|
98
|
-
# 1. Ensure that element is a checkbox or a radio input. If not, this method
|
99
|
-
#
|
121
|
+
# 1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already checked,
|
122
|
+
# this method returns immediately.
|
100
123
|
# 1. Wait for [actionability](./actionability.md) checks on the element, unless `force` option is set.
|
101
124
|
# 1. Scroll the element into view if needed.
|
102
125
|
# 1. Use [`property: Page.mouse`] to click in the center of the element.
|
103
126
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
104
|
-
# 1. Ensure that the element is now checked. If not, this method
|
127
|
+
# 1. Ensure that the element is now checked. If not, this method throws.
|
105
128
|
#
|
106
|
-
# If the element is detached from the DOM at any moment during the action, this method
|
129
|
+
# If the element is detached from the DOM at any moment during the action, this method throws.
|
107
130
|
#
|
108
|
-
# When all steps combined have not finished during the specified `timeout`, this method
|
109
|
-
#
|
110
|
-
def check(force: nil, noWaitAfter: nil, timeout: nil)
|
111
|
-
wrap_impl(@impl.check(force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
131
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
|
132
|
+
# zero timeout disables this.
|
133
|
+
def check(force: nil, noWaitAfter: nil, position: nil, timeout: nil)
|
134
|
+
wrap_impl(@impl.check(force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
|
112
135
|
end
|
113
136
|
|
114
137
|
# This method clicks the element by performing the following steps:
|
@@ -117,10 +140,10 @@ module Playwright
|
|
117
140
|
# 1. Use [`property: Page.mouse`] to click in the center of the element, or the specified `position`.
|
118
141
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
119
142
|
#
|
120
|
-
# If the element is detached from the DOM at any moment during the action, this method
|
143
|
+
# If the element is detached from the DOM at any moment during the action, this method throws.
|
121
144
|
#
|
122
|
-
# When all steps combined have not finished during the specified `timeout`, this method
|
123
|
-
#
|
145
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
|
146
|
+
# zero timeout disables this.
|
124
147
|
def click(
|
125
148
|
button: nil,
|
126
149
|
clickCount: nil,
|
@@ -143,12 +166,12 @@ module Playwright
|
|
143
166
|
# 1. Scroll the element into view if needed.
|
144
167
|
# 1. Use [`property: Page.mouse`] to double click in the center of the element, or the specified `position`.
|
145
168
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the
|
146
|
-
# first click of the `dblclick()` triggers a navigation event, this method will
|
169
|
+
# first click of the `dblclick()` triggers a navigation event, this method will throw.
|
147
170
|
#
|
148
|
-
# If the element is detached from the DOM at any moment during the action, this method
|
171
|
+
# If the element is detached from the DOM at any moment during the action, this method throws.
|
149
172
|
#
|
150
|
-
# When all steps combined have not finished during the specified `timeout`, this method
|
151
|
-
#
|
173
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
|
174
|
+
# zero timeout disables this.
|
152
175
|
#
|
153
176
|
# > NOTE: `elementHandle.dblclick()` dispatches two `click` events and a single `dblclick` event.
|
154
177
|
def dblclick(
|
@@ -162,8 +185,8 @@ module Playwright
|
|
162
185
|
wrap_impl(@impl.dblclick(button: unwrap_impl(button), delay: unwrap_impl(delay), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
|
163
186
|
end
|
164
187
|
|
165
|
-
# The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the
|
166
|
-
# is dispatched. This is
|
188
|
+
# The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element,
|
189
|
+
# `click` is dispatched. This is equivalent to calling
|
167
190
|
# [element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
|
168
191
|
#
|
169
192
|
#
|
@@ -171,6 +194,10 @@ module Playwright
|
|
171
194
|
# await elementHandle.dispatchEvent('click');
|
172
195
|
# ```
|
173
196
|
#
|
197
|
+
# ```java
|
198
|
+
# elementHandle.dispatchEvent("click");
|
199
|
+
# ```
|
200
|
+
#
|
174
201
|
# ```python async
|
175
202
|
# await element_handle.dispatch_event("click")
|
176
203
|
# ```
|
@@ -200,6 +227,14 @@ module Playwright
|
|
200
227
|
# await elementHandle.dispatchEvent('dragstart', { dataTransfer });
|
201
228
|
# ```
|
202
229
|
#
|
230
|
+
# ```java
|
231
|
+
# // Note you can only create DataTransfer in Chromium and Firefox
|
232
|
+
# JSHandle dataTransfer = page.evaluateHandle("() => new DataTransfer()");
|
233
|
+
# Map<String, Object> arg = new HashMap<>();
|
234
|
+
# arg.put("dataTransfer", dataTransfer);
|
235
|
+
# elementHandle.dispatchEvent("dragstart", arg);
|
236
|
+
# ```
|
237
|
+
#
|
203
238
|
# ```python async
|
204
239
|
# # note you can only create data_transfer in chromium and firefox
|
205
240
|
# data_transfer = await page.evaluate_handle("new DataTransfer()")
|
@@ -233,6 +268,12 @@ module Playwright
|
|
233
268
|
# expect(await tweetHandle.$eval('.retweets', node => node.innerText)).toBe('10');
|
234
269
|
# ```
|
235
270
|
#
|
271
|
+
# ```java
|
272
|
+
# ElementHandle tweetHandle = page.querySelector(".tweet");
|
273
|
+
# assertEquals("100", tweetHandle.evalOnSelector(".like", "node => node.innerText"));
|
274
|
+
# assertEquals("10", tweetHandle.evalOnSelector(".retweets", "node => node.innerText"));
|
275
|
+
# ```
|
276
|
+
#
|
236
277
|
# ```python async
|
237
278
|
# tweet_handle = await page.query_selector(".tweet")
|
238
279
|
# assert await tweet_handle.eval_on_selector(".like", "node => node.innerText") == "100"
|
@@ -271,6 +312,11 @@ module Playwright
|
|
271
312
|
# expect(await feedHandle.$$eval('.tweet', nodes => nodes.map(n => n.innerText))).toEqual(['Hello!', 'Hi!']);
|
272
313
|
# ```
|
273
314
|
#
|
315
|
+
# ```java
|
316
|
+
# ElementHandle feedHandle = page.querySelector(".feed");
|
317
|
+
# assertEquals(Arrays.asList("Hello!", "Hi!"), feedHandle.evalOnSelectorAll(".tweet", "nodes => nodes.map(n => n.innerText)"));
|
318
|
+
# ```
|
319
|
+
#
|
274
320
|
# ```python async
|
275
321
|
# feed_handle = await page.query_selector(".feed")
|
276
322
|
# assert await feed_handle.eval_on_selector_all(".tweet", "nodes => nodes.map(n => n.innerText)") == ["hello!", "hi!"]
|
@@ -310,10 +356,10 @@ module Playwright
|
|
310
356
|
# 1. Use [`property: Page.mouse`] to hover over the center of the element, or the specified `position`.
|
311
357
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
312
358
|
#
|
313
|
-
# If the element is detached from the DOM at any moment during the action, this method
|
359
|
+
# If the element is detached from the DOM at any moment during the action, this method throws.
|
314
360
|
#
|
315
|
-
# When all steps combined have not finished during the specified `timeout`, this method
|
316
|
-
#
|
361
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
|
362
|
+
# zero timeout disables this.
|
317
363
|
def hover(force: nil, modifiers: nil, position: nil, timeout: nil)
|
318
364
|
wrap_impl(@impl.hover(force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
|
319
365
|
end
|
@@ -379,7 +425,7 @@ module Playwright
|
|
379
425
|
# If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
|
380
426
|
# texts.
|
381
427
|
#
|
382
|
-
# Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When
|
428
|
+
# Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
|
383
429
|
# modifier, modifier is pressed and being held while the subsequent key is being pressed.
|
384
430
|
def press(key, delay: nil, noWaitAfter: nil, timeout: nil)
|
385
431
|
wrap_impl(@impl.press(unwrap_impl(key), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
@@ -439,6 +485,15 @@ module Playwright
|
|
439
485
|
# handle.selectOption(['red', 'green', 'blue']);
|
440
486
|
# ```
|
441
487
|
#
|
488
|
+
# ```java
|
489
|
+
# // single selection matching the value
|
490
|
+
# handle.selectOption("blue");
|
491
|
+
# // single selection matching the label
|
492
|
+
# handle.selectOption(new SelectOption().setLabel("Blue"));
|
493
|
+
# // multiple selection
|
494
|
+
# handle.selectOption(new String[] {"red", "green", "blue"});
|
495
|
+
# ```
|
496
|
+
#
|
442
497
|
# ```python async
|
443
498
|
# # single selection matching the value
|
444
499
|
# await handle.select_option("blue")
|
@@ -499,10 +554,10 @@ module Playwright
|
|
499
554
|
# 1. Use [`property: Page.touchscreen`] to tap the center of the element, or the specified `position`.
|
500
555
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
501
556
|
#
|
502
|
-
# If the element is detached from the DOM at any moment during the action, this method
|
557
|
+
# If the element is detached from the DOM at any moment during the action, this method throws.
|
503
558
|
#
|
504
|
-
# When all steps combined have not finished during the specified `timeout`, this method
|
505
|
-
#
|
559
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
|
560
|
+
# zero timeout disables this.
|
506
561
|
#
|
507
562
|
# > NOTE: `elementHandle.tap()` requires that the `hasTouch` option of the browser context be set to true.
|
508
563
|
def tap_point(
|
@@ -529,6 +584,11 @@ module Playwright
|
|
529
584
|
# await elementHandle.type('World', {delay: 100}); // Types slower, like a user
|
530
585
|
# ```
|
531
586
|
#
|
587
|
+
# ```java
|
588
|
+
# elementHandle.type("Hello"); // Types instantly
|
589
|
+
# elementHandle.type("World", new ElementHandle.TypeOptions().setDelay(100)); // Types slower, like a user
|
590
|
+
# ```
|
591
|
+
#
|
532
592
|
# ```python async
|
533
593
|
# await element_handle.type("hello") # types instantly
|
534
594
|
# await element_handle.type("world", delay=100) # types slower, like a user
|
@@ -548,6 +608,12 @@ module Playwright
|
|
548
608
|
# await elementHandle.press('Enter');
|
549
609
|
# ```
|
550
610
|
#
|
611
|
+
# ```java
|
612
|
+
# ElementHandle elementHandle = page.querySelector("input");
|
613
|
+
# elementHandle.type("some text");
|
614
|
+
# elementHandle.press("Enter");
|
615
|
+
# ```
|
616
|
+
#
|
551
617
|
# ```python async
|
552
618
|
# element_handle = await page.query_selector("input")
|
553
619
|
# await element_handle.type("some text")
|
@@ -564,20 +630,20 @@ module Playwright
|
|
564
630
|
end
|
565
631
|
|
566
632
|
# This method checks the element by performing the following steps:
|
567
|
-
# 1. Ensure that element is a checkbox or a radio input. If not, this method
|
633
|
+
# 1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already
|
568
634
|
# unchecked, this method returns immediately.
|
569
635
|
# 1. Wait for [actionability](./actionability.md) checks on the element, unless `force` option is set.
|
570
636
|
# 1. Scroll the element into view if needed.
|
571
637
|
# 1. Use [`property: Page.mouse`] to click in the center of the element.
|
572
638
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
573
|
-
# 1. Ensure that the element is now unchecked. If not, this method
|
639
|
+
# 1. Ensure that the element is now unchecked. If not, this method throws.
|
574
640
|
#
|
575
|
-
# If the element is detached from the DOM at any moment during the action, this method
|
641
|
+
# If the element is detached from the DOM at any moment during the action, this method throws.
|
576
642
|
#
|
577
|
-
# When all steps combined have not finished during the specified `timeout`, this method
|
578
|
-
#
|
579
|
-
def uncheck(force: nil, noWaitAfter: nil, timeout: nil)
|
580
|
-
wrap_impl(@impl.uncheck(force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
643
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
|
644
|
+
# zero timeout disables this.
|
645
|
+
def uncheck(force: nil, noWaitAfter: nil, position: nil, timeout: nil)
|
646
|
+
wrap_impl(@impl.uncheck(force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
|
581
647
|
end
|
582
648
|
|
583
649
|
# Returns when the element satisfies the `state`.
|
@@ -614,6 +680,14 @@ module Playwright
|
|
614
680
|
# const span = await div.waitForSelector('span', { state: 'attached' });
|
615
681
|
# ```
|
616
682
|
#
|
683
|
+
# ```java
|
684
|
+
# page.setContent("<div><span></span></div>");
|
685
|
+
# ElementHandle div = page.querySelector("div");
|
686
|
+
# // Waiting for the "span" selector relative to the div.
|
687
|
+
# ElementHandle span = div.waitForSelector("span", new ElementHandle.WaitForSelectorOptions()
|
688
|
+
# .setState(WaitForSelectorState.ATTACHED));
|
689
|
+
# ```
|
690
|
+
#
|
617
691
|
# ```python async
|
618
692
|
# await page.set_content("<div><span></span></div>")
|
619
693
|
# div = await page.query_selector("div")
|
@@ -633,12 +707,6 @@ module Playwright
|
|
633
707
|
wrap_impl(@impl.wait_for_selector(unwrap_impl(selector), state: unwrap_impl(state), timeout: unwrap_impl(timeout)))
|
634
708
|
end
|
635
709
|
|
636
|
-
# -- inherited from EventEmitter --
|
637
|
-
# @nodoc
|
638
|
-
def off(event, callback)
|
639
|
-
event_emitter_proxy.off(event, callback)
|
640
|
-
end
|
641
|
-
|
642
710
|
# -- inherited from EventEmitter --
|
643
711
|
# @nodoc
|
644
712
|
def once(event, callback)
|
@@ -651,6 +719,12 @@ module Playwright
|
|
651
719
|
event_emitter_proxy.on(event, callback)
|
652
720
|
end
|
653
721
|
|
722
|
+
# -- inherited from EventEmitter --
|
723
|
+
# @nodoc
|
724
|
+
def off(event, callback)
|
725
|
+
event_emitter_proxy.off(event, callback)
|
726
|
+
end
|
727
|
+
|
654
728
|
private def event_emitter_proxy
|
655
729
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
656
730
|
end
|