playwright-ruby-client 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- 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 +185 -0
- data/documentation/docs/api/browser_context.md +398 -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 +74 -0
- data/documentation/docs/api/element_handle.md +640 -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 +91 -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 +51 -0
- data/documentation/docs/api/frame.md +867 -0
- data/documentation/docs/api/js_handle.md +116 -0
- data/documentation/docs/api/keyboard.md +157 -0
- data/documentation/docs/api/mouse.md +69 -0
- data/documentation/docs/api/page.md +1469 -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 +7 -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 +51 -0
- data/{docs → documentation/docs/include}/api_coverage.md +0 -0
- 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_context.rb +2 -2
- data/lib/playwright/channel_owners/element_handle.rb +2 -10
- data/lib/playwright/channel_owners/frame.rb +6 -28
- data/lib/playwright/channel_owners/js_handle.rb +2 -10
- data/lib/playwright/channel_owners/page.rb +10 -1
- 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/version.rb +1 -1
- data/lib/playwright_api/accessibility.rb +7 -89
- data/lib/playwright_api/android.rb +7 -64
- data/lib/playwright_api/android_device.rb +8 -8
- data/lib/playwright_api/browser.rb +15 -169
- data/lib/playwright_api/browser_context.rb +47 -609
- data/lib/playwright_api/browser_type.rb +13 -103
- data/lib/playwright_api/cdp_session.rb +2 -25
- data/lib/playwright_api/console_message.rb +6 -6
- data/lib/playwright_api/dialog.rb +11 -92
- data/lib/playwright_api/element_handle.rb +60 -362
- data/lib/playwright_api/file_chooser.rb +0 -28
- data/lib/playwright_api/frame.rb +74 -713
- data/lib/playwright_api/js_handle.rb +16 -90
- data/lib/playwright_api/keyboard.rb +21 -213
- data/lib/playwright_api/mouse.rb +1 -45
- data/lib/playwright_api/page.rb +155 -1635
- data/lib/playwright_api/playwright.rb +14 -117
- data/lib/playwright_api/request.rb +15 -121
- data/lib/playwright_api/response.rb +9 -9
- data/lib/playwright_api/route.rb +8 -105
- data/lib/playwright_api/selectors.rb +6 -97
- data/lib/playwright_api/tracing.rb +1 -61
- data/lib/playwright_api/web_socket.rb +1 -1
- data/lib/playwright_api/worker.rb +6 -42
- metadata +55 -4
- data/lib/playwright/javascript/function.rb +0 -67
@@ -1,36 +1,16 @@
|
|
1
1
|
module Playwright
|
2
2
|
# JSHandle represents an in-page JavaScript object. JSHandles can be created with the [`method: Page.evaluateHandle`]
|
3
3
|
# method.
|
4
|
-
#
|
5
4
|
#
|
6
|
-
# ```js
|
7
|
-
# const windowHandle = await page.evaluateHandle(() => window);
|
8
|
-
# // ...
|
9
|
-
# ```
|
10
|
-
#
|
11
|
-
# ```java
|
12
|
-
# JSHandle windowHandle = page.evaluateHandle("() => window");
|
13
|
-
# // ...
|
14
|
-
# ```
|
15
|
-
#
|
16
|
-
# ```python async
|
17
|
-
# window_handle = await page.evaluate_handle("window")
|
18
|
-
# # ...
|
19
|
-
# ```
|
20
|
-
#
|
21
5
|
# ```python sync
|
22
6
|
# window_handle = page.evaluate_handle("window")
|
23
7
|
# # ...
|
24
8
|
# ```
|
25
|
-
#
|
26
|
-
# ```csharp
|
27
|
-
# var windowHandle = await page.EvaluateHandleAsync("() => window");
|
28
|
-
# ```
|
29
|
-
#
|
9
|
+
#
|
30
10
|
# JSHandle prevents the referenced JavaScript object being garbage collected unless the handle is exposed with
|
31
11
|
# [`method: JSHandle.dispose`]. JSHandles are auto-disposed when their origin frame gets navigated or the parent context
|
32
12
|
# gets destroyed.
|
33
|
-
#
|
13
|
+
#
|
34
14
|
# JSHandle instances can be used as an argument in [`method: Page.evalOnSelector`], [`method: Page.evaluate`] and
|
35
15
|
# [`method: Page.evaluateHandle`] methods.
|
36
16
|
class JSHandle < PlaywrightApi
|
@@ -46,84 +26,38 @@ module Playwright
|
|
46
26
|
end
|
47
27
|
|
48
28
|
# Returns the return value of `expression`.
|
49
|
-
#
|
29
|
+
#
|
50
30
|
# This method passes this handle as the first argument to `expression`.
|
51
|
-
#
|
31
|
+
#
|
52
32
|
# If `expression` returns a [Promise], then `handle.evaluate` would wait for the promise to resolve and return its value.
|
53
|
-
#
|
33
|
+
#
|
54
34
|
# Examples:
|
55
|
-
#
|
56
35
|
#
|
57
|
-
# ```js
|
58
|
-
# const tweetHandle = await page.$('.tweet .retweets');
|
59
|
-
# expect(await tweetHandle.evaluate(node => node.innerText)).toBe('10 retweets');
|
60
|
-
# ```
|
61
|
-
#
|
62
|
-
# ```java
|
63
|
-
# ElementHandle tweetHandle = page.querySelector(".tweet .retweets");
|
64
|
-
# assertEquals("10 retweets", tweetHandle.evaluate("node => node.innerText"));
|
65
|
-
# ```
|
66
|
-
#
|
67
|
-
# ```python async
|
68
|
-
# tweet_handle = await page.query_selector(".tweet .retweets")
|
69
|
-
# assert await tweet_handle.evaluate("node => node.innerText") == "10 retweets"
|
70
|
-
# ```
|
71
|
-
#
|
72
36
|
# ```python sync
|
73
37
|
# tweet_handle = page.query_selector(".tweet .retweets")
|
74
38
|
# assert tweet_handle.evaluate("node => node.innerText") == "10 retweets"
|
75
39
|
# ```
|
76
|
-
#
|
77
|
-
# ```csharp
|
78
|
-
# var tweetHandle = await page.QuerySelectorAsync(".tweet .retweets");
|
79
|
-
# Assert.Equals("10 retweets", await tweetHandle.EvaluateAsync("node => node.innerText"));
|
80
|
-
# ```
|
81
40
|
def evaluate(expression, arg: nil)
|
82
41
|
wrap_impl(@impl.evaluate(unwrap_impl(expression), arg: unwrap_impl(arg)))
|
83
42
|
end
|
84
43
|
|
85
44
|
# Returns the return value of `expression` as a `JSHandle`.
|
86
|
-
#
|
45
|
+
#
|
87
46
|
# This method passes this handle as the first argument to `expression`.
|
88
|
-
#
|
47
|
+
#
|
89
48
|
# The only difference between `jsHandle.evaluate` and `jsHandle.evaluateHandle` is that `jsHandle.evaluateHandle` returns
|
90
49
|
# `JSHandle`.
|
91
|
-
#
|
50
|
+
#
|
92
51
|
# If the function passed to the `jsHandle.evaluateHandle` returns a [Promise], then `jsHandle.evaluateHandle` would wait
|
93
52
|
# for the promise to resolve and return its value.
|
94
|
-
#
|
53
|
+
#
|
95
54
|
# See [`method: Page.evaluateHandle`] for more details.
|
96
55
|
def evaluate_handle(expression, arg: nil)
|
97
56
|
wrap_impl(@impl.evaluate_handle(unwrap_impl(expression), arg: unwrap_impl(arg)))
|
98
57
|
end
|
99
58
|
|
100
59
|
# The method returns a map with **own property names** as keys and JSHandle instances for the property values.
|
101
|
-
#
|
102
60
|
#
|
103
|
-
# ```js
|
104
|
-
# const handle = await page.evaluateHandle(() => ({window, document}));
|
105
|
-
# const properties = await handle.getProperties();
|
106
|
-
# const windowHandle = properties.get('window');
|
107
|
-
# const documentHandle = properties.get('document');
|
108
|
-
# await handle.dispose();
|
109
|
-
# ```
|
110
|
-
#
|
111
|
-
# ```java
|
112
|
-
# JSHandle handle = page.evaluateHandle("() => ({window, document}"););
|
113
|
-
# Map<String, JSHandle> properties = handle.getProperties();
|
114
|
-
# JSHandle windowHandle = properties.get("window");
|
115
|
-
# JSHandle documentHandle = properties.get("document");
|
116
|
-
# handle.dispose();
|
117
|
-
# ```
|
118
|
-
#
|
119
|
-
# ```python async
|
120
|
-
# handle = await page.evaluate_handle("{window, document}")
|
121
|
-
# properties = await handle.get_properties()
|
122
|
-
# window_handle = properties.get("window")
|
123
|
-
# document_handle = properties.get("document")
|
124
|
-
# await handle.dispose()
|
125
|
-
# ```
|
126
|
-
#
|
127
61
|
# ```python sync
|
128
62
|
# handle = page.evaluate_handle("{window, document}")
|
129
63
|
# properties = handle.get_properties()
|
@@ -131,14 +65,6 @@ module Playwright
|
|
131
65
|
# document_handle = properties.get("document")
|
132
66
|
# handle.dispose()
|
133
67
|
# ```
|
134
|
-
#
|
135
|
-
# ```csharp
|
136
|
-
# var handle = await page.EvaluateHandleAsync("() => ({window, document}");
|
137
|
-
# var properties = await handle.GetPropertiesAsync();
|
138
|
-
# var windowHandle = properties["window"];
|
139
|
-
# var documentHandle = properties["document"];
|
140
|
-
# await handle.DisposeAsync();
|
141
|
-
# ```
|
142
68
|
def get_properties
|
143
69
|
wrap_impl(@impl.get_properties)
|
144
70
|
end
|
@@ -150,7 +76,7 @@ module Playwright
|
|
150
76
|
end
|
151
77
|
|
152
78
|
# Returns a JSON representation of the object. If the object has a `toJSON` function, it **will not be called**.
|
153
|
-
#
|
79
|
+
#
|
154
80
|
# > NOTE: The method will return an empty JSON object if the referenced object is not stringifiable. It will throw an
|
155
81
|
# error if the object has circular references.
|
156
82
|
def json_value
|
@@ -164,20 +90,20 @@ module Playwright
|
|
164
90
|
|
165
91
|
# -- inherited from EventEmitter --
|
166
92
|
# @nodoc
|
167
|
-
def
|
168
|
-
event_emitter_proxy.
|
93
|
+
def on(event, callback)
|
94
|
+
event_emitter_proxy.on(event, callback)
|
169
95
|
end
|
170
96
|
|
171
97
|
# -- inherited from EventEmitter --
|
172
98
|
# @nodoc
|
173
|
-
def
|
174
|
-
event_emitter_proxy.
|
99
|
+
def off(event, callback)
|
100
|
+
event_emitter_proxy.off(event, callback)
|
175
101
|
end
|
176
102
|
|
177
103
|
# -- inherited from EventEmitter --
|
178
104
|
# @nodoc
|
179
|
-
def
|
180
|
-
event_emitter_proxy.
|
105
|
+
def once(event, callback)
|
106
|
+
event_emitter_proxy.once(event, callback)
|
181
107
|
end
|
182
108
|
|
183
109
|
private def event_emitter_proxy
|
@@ -1,48 +1,12 @@
|
|
1
1
|
module Playwright
|
2
2
|
# Keyboard provides an api for managing a virtual keyboard. The high level api is [`method: Keyboard.type`], which takes
|
3
3
|
# raw characters and generates proper keydown, keypress/input, and keyup events on your page.
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# For finer control, you can use [`method: Keyboard.down`], [`method: Keyboard.up`], and [`method: Keyboard.insertText`]
|
6
6
|
# to manually fire events as if they were generated from a real keyboard.
|
7
|
-
#
|
7
|
+
#
|
8
8
|
# An example of holding down `Shift` in order to select and delete some text:
|
9
|
-
#
|
10
9
|
#
|
11
|
-
# ```js
|
12
|
-
# await page.keyboard.type('Hello World!');
|
13
|
-
# await page.keyboard.press('ArrowLeft');
|
14
|
-
#
|
15
|
-
# await page.keyboard.down('Shift');
|
16
|
-
# for (let i = 0; i < ' World'.length; i++)
|
17
|
-
# await page.keyboard.press('ArrowLeft');
|
18
|
-
# await page.keyboard.up('Shift');
|
19
|
-
#
|
20
|
-
# await page.keyboard.press('Backspace');
|
21
|
-
# // Result text will end up saying 'Hello!'
|
22
|
-
# ```
|
23
|
-
#
|
24
|
-
# ```java
|
25
|
-
# page.keyboard().type("Hello World!");
|
26
|
-
# page.keyboard().press("ArrowLeft");
|
27
|
-
# page.keyboard().down("Shift");
|
28
|
-
# for (int i = 0; i < " World".length(); i++)
|
29
|
-
# page.keyboard().press("ArrowLeft");
|
30
|
-
# page.keyboard().up("Shift");
|
31
|
-
# page.keyboard().press("Backspace");
|
32
|
-
# // Result text will end up saying "Hello!"
|
33
|
-
# ```
|
34
|
-
#
|
35
|
-
# ```python async
|
36
|
-
# await page.keyboard.type("Hello World!")
|
37
|
-
# await page.keyboard.press("ArrowLeft")
|
38
|
-
# await page.keyboard.down("Shift")
|
39
|
-
# for i in range(6):
|
40
|
-
# await page.keyboard.press("ArrowLeft")
|
41
|
-
# await page.keyboard.up("Shift")
|
42
|
-
# await page.keyboard.press("Backspace")
|
43
|
-
# # result text will end up saying "Hello!"
|
44
|
-
# ```
|
45
|
-
#
|
46
10
|
# ```python sync
|
47
11
|
# page.keyboard.type("Hello World!")
|
48
12
|
# page.keyboard.press("ArrowLeft")
|
@@ -53,144 +17,59 @@ module Playwright
|
|
53
17
|
# page.keyboard.press("Backspace")
|
54
18
|
# # result text will end up saying "Hello!"
|
55
19
|
# ```
|
56
|
-
#
|
57
|
-
# ```csharp
|
58
|
-
# await page.Keyboard.TypeAsync("Hello World!");
|
59
|
-
# await page.Keyboard.PressAsync("ArrowLeft");
|
60
|
-
#
|
61
|
-
# await page.Keyboard.DownAsync("Shift");
|
62
|
-
# for (int i = 0; i < " World".Length; i++)
|
63
|
-
# await page.Keyboard.PressAsync("ArrowLeft");
|
64
|
-
#
|
65
|
-
# await page.Keyboard.UpAsync("Shift");
|
66
|
-
#
|
67
|
-
# await page.Keyboard.PressAsync("Backspace");
|
68
|
-
# // Result text will end up saying "Hello!"
|
69
|
-
# ```
|
70
|
-
#
|
20
|
+
#
|
71
21
|
# An example of pressing uppercase `A`
|
72
|
-
#
|
73
22
|
#
|
74
|
-
# ```js
|
75
|
-
# await page.keyboard.press('Shift+KeyA');
|
76
|
-
# // or
|
77
|
-
# await page.keyboard.press('Shift+A');
|
78
|
-
# ```
|
79
|
-
#
|
80
|
-
# ```java
|
81
|
-
# page.keyboard().press("Shift+KeyA");
|
82
|
-
# // or
|
83
|
-
# page.keyboard().press("Shift+A");
|
84
|
-
# ```
|
85
|
-
#
|
86
|
-
# ```python async
|
87
|
-
# await page.keyboard.press("Shift+KeyA")
|
88
|
-
# # or
|
89
|
-
# await page.keyboard.press("Shift+A")
|
90
|
-
# ```
|
91
|
-
#
|
92
23
|
# ```python sync
|
93
24
|
# page.keyboard.press("Shift+KeyA")
|
94
25
|
# # or
|
95
26
|
# page.keyboard.press("Shift+A")
|
96
27
|
# ```
|
97
|
-
#
|
98
|
-
# ```csharp
|
99
|
-
# await page.Keyboard.PressAsync("Shift+KeyA");
|
100
|
-
# // or
|
101
|
-
# await page.Keyboard.PressAsync("Shift+A");
|
102
|
-
# ```
|
103
|
-
#
|
28
|
+
#
|
104
29
|
# An example to trigger select-all with the keyboard
|
105
|
-
#
|
106
30
|
#
|
107
|
-
# ```js
|
108
|
-
# // on Windows and Linux
|
109
|
-
# await page.keyboard.press('Control+A');
|
110
|
-
# // on macOS
|
111
|
-
# await page.keyboard.press('Meta+A');
|
112
|
-
# ```
|
113
|
-
#
|
114
|
-
# ```java
|
115
|
-
# // on Windows and Linux
|
116
|
-
# page.keyboard().press("Control+A");
|
117
|
-
# // on macOS
|
118
|
-
# page.keyboard().press("Meta+A");
|
119
|
-
# ```
|
120
|
-
#
|
121
|
-
# ```python async
|
122
|
-
# # on windows and linux
|
123
|
-
# await page.keyboard.press("Control+A")
|
124
|
-
# # on mac_os
|
125
|
-
# await page.keyboard.press("Meta+A")
|
126
|
-
# ```
|
127
|
-
#
|
128
31
|
# ```python sync
|
129
32
|
# # on windows and linux
|
130
33
|
# page.keyboard.press("Control+A")
|
131
34
|
# # on mac_os
|
132
35
|
# page.keyboard.press("Meta+A")
|
133
36
|
# ```
|
134
|
-
#
|
135
|
-
# ```csharp
|
136
|
-
# // on Windows and Linux
|
137
|
-
# await page.Keyboard.PressAsync("Control+A");
|
138
|
-
# // on macOS
|
139
|
-
# await page.Keyboard.PressAsync("Meta+A");
|
140
|
-
# ```
|
141
37
|
class Keyboard < PlaywrightApi
|
142
38
|
|
143
39
|
# Dispatches a `keydown` event.
|
144
|
-
#
|
40
|
+
#
|
145
41
|
# `key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)
|
146
42
|
# value or a single character to generate the text for. A superset of the `key` values can be found
|
147
43
|
# [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
|
148
|
-
#
|
44
|
+
#
|
149
45
|
# `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
|
150
46
|
# `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
|
151
|
-
#
|
47
|
+
#
|
152
48
|
# Following modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`.
|
153
|
-
#
|
49
|
+
#
|
154
50
|
# Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
|
155
|
-
#
|
51
|
+
#
|
156
52
|
# If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
|
157
53
|
# texts.
|
158
|
-
#
|
54
|
+
#
|
159
55
|
# If `key` is a modifier key, `Shift`, `Meta`, `Control`, or `Alt`, subsequent key presses will be sent with that modifier
|
160
56
|
# active. To release the modifier key, use [`method: Keyboard.up`].
|
161
|
-
#
|
57
|
+
#
|
162
58
|
# After the key is pressed once, subsequent calls to [`method: Keyboard.down`] will have
|
163
59
|
# [repeat](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat) set to true. To release the key, use
|
164
60
|
# [`method: Keyboard.up`].
|
165
|
-
#
|
61
|
+
#
|
166
62
|
# > NOTE: Modifier keys DO influence `keyboard.down`. Holding down `Shift` will type the text in upper case.
|
167
63
|
def down(key)
|
168
64
|
wrap_impl(@impl.down(unwrap_impl(key)))
|
169
65
|
end
|
170
66
|
|
171
67
|
# Dispatches only `input` event, does not emit the `keydown`, `keyup` or `keypress` events.
|
172
|
-
#
|
173
68
|
#
|
174
|
-
# ```js
|
175
|
-
# page.keyboard.insertText('嗨');
|
176
|
-
# ```
|
177
|
-
#
|
178
|
-
# ```java
|
179
|
-
# page.keyboard().insertText("嗨");
|
180
|
-
# ```
|
181
|
-
#
|
182
|
-
# ```python async
|
183
|
-
# await page.keyboard.insert_text("嗨")
|
184
|
-
# ```
|
185
|
-
#
|
186
69
|
# ```python sync
|
187
70
|
# page.keyboard.insert_text("嗨")
|
188
71
|
# ```
|
189
|
-
#
|
190
|
-
# ```csharp
|
191
|
-
# await page.Keyboard.PressAsync("嗨");
|
192
|
-
# ```
|
193
|
-
#
|
72
|
+
#
|
194
73
|
# > NOTE: Modifier keys DO NOT effect `keyboard.insertText`. Holding down `Shift` will not type the text in upper case.
|
195
74
|
def insert_text(text)
|
196
75
|
wrap_impl(@impl.insert_text(unwrap_impl(text)))
|
@@ -199,57 +78,20 @@ module Playwright
|
|
199
78
|
# `key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)
|
200
79
|
# value or a single character to generate the text for. A superset of the `key` values can be found
|
201
80
|
# [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
|
202
|
-
#
|
81
|
+
#
|
203
82
|
# `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
|
204
83
|
# `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
|
205
|
-
#
|
84
|
+
#
|
206
85
|
# Following modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`.
|
207
|
-
#
|
86
|
+
#
|
208
87
|
# Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
|
209
|
-
#
|
88
|
+
#
|
210
89
|
# If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
|
211
90
|
# texts.
|
212
|
-
#
|
91
|
+
#
|
213
92
|
# Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
|
214
93
|
# modifier, modifier is pressed and being held while the subsequent key is being pressed.
|
215
|
-
#
|
216
94
|
#
|
217
|
-
# ```js
|
218
|
-
# const page = await browser.newPage();
|
219
|
-
# await page.goto('https://keycode.info');
|
220
|
-
# await page.keyboard.press('A');
|
221
|
-
# await page.screenshot({ path: 'A.png' });
|
222
|
-
# await page.keyboard.press('ArrowLeft');
|
223
|
-
# await page.screenshot({ path: 'ArrowLeft.png' });
|
224
|
-
# await page.keyboard.press('Shift+O');
|
225
|
-
# await page.screenshot({ path: 'O.png' });
|
226
|
-
# await browser.close();
|
227
|
-
# ```
|
228
|
-
#
|
229
|
-
# ```java
|
230
|
-
# Page page = browser.newPage();
|
231
|
-
# page.navigate("https://keycode.info");
|
232
|
-
# page.keyboard().press("A");
|
233
|
-
# page.screenshot(new Page.ScreenshotOptions().setPath(Paths.get("A.png"));
|
234
|
-
# page.keyboard().press("ArrowLeft");
|
235
|
-
# page.screenshot(new Page.ScreenshotOptions().setPath(Paths.get("ArrowLeft.png")));
|
236
|
-
# page.keyboard().press("Shift+O");
|
237
|
-
# page.screenshot(new Page.ScreenshotOptions().setPath(Paths.get("O.png")));
|
238
|
-
# browser.close();
|
239
|
-
# ```
|
240
|
-
#
|
241
|
-
# ```python async
|
242
|
-
# page = await browser.new_page()
|
243
|
-
# await page.goto("https://keycode.info")
|
244
|
-
# await page.keyboard.press("a")
|
245
|
-
# await page.screenshot(path="a.png")
|
246
|
-
# await page.keyboard.press("ArrowLeft")
|
247
|
-
# await page.screenshot(path="arrow_left.png")
|
248
|
-
# await page.keyboard.press("Shift+O")
|
249
|
-
# await page.screenshot(path="o.png")
|
250
|
-
# await browser.close()
|
251
|
-
# ```
|
252
|
-
#
|
253
95
|
# ```python sync
|
254
96
|
# page = browser.new_page()
|
255
97
|
# page.goto("https://keycode.info")
|
@@ -261,55 +103,21 @@ module Playwright
|
|
261
103
|
# page.screenshot(path="o.png")
|
262
104
|
# browser.close()
|
263
105
|
# ```
|
264
|
-
#
|
265
|
-
# ```csharp
|
266
|
-
# await page.GotoAsync("https://keycode.info");
|
267
|
-
# await page.Keyboard.PressAsync("A");
|
268
|
-
# await page.ScreenshotAsync("A.png");
|
269
|
-
# await page.Keyboard.PressAsync("ArrowLeft");
|
270
|
-
# await page.ScreenshotAsync("ArrowLeft.png");
|
271
|
-
# await page.Keyboard.PressAsync("Shift+O");
|
272
|
-
# await page.ScreenshotAsync("O.png");
|
273
|
-
# await browser.CloseAsync();
|
274
|
-
# ```
|
275
|
-
#
|
106
|
+
#
|
276
107
|
# Shortcut for [`method: Keyboard.down`] and [`method: Keyboard.up`].
|
277
108
|
def press(key, delay: nil)
|
278
109
|
wrap_impl(@impl.press(unwrap_impl(key), delay: unwrap_impl(delay)))
|
279
110
|
end
|
280
111
|
|
281
112
|
# Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
|
282
|
-
#
|
113
|
+
#
|
283
114
|
# To press a special key, like `Control` or `ArrowDown`, use [`method: Keyboard.press`].
|
284
|
-
#
|
285
115
|
#
|
286
|
-
# ```js
|
287
|
-
# await page.keyboard.type('Hello'); // Types instantly
|
288
|
-
# await page.keyboard.type('World', {delay: 100}); // Types slower, like a user
|
289
|
-
# ```
|
290
|
-
#
|
291
|
-
# ```java
|
292
|
-
# // Types instantly
|
293
|
-
# page.keyboard().type("Hello");
|
294
|
-
# // Types slower, like a user
|
295
|
-
# page.keyboard().type("World", new Keyboard.TypeOptions().setDelay(100));
|
296
|
-
# ```
|
297
|
-
#
|
298
|
-
# ```python async
|
299
|
-
# await page.keyboard.type("Hello") # types instantly
|
300
|
-
# await page.keyboard.type("World", delay=100) # types slower, like a user
|
301
|
-
# ```
|
302
|
-
#
|
303
116
|
# ```python sync
|
304
117
|
# page.keyboard.type("Hello") # types instantly
|
305
118
|
# page.keyboard.type("World", delay=100) # types slower, like a user
|
306
119
|
# ```
|
307
|
-
#
|
308
|
-
# ```csharp
|
309
|
-
# await page.Keyboard.TypeAsync("Hello"); // types instantly
|
310
|
-
# await page.Keyboard.TypeAsync("World"); // types slower, like a user
|
311
|
-
# ```
|
312
|
-
#
|
120
|
+
#
|
313
121
|
# > NOTE: Modifier keys DO NOT effect `keyboard.type`. Holding down `Shift` will not type the text in upper case.
|
314
122
|
# > NOTE: For characters that are not on a US keyboard, only an `input` event will be sent.
|
315
123
|
def type(text, delay: nil)
|