playwright-ruby-client 1.28.1 → 1.29.1.alpha1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/documentation/docs/api/accessibility.md +9 -14
- data/documentation/docs/api/api_request_context.md +44 -41
- data/documentation/docs/api/api_response.md +13 -3
- data/documentation/docs/api/browser.md +24 -23
- data/documentation/docs/api/browser_context.md +71 -45
- data/documentation/docs/api/browser_type.md +21 -14
- data/documentation/docs/api/cdp_session.md +3 -5
- data/documentation/docs/api/console_message.md +7 -4
- data/documentation/docs/api/dialog.md +9 -5
- data/documentation/docs/api/download.md +19 -11
- data/documentation/docs/api/element_handle.md +125 -116
- data/documentation/docs/api/experimental/android.md +4 -5
- data/documentation/docs/api/experimental/android_device.md +11 -2
- data/documentation/docs/api/experimental/android_input.md +5 -0
- data/documentation/docs/api/file_chooser.md +6 -3
- data/documentation/docs/api/frame.md +182 -171
- data/documentation/docs/api/frame_locator.md +27 -38
- data/documentation/docs/api/js_handle.md +16 -10
- data/documentation/docs/api/keyboard.md +29 -16
- data/documentation/docs/api/locator.md +189 -140
- data/documentation/docs/api/mouse.md +9 -4
- data/documentation/docs/api/page.md +304 -289
- data/documentation/docs/api/playwright.md +8 -5
- data/documentation/docs/api/request.md +34 -15
- data/documentation/docs/api/response.md +27 -10
- data/documentation/docs/api/route.md +44 -12
- data/documentation/docs/api/selectors.md +5 -3
- data/documentation/docs/api/touchscreen.md +2 -0
- data/documentation/docs/api/tracing.md +11 -11
- data/documentation/docs/api/web_socket.md +9 -4
- data/documentation/docs/api/worker.md +12 -11
- data/documentation/docs/include/api_coverage.md +2 -0
- data/lib/playwright/channel_owners/api_request_context.rb +37 -2
- data/lib/playwright/channel_owners/browser_context.rb +22 -26
- data/lib/playwright/channel_owners/page.rb +35 -25
- data/lib/playwright/channel_owners/route.rb +28 -8
- data/lib/playwright/event_emitter.rb +6 -1
- data/lib/playwright/locator_impl.rb +8 -0
- data/lib/playwright/select_option_values.rb +2 -0
- data/lib/playwright/version.rb +2 -2
- data/lib/playwright_api/accessibility.rb +9 -13
- data/lib/playwright_api/android.rb +14 -12
- data/lib/playwright_api/android_device.rb +38 -13
- data/lib/playwright_api/android_input.rb +5 -0
- data/lib/playwright_api/android_socket.rb +4 -2
- data/lib/playwright_api/android_web_view.rb +5 -2
- data/lib/playwright_api/api_request.rb +6 -3
- data/lib/playwright_api/api_request_context.rb +52 -42
- data/lib/playwright_api/api_response.rb +13 -2
- data/lib/playwright_api/browser.rb +30 -22
- data/lib/playwright_api/browser_context.rb +82 -45
- data/lib/playwright_api/browser_type.rb +29 -19
- data/lib/playwright_api/cdp_session.rb +9 -10
- data/lib/playwright_api/console_message.rb +13 -8
- data/lib/playwright_api/dialog.rb +14 -10
- data/lib/playwright_api/download.rb +19 -9
- data/lib/playwright_api/element_handle.rb +122 -99
- data/lib/playwright_api/file_chooser.rb +6 -1
- data/lib/playwright_api/frame.rb +186 -141
- data/lib/playwright_api/frame_locator.rb +29 -32
- data/lib/playwright_api/js_handle.rb +22 -12
- data/lib/playwright_api/keyboard.rb +29 -14
- data/lib/playwright_api/locator.rb +183 -112
- data/lib/playwright_api/mouse.rb +9 -2
- data/lib/playwright_api/page.rb +307 -259
- data/lib/playwright_api/playwright.rb +17 -10
- data/lib/playwright_api/request.rb +40 -13
- data/lib/playwright_api/response.rb +33 -16
- data/lib/playwright_api/route.rb +50 -17
- data/lib/playwright_api/selectors.rb +12 -7
- data/lib/playwright_api/touchscreen.rb +2 -0
- data/lib/playwright_api/tracing.rb +17 -11
- data/lib/playwright_api/web_socket.rb +15 -10
- data/lib/playwright_api/worker.rb +20 -17
- data/playwright.gemspec +2 -2
- data/sig/playwright.rbs +559 -0
- metadata +10 -9
@@ -4,9 +4,8 @@ sidebar_position: 10
|
|
4
4
|
|
5
5
|
# FrameLocator
|
6
6
|
|
7
|
-
|
8
|
-
and locate elements in that iframe. FrameLocator can be created with either [Page#frame_locator](./page#frame_locator) or
|
9
|
-
[Locator#frame_locator](./locator#frame_locator) method.
|
7
|
+
|
8
|
+
FrameLocator represents a view to the `iframe` on the page. It captures the logic sufficient to retrieve the `iframe` and locate elements in that iframe. FrameLocator can be created with either [Page#frame_locator](./page#frame_locator) or [Locator#frame_locator](./locator#frame_locator) method.
|
10
9
|
|
11
10
|
```ruby
|
12
11
|
locator = page.frame_locator("my-frame").get_by_text("Submit")
|
@@ -15,8 +14,7 @@ locator.click
|
|
15
14
|
|
16
15
|
**Strictness**
|
17
16
|
|
18
|
-
Frame locators are strict. This means that all operations on frame locators will throw if more than one element matches
|
19
|
-
a given selector.
|
17
|
+
Frame locators are strict. This means that all operations on frame locators will throw if more than one element matches a given selector.
|
20
18
|
|
21
19
|
```ruby
|
22
20
|
# Throws if there are several frames in DOM:
|
@@ -28,21 +26,19 @@ page.frame_locator('.result-frame').first.get_by_role('button').click
|
|
28
26
|
|
29
27
|
**Converting Locator to FrameLocator**
|
30
28
|
|
31
|
-
If you have a [Locator](./locator) object pointing to an `iframe` it can be converted to [FrameLocator](./frame_locator) using
|
32
|
-
[`:scope`](https://developer.mozilla.org/en-US/docs/Web/CSS/:scope) CSS selector:
|
29
|
+
If you have a [Locator](./locator) object pointing to an `iframe` it can be converted to [FrameLocator](./frame_locator) using [`:scope`](https://developer.mozilla.org/en-US/docs/Web/CSS/:scope) CSS selector:
|
33
30
|
|
34
31
|
```ruby
|
35
32
|
frame_locator = locator.frame_locator(':scope')
|
36
33
|
```
|
37
34
|
|
38
|
-
|
39
|
-
|
40
35
|
## first
|
41
36
|
|
42
37
|
```
|
43
38
|
def first
|
44
39
|
```
|
45
40
|
|
41
|
+
|
46
42
|
Returns locator to the first matching frame.
|
47
43
|
|
48
44
|
## frame_locator
|
@@ -51,8 +47,9 @@ Returns locator to the first matching frame.
|
|
51
47
|
def frame_locator(selector)
|
52
48
|
```
|
53
49
|
|
54
|
-
|
55
|
-
that iframe
|
50
|
+
|
51
|
+
When working with iframes, you can create a frame locator that will enter the iframe and allow selecting elements
|
52
|
+
in that iframe.
|
56
53
|
|
57
54
|
## get_by_alt_text
|
58
55
|
|
@@ -60,42 +57,40 @@ that iframe.
|
|
60
57
|
def get_by_alt_text(text, exact: nil)
|
61
58
|
```
|
62
59
|
|
60
|
+
|
63
61
|
Allows locating elements by their alt text. For example, this method will find the image by alt text "Castle":
|
64
62
|
|
65
63
|
```html
|
66
64
|
<img alt='Castle'>
|
67
65
|
```
|
68
66
|
|
69
|
-
|
70
67
|
## get_by_label
|
71
68
|
|
72
69
|
```
|
73
70
|
def get_by_label(text, exact: nil)
|
74
71
|
```
|
75
72
|
|
76
|
-
|
77
|
-
label text "Password" in the following DOM:
|
73
|
+
|
74
|
+
Allows locating input elements by the text of the associated label. For example, this method will find the input by label text "Password" in the following DOM:
|
78
75
|
|
79
76
|
```html
|
80
77
|
<label for="password-input">Password:</label>
|
81
78
|
<input id="password-input">
|
82
79
|
```
|
83
80
|
|
84
|
-
|
85
81
|
## get_by_placeholder
|
86
82
|
|
87
83
|
```
|
88
84
|
def get_by_placeholder(text, exact: nil)
|
89
85
|
```
|
90
86
|
|
91
|
-
|
92
|
-
"Country":
|
87
|
+
|
88
|
+
Allows locating input elements by the placeholder text. For example, this method will find the input by placeholder "Country":
|
93
89
|
|
94
90
|
```html
|
95
91
|
<input placeholder="Country">
|
96
92
|
```
|
97
93
|
|
98
|
-
|
99
94
|
## get_by_role
|
100
95
|
|
101
96
|
```
|
@@ -112,15 +107,10 @@ def get_by_role(
|
|
112
107
|
selected: nil)
|
113
108
|
```
|
114
109
|
|
115
|
-
Allows locating elements by their [ARIA role](https://www.w3.org/TR/wai-aria-1.2/#roles),
|
116
|
-
[ARIA attributes](https://www.w3.org/TR/wai-aria-1.2/#aria-attributes) and
|
117
|
-
[accessible name](https://w3c.github.io/accname/#dfn-accessible-name). Note that role selector **does not replace**
|
118
|
-
accessibility audits and conformance tests, but rather gives early feedback about the ARIA guidelines.
|
119
110
|
|
120
|
-
Note that
|
121
|
-
|
122
|
-
can find all the [supported roles here](https://www.w3.org/TR/wai-aria-1.2/#role_definitions). ARIA guidelines **do not
|
123
|
-
recommend** duplicating implicit roles and attributes by setting `role` and/or `aria-*` attributes to default values.
|
111
|
+
Allows locating elements by their [ARIA role](https://www.w3.org/TR/wai-aria-1.2/#roles), [ARIA attributes](https://www.w3.org/TR/wai-aria-1.2/#aria-attributes) and [accessible name](https://w3c.github.io/accname/#dfn-accessible-name). Note that role selector **does not replace** accessibility audits and conformance tests, but rather gives early feedback about the ARIA guidelines.
|
112
|
+
|
113
|
+
Note that many html elements have an implicitly [defined role](https://w3c.github.io/html-aam/#html-element-role-mappings) that is recognized by the role selector. You can find all the [supported roles here](https://www.w3.org/TR/wai-aria-1.2/#role_definitions). ARIA guidelines **do not recommend** duplicating implicit roles and attributes by setting `role` and/or `aria-*` attributes to default values.
|
124
114
|
|
125
115
|
## get_by_test_id
|
126
116
|
|
@@ -128,10 +118,8 @@ recommend** duplicating implicit roles and attributes by setting `role` and/or `
|
|
128
118
|
def get_by_test_id(testId)
|
129
119
|
```
|
130
120
|
|
131
|
-
Locate element by the test id. By default, the `data-testid` attribute is used as a test id. Use
|
132
|
-
[Selectors#set_test_id_attribute](./selectors#set_test_id_attribute) to configure a different test id attribute if necessary.
|
133
|
-
|
134
121
|
|
122
|
+
Locate element by the test id. By default, the `data-testid` attribute is used as a test id. Use [Selectors#set_test_id_attribute](./selectors#set_test_id_attribute) to configure a different test id attribute if necessary.
|
135
123
|
|
136
124
|
## get_by_text
|
137
125
|
|
@@ -139,6 +127,7 @@ Locate element by the test id. By default, the `data-testid` attribute is used a
|
|
139
127
|
def get_by_text(text, exact: nil)
|
140
128
|
```
|
141
129
|
|
130
|
+
|
142
131
|
Allows locating elements that contain given text. Consider the following DOM structure:
|
143
132
|
|
144
133
|
```html
|
@@ -177,13 +166,11 @@ locator = page.get_by_text(/^hello$/i)
|
|
177
166
|
expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
|
178
167
|
```
|
179
168
|
|
180
|
-
See also [Locator#filter](./locator#filter) that allows to match by another criteria, like an accessible role, and then filter
|
181
|
-
|
169
|
+
See also [Locator#filter](./locator#filter) that allows to match by another criteria, like an accessible role, and then filter by the text content.
|
170
|
+
|
171
|
+
**NOTE**: Matching by text always normalizes whitespace, even with exact match. For example, it turns multiple spaces into one, turns line breaks into spaces and ignores leading and trailing whitespace.
|
182
172
|
|
183
|
-
|
184
|
-
one, turns line breaks into spaces and ignores leading and trailing whitespace.
|
185
|
-
> NOTE: Input elements of the type `button` and `submit` are matched by their `value` instead of the text content. For
|
186
|
-
example, locating by text `"Log in"` matches `<input type=button value="Log in">`.
|
173
|
+
**NOTE**: Input elements of the type `button` and `submit` are matched by their `value` instead of the text content. For example, locating by text `"Log in"` matches `<input type=button value="Log in">`.
|
187
174
|
|
188
175
|
## get_by_title
|
189
176
|
|
@@ -191,19 +178,20 @@ example, locating by text `"Log in"` matches `<input type=button value="Log in">
|
|
191
178
|
def get_by_title(text, exact: nil)
|
192
179
|
```
|
193
180
|
|
181
|
+
|
194
182
|
Allows locating elements by their title. For example, this method will find the button by its title "Place the order":
|
195
183
|
|
196
184
|
```html
|
197
185
|
<button title='Place the order'>Order Now</button>
|
198
186
|
```
|
199
187
|
|
200
|
-
|
201
188
|
## last
|
202
189
|
|
203
190
|
```
|
204
191
|
def last
|
205
192
|
```
|
206
193
|
|
194
|
+
|
207
195
|
Returns locator to the last matching frame.
|
208
196
|
|
209
197
|
## locator
|
@@ -212,8 +200,8 @@ Returns locator to the last matching frame.
|
|
212
200
|
def locator(selector, has: nil, hasText: nil)
|
213
201
|
```
|
214
202
|
|
215
|
-
|
216
|
-
similar to [Locator#filter](./locator#filter) method.
|
203
|
+
|
204
|
+
The method finds an element matching the specified selector in the locator's subtree. It also accepts filter options, similar to [Locator#filter](./locator#filter) method.
|
217
205
|
|
218
206
|
[Learn more about locators](https://playwright.dev/python/docs/locators).
|
219
207
|
|
@@ -223,4 +211,5 @@ similar to [Locator#filter](./locator#filter) method.
|
|
223
211
|
def nth(index)
|
224
212
|
```
|
225
213
|
|
214
|
+
|
226
215
|
Returns locator to the n-th matching frame. It's zero based, `nth(0)` selects the first frame.
|
@@ -4,6 +4,7 @@ sidebar_position: 10
|
|
4
4
|
|
5
5
|
# JSHandle
|
6
6
|
|
7
|
+
|
7
8
|
JSHandle represents an in-page JavaScript object. JSHandles can be created with the [Page#evaluate_handle](./page#evaluate_handle)
|
8
9
|
method.
|
9
10
|
|
@@ -25,6 +26,7 @@ JSHandle instances can be used as an argument in [Page#eval_on_selector](./page#
|
|
25
26
|
def as_element
|
26
27
|
```
|
27
28
|
|
29
|
+
|
28
30
|
Returns either `null` or the object handle itself, if the object handle is an instance of [ElementHandle](./element_handle).
|
29
31
|
|
30
32
|
## dispose
|
@@ -33,6 +35,7 @@ Returns either `null` or the object handle itself, if the object handle is an in
|
|
33
35
|
def dispose
|
34
36
|
```
|
35
37
|
|
38
|
+
|
36
39
|
The `jsHandle.dispose` method stops referencing the element handle.
|
37
40
|
|
38
41
|
## evaluate
|
@@ -41,33 +44,33 @@ The `jsHandle.dispose` method stops referencing the element handle.
|
|
41
44
|
def evaluate(expression, arg: nil)
|
42
45
|
```
|
43
46
|
|
47
|
+
|
44
48
|
Returns the return value of `expression`.
|
45
49
|
|
46
50
|
This method passes this handle as the first argument to `expression`.
|
47
51
|
|
48
|
-
If `expression` returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), then `handle.evaluate` would wait for the promise to resolve and return
|
52
|
+
If `expression` returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), then `handle.evaluate` would wait for the promise to resolve and return
|
53
|
+
its value.
|
49
54
|
|
50
|
-
|
55
|
+
**Usage**
|
51
56
|
|
52
57
|
```ruby
|
53
58
|
tweet_handle = page.query_selector(".tweet .retweets")
|
54
59
|
tweet_handle.evaluate("node => node.innerText") # => "10 retweets"
|
55
60
|
```
|
56
61
|
|
57
|
-
|
58
|
-
|
59
62
|
## evaluate_handle
|
60
63
|
|
61
64
|
```
|
62
65
|
def evaluate_handle(expression, arg: nil)
|
63
66
|
```
|
64
67
|
|
68
|
+
|
65
69
|
Returns the return value of `expression` as a [JSHandle](./js_handle).
|
66
70
|
|
67
71
|
This method passes this handle as the first argument to `expression`.
|
68
72
|
|
69
|
-
The only difference between [JSHandle#evaluate](./js_handle#evaluate) and [JSHandle#evaluate_handle](./js_handle#evaluate_handle) is that [JSHandle#evaluate_handle](./js_handle#evaluate_handle) returns
|
70
|
-
[JSHandle](./js_handle).
|
73
|
+
The only difference between [JSHandle#evaluate](./js_handle#evaluate) and [JSHandle#evaluate_handle](./js_handle#evaluate_handle) is that [JSHandle#evaluate_handle](./js_handle#evaluate_handle) returns [JSHandle](./js_handle).
|
71
74
|
|
72
75
|
If the function passed to the [JSHandle#evaluate_handle](./js_handle#evaluate_handle) returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), then [JSHandle#evaluate_handle](./js_handle#evaluate_handle) would wait
|
73
76
|
for the promise to resolve and return its value.
|
@@ -81,8 +84,11 @@ def get_properties
|
|
81
84
|
```
|
82
85
|
alias: `properties`
|
83
86
|
|
87
|
+
|
84
88
|
The method returns a map with **own property names** as keys and JSHandle instances for the property values.
|
85
89
|
|
90
|
+
**Usage**
|
91
|
+
|
86
92
|
```ruby
|
87
93
|
page.goto('https://example.com/')
|
88
94
|
handle = page.evaluate_handle("({window, document})")
|
@@ -93,14 +99,13 @@ document_handle = properties["document"]
|
|
93
99
|
handle.dispose
|
94
100
|
```
|
95
101
|
|
96
|
-
|
97
|
-
|
98
102
|
## get_property
|
99
103
|
|
100
104
|
```
|
101
105
|
def get_property(propertyName)
|
102
106
|
```
|
103
107
|
|
108
|
+
|
104
109
|
Fetches a single property from the referenced object.
|
105
110
|
|
106
111
|
## json_value
|
@@ -109,7 +114,8 @@ Fetches a single property from the referenced object.
|
|
109
114
|
def json_value
|
110
115
|
```
|
111
116
|
|
117
|
+
|
112
118
|
Returns a JSON representation of the object. If the object has a `toJSON` function, it **will not be called**.
|
113
119
|
|
114
|
-
|
115
|
-
|
120
|
+
**NOTE**: The method will return an empty JSON object if the referenced object is not stringifiable. It will throw an error if the
|
121
|
+
object has circular references.
|
@@ -4,6 +4,7 @@ sidebar_position: 10
|
|
4
4
|
|
5
5
|
# Keyboard
|
6
6
|
|
7
|
+
|
7
8
|
Keyboard provides an api for managing a virtual keyboard. The high level api is [Keyboard#type](./keyboard#type), which takes
|
8
9
|
raw characters and generates proper `keydown`, `keypress`/`input`, and `keyup` events on your page.
|
9
10
|
|
@@ -39,18 +40,18 @@ page.keyboard.press("Control+A")
|
|
39
40
|
page.keyboard.press("Meta+A")
|
40
41
|
```
|
41
42
|
|
42
|
-
|
43
|
-
|
44
43
|
## down
|
45
44
|
|
46
45
|
```
|
47
46
|
def down(key)
|
48
47
|
```
|
49
48
|
|
49
|
+
|
50
50
|
Dispatches a `keydown` event.
|
51
51
|
|
52
|
-
`key` can specify the intended
|
53
|
-
value or a single character to
|
52
|
+
`key` can specify the intended
|
53
|
+
[keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to
|
54
|
+
generate the text for. A superset of the `key` values can be found
|
54
55
|
[here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
|
55
56
|
|
56
57
|
`F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
|
@@ -60,17 +61,17 @@ Following modification shortcuts are also supported: `Shift`, `Control`, `Alt`,
|
|
60
61
|
|
61
62
|
Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
|
62
63
|
|
63
|
-
If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different
|
64
|
-
texts.
|
64
|
+
If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different
|
65
|
+
respective texts.
|
65
66
|
|
66
|
-
If `key` is a modifier key, `Shift`, `Meta`, `Control`, or `Alt`, subsequent key presses will be sent with that
|
67
|
-
active. To release the modifier key, use [Keyboard#up](./keyboard#up).
|
67
|
+
If `key` is a modifier key, `Shift`, `Meta`, `Control`, or `Alt`, subsequent key presses will be sent with that
|
68
|
+
modifier active. To release the modifier key, use [Keyboard#up](./keyboard#up).
|
68
69
|
|
69
70
|
After the key is pressed once, subsequent calls to [Keyboard#down](./keyboard#down) will have
|
70
71
|
[repeat](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat) set to true. To release the key, use
|
71
72
|
[Keyboard#up](./keyboard#up).
|
72
73
|
|
73
|
-
|
74
|
+
**NOTE**: Modifier keys DO influence `keyboard.down`. Holding down `Shift` will type the text in upper case.
|
74
75
|
|
75
76
|
## insert_text
|
76
77
|
|
@@ -78,13 +79,16 @@ After the key is pressed once, subsequent calls to [Keyboard#down](./keyboard#do
|
|
78
79
|
def insert_text(text)
|
79
80
|
```
|
80
81
|
|
82
|
+
|
81
83
|
Dispatches only `input` event, does not emit the `keydown`, `keyup` or `keypress` events.
|
82
84
|
|
85
|
+
**Usage**
|
86
|
+
|
83
87
|
```ruby
|
84
88
|
page.keyboard.insert_text("嗨")
|
85
89
|
```
|
86
90
|
|
87
|
-
|
91
|
+
**NOTE**: Modifier keys DO NOT effect `keyboard.insertText`. Holding down `Shift` will not type the text in upper case.
|
88
92
|
|
89
93
|
## press
|
90
94
|
|
@@ -92,8 +96,10 @@ page.keyboard.insert_text("嗨")
|
|
92
96
|
def press(key, delay: nil)
|
93
97
|
```
|
94
98
|
|
95
|
-
|
96
|
-
|
99
|
+
|
100
|
+
`key` can specify the intended
|
101
|
+
[keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to
|
102
|
+
generate the text for. A superset of the `key` values can be found
|
97
103
|
[here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
|
98
104
|
|
99
105
|
`F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
|
@@ -103,12 +109,14 @@ Following modification shortcuts are also supported: `Shift`, `Control`, `Alt`,
|
|
103
109
|
|
104
110
|
Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
|
105
111
|
|
106
|
-
If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different
|
107
|
-
texts.
|
112
|
+
If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different
|
113
|
+
respective texts.
|
108
114
|
|
109
115
|
Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
|
110
116
|
modifier, modifier is pressed and being held while the subsequent key is being pressed.
|
111
117
|
|
118
|
+
**Usage**
|
119
|
+
|
112
120
|
```ruby
|
113
121
|
page.goto("https://keycode.info")
|
114
122
|
page.keyboard.press("a")
|
@@ -127,17 +135,21 @@ Shortcut for [Keyboard#down](./keyboard#down) and [Keyboard#up](./keyboard#up).
|
|
127
135
|
def type(text, delay: nil)
|
128
136
|
```
|
129
137
|
|
138
|
+
|
130
139
|
Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
|
131
140
|
|
132
141
|
To press a special key, like `Control` or `ArrowDown`, use [Keyboard#press](./keyboard#press).
|
133
142
|
|
143
|
+
**Usage**
|
144
|
+
|
134
145
|
```ruby
|
135
146
|
page.keyboard.type("Hello") # types instantly
|
136
147
|
page.keyboard.type("World", delay: 100) # types slower, like a user
|
137
148
|
```
|
138
149
|
|
139
|
-
|
140
|
-
|
150
|
+
**NOTE**: Modifier keys DO NOT effect `keyboard.type`. Holding down `Shift` will not type the text in upper case.
|
151
|
+
|
152
|
+
**NOTE**: For characters that are not on a US keyboard, only an `input` event will be sent.
|
141
153
|
|
142
154
|
## up
|
143
155
|
|
@@ -145,4 +157,5 @@ page.keyboard.type("World", delay: 100) # types slower, like a user
|
|
145
157
|
def up(key)
|
146
158
|
```
|
147
159
|
|
160
|
+
|
148
161
|
Dispatches a `keyup` event.
|