playwright-ruby-client 0.0.8 → 1.58.1.alpha1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/AGENTS.md +4 -0
- data/CLAUDE/api_generation.md +28 -0
- data/CLAUDE/ci_expectations.md +23 -0
- data/CLAUDE/gem_release_flow.md +39 -0
- data/CLAUDE/past_upgrade_pr_patterns.md +42 -0
- data/CLAUDE/playwright_upgrade_workflow.md +35 -0
- data/CLAUDE/rspec_debugging.md +30 -0
- data/CLAUDE/unimplemented_examples.md +18 -0
- data/CLAUDE.md +32 -0
- data/CONTRIBUTING.md +5 -0
- data/README.md +60 -16
- data/documentation/README.md +33 -0
- data/documentation/babel.config.js +3 -0
- data/documentation/docs/api/api_request.md +7 -0
- data/documentation/docs/api/api_request_context.md +298 -0
- data/documentation/docs/api/api_response.md +114 -0
- data/documentation/docs/api/browser.md +237 -0
- data/documentation/docs/api/browser_context.md +503 -0
- data/documentation/docs/api/browser_type.md +184 -0
- data/documentation/docs/api/cdp_session.md +44 -0
- data/documentation/docs/api/clock.md +154 -0
- data/documentation/docs/api/console_message.md +85 -0
- data/documentation/docs/api/dialog.md +84 -0
- data/documentation/docs/api/download.md +111 -0
- data/documentation/docs/api/element_handle.md +694 -0
- data/documentation/docs/api/experimental/_category_.yml +3 -0
- data/documentation/docs/api/experimental/android.md +42 -0
- data/documentation/docs/api/experimental/android_device.md +109 -0
- data/documentation/docs/api/experimental/android_input.md +43 -0
- data/documentation/docs/api/experimental/android_socket.md +7 -0
- data/documentation/docs/api/experimental/android_web_view.md +7 -0
- data/documentation/docs/api/file_chooser.md +53 -0
- data/documentation/docs/api/frame.md +1218 -0
- data/documentation/docs/api/frame_locator.md +348 -0
- data/documentation/docs/api/js_handle.md +121 -0
- data/documentation/docs/api/keyboard.md +170 -0
- data/documentation/docs/api/locator.md +1495 -0
- data/documentation/docs/api/locator_assertions.md +827 -0
- data/documentation/docs/api/mouse.md +86 -0
- data/documentation/docs/api/page.md +1946 -0
- data/documentation/docs/api/page_assertions.md +65 -0
- data/documentation/docs/api/playwright.md +66 -0
- data/documentation/docs/api/request.md +255 -0
- data/documentation/docs/api/response.md +176 -0
- data/documentation/docs/api/route.md +205 -0
- data/documentation/docs/api/selectors.md +63 -0
- data/documentation/docs/api/touchscreen.md +22 -0
- data/documentation/docs/api/tracing.md +129 -0
- data/documentation/docs/api/web_socket.md +51 -0
- data/documentation/docs/api/worker.md +83 -0
- data/documentation/docs/article/api_coverage.mdx +11 -0
- data/documentation/docs/article/getting_started.md +161 -0
- data/documentation/docs/article/guides/_category_.yml +3 -0
- data/documentation/docs/article/guides/download_playwright_driver.md +55 -0
- data/documentation/docs/article/guides/inspector.md +31 -0
- data/documentation/docs/article/guides/launch_browser.md +121 -0
- data/documentation/docs/article/guides/playwright_on_alpine_linux.md +112 -0
- data/documentation/docs/article/guides/rails_integration.md +278 -0
- data/documentation/docs/article/guides/rails_integration_with_null_driver.md +145 -0
- data/documentation/docs/article/guides/recording_video.md +79 -0
- data/documentation/docs/article/guides/rspec_integration.md +59 -0
- data/documentation/docs/article/guides/semi_automation.md +71 -0
- data/documentation/docs/article/guides/use_storage_state.md +78 -0
- data/documentation/docs/include/api_coverage.md +671 -0
- data/documentation/docusaurus.config.js +114 -0
- data/documentation/package.json +39 -0
- data/documentation/sidebars.js +15 -0
- data/documentation/src/components/HomepageFeatures.js +61 -0
- data/documentation/src/components/HomepageFeatures.module.css +13 -0
- data/documentation/src/css/custom.css +44 -0
- data/documentation/src/pages/index.js +49 -0
- data/documentation/src/pages/index.module.css +41 -0
- data/documentation/src/pages/markdown-page.md +7 -0
- data/documentation/static/.nojekyll +0 -0
- data/documentation/static/img/playwright-logo.svg +9 -0
- data/documentation/static/img/playwright-ruby-client.png +0 -0
- data/documentation/static/img/undraw_dropdown_menu.svg +1 -0
- data/documentation/static/img/undraw_web_development.svg +1 -0
- data/documentation/static/img/undraw_windows.svg +1 -0
- data/documentation/yarn.lock +9005 -0
- data/lib/playwright/{input_types/android_input.rb → android_input_impl.rb} +5 -1
- data/lib/playwright/api_implementation.rb +18 -0
- data/lib/playwright/api_response_impl.rb +77 -0
- data/lib/playwright/channel.rb +62 -1
- data/lib/playwright/channel_owner.rb +70 -7
- data/lib/playwright/channel_owners/android.rb +16 -3
- data/lib/playwright/channel_owners/android_device.rb +22 -66
- data/lib/playwright/channel_owners/api_request_context.rb +247 -0
- data/lib/playwright/channel_owners/artifact.rb +40 -0
- data/lib/playwright/channel_owners/binding_call.rb +70 -0
- data/lib/playwright/channel_owners/browser.rb +114 -22
- data/lib/playwright/channel_owners/browser_context.rb +589 -15
- data/lib/playwright/channel_owners/browser_type.rb +90 -1
- data/lib/playwright/channel_owners/cdp_session.rb +19 -0
- data/lib/playwright/channel_owners/dialog.rb +32 -0
- data/lib/playwright/channel_owners/element_handle.rb +107 -43
- data/lib/playwright/channel_owners/fetch_request.rb +8 -0
- data/lib/playwright/channel_owners/frame.rb +334 -104
- data/lib/playwright/channel_owners/js_handle.rb +9 -13
- data/lib/playwright/channel_owners/local_utils.rb +82 -0
- data/lib/playwright/channel_owners/page.rb +778 -95
- data/lib/playwright/channel_owners/playwright.rb +25 -30
- data/lib/playwright/channel_owners/request.rb +120 -18
- data/lib/playwright/channel_owners/response.rb +113 -0
- data/lib/playwright/channel_owners/route.rb +181 -0
- data/lib/playwright/channel_owners/stream.rb +30 -0
- data/lib/playwright/channel_owners/tracing.rb +117 -0
- data/lib/playwright/channel_owners/web_socket.rb +96 -0
- data/lib/playwright/channel_owners/worker.rb +46 -0
- data/lib/playwright/channel_owners/writable_stream.rb +14 -0
- data/lib/playwright/clock_impl.rb +67 -0
- data/lib/playwright/connection.rb +111 -63
- data/lib/playwright/console_message_impl.rb +29 -0
- data/lib/playwright/download_impl.rb +32 -0
- data/lib/playwright/errors.rb +42 -5
- data/lib/playwright/event_emitter.rb +17 -3
- data/lib/playwright/event_emitter_proxy.rb +49 -0
- data/lib/playwright/events.rb +10 -5
- data/lib/playwright/file_chooser_impl.rb +24 -0
- data/lib/playwright/frame_locator_impl.rb +66 -0
- data/lib/playwright/har_router.rb +89 -0
- data/lib/playwright/http_headers.rb +14 -0
- data/lib/playwright/input_files.rb +102 -15
- data/lib/playwright/javascript/expression.rb +7 -11
- data/lib/playwright/javascript/regex.rb +23 -0
- data/lib/playwright/javascript/source_url.rb +16 -0
- data/lib/playwright/javascript/value_parser.rb +108 -19
- data/lib/playwright/javascript/value_serializer.rb +47 -8
- data/lib/playwright/javascript/visitor_info.rb +26 -0
- data/lib/playwright/javascript.rb +2 -10
- data/lib/playwright/{input_types/keyboard.rb → keyboard_impl.rb} +6 -2
- data/lib/playwright/locator_assertions_impl.rb +571 -0
- data/lib/playwright/locator_impl.rb +544 -0
- data/lib/playwright/locator_utils.rb +136 -0
- data/lib/playwright/mouse_impl.rb +57 -0
- data/lib/playwright/page_assertions_impl.rb +154 -0
- data/lib/playwright/playwright_api.rb +102 -30
- data/lib/playwright/raw_headers.rb +61 -0
- data/lib/playwright/route_handler.rb +78 -0
- data/lib/playwright/select_option_values.rb +34 -13
- data/lib/playwright/selectors_impl.rb +45 -0
- data/lib/playwright/test.rb +102 -0
- data/lib/playwright/timeout_settings.rb +9 -4
- data/lib/playwright/touchscreen_impl.rb +14 -0
- data/lib/playwright/transport.rb +61 -10
- data/lib/playwright/url_matcher.rb +24 -2
- data/lib/playwright/utils.rb +48 -13
- data/lib/playwright/version.rb +2 -1
- data/lib/playwright/video.rb +54 -0
- data/lib/playwright/waiter.rb +166 -0
- data/lib/playwright/web_socket_client.rb +167 -0
- data/lib/playwright/web_socket_transport.rb +116 -0
- data/lib/playwright.rb +188 -11
- data/lib/playwright_api/android.rb +46 -11
- data/lib/playwright_api/android_device.rb +182 -31
- data/lib/playwright_api/android_input.rb +22 -13
- data/lib/playwright_api/android_socket.rb +18 -0
- data/lib/playwright_api/android_web_view.rb +24 -0
- data/lib/playwright_api/api_request.rb +26 -0
- data/lib/playwright_api/api_request_context.rb +311 -0
- data/lib/playwright_api/api_response.rb +92 -0
- data/lib/playwright_api/browser.rb +116 -103
- data/lib/playwright_api/browser_context.rb +290 -389
- data/lib/playwright_api/browser_type.rb +96 -118
- data/lib/playwright_api/cdp_session.rb +36 -39
- data/lib/playwright_api/clock.rb +121 -0
- data/lib/playwright_api/console_message.rb +35 -19
- data/lib/playwright_api/dialog.rb +53 -50
- data/lib/playwright_api/download.rb +49 -43
- data/lib/playwright_api/element_handle.rb +354 -402
- data/lib/playwright_api/file_chooser.rb +15 -18
- data/lib/playwright_api/frame.rb +703 -603
- data/lib/playwright_api/frame_locator.rb +285 -0
- data/lib/playwright_api/js_handle.rb +50 -76
- data/lib/playwright_api/keyboard.rb +67 -146
- data/lib/playwright_api/locator.rb +1304 -0
- data/lib/playwright_api/locator_assertions.rb +704 -0
- data/lib/playwright_api/mouse.rb +23 -29
- data/lib/playwright_api/page.rb +1196 -1176
- data/lib/playwright_api/page_assertions.rb +60 -0
- data/lib/playwright_api/playwright.rb +54 -122
- data/lib/playwright_api/request.rb +112 -74
- data/lib/playwright_api/response.rb +92 -20
- data/lib/playwright_api/route.rb +152 -62
- data/lib/playwright_api/selectors.rb +47 -61
- data/lib/playwright_api/touchscreen.rb +8 -2
- data/lib/playwright_api/tracing.rb +128 -0
- data/lib/playwright_api/web_socket.rb +43 -5
- data/lib/playwright_api/worker.rb +74 -34
- data/playwright.gemspec +14 -9
- data/sig/playwright.rbs +658 -0
- metadata +216 -50
- data/docs/api_coverage.md +0 -354
- data/lib/playwright/channel_owners/chromium_browser.rb +0 -8
- data/lib/playwright/channel_owners/chromium_browser_context.rb +0 -8
- data/lib/playwright/channel_owners/console_message.rb +0 -21
- data/lib/playwright/channel_owners/firefox_browser.rb +0 -8
- data/lib/playwright/channel_owners/selectors.rb +0 -4
- data/lib/playwright/channel_owners/webkit_browser.rb +0 -8
- data/lib/playwright/input_type.rb +0 -19
- data/lib/playwright/input_types/mouse.rb +0 -4
- data/lib/playwright/input_types/touchscreen.rb +0 -4
- data/lib/playwright/javascript/function.rb +0 -67
- data/lib/playwright/wait_helper.rb +0 -73
- data/lib/playwright_api/accessibility.rb +0 -93
- data/lib/playwright_api/binding_call.rb +0 -23
- data/lib/playwright_api/chromium_browser_context.rb +0 -57
- data/lib/playwright_api/video.rb +0 -24
|
@@ -1,37 +1,13 @@
|
|
|
1
1
|
module Playwright
|
|
2
|
+
#
|
|
2
3
|
# Keyboard provides an api for managing a virtual keyboard. The high level api is [`method: Keyboard.type`], which takes
|
|
3
|
-
# raw characters and generates proper keydown
|
|
4
|
-
#
|
|
4
|
+
# raw characters and generates proper `keydown`, `keypress`/`input`, and `keyup` events on your page.
|
|
5
|
+
#
|
|
5
6
|
# For finer control, you can use [`method: Keyboard.down`], [`method: Keyboard.up`], and [`method: Keyboard.insertText`]
|
|
6
7
|
# to manually fire events as if they were generated from a real keyboard.
|
|
7
|
-
#
|
|
8
|
+
#
|
|
8
9
|
# An example of holding down `Shift` in order to select and delete some text:
|
|
9
|
-
#
|
|
10
10
|
#
|
|
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
|
-
# ```python async
|
|
25
|
-
# await page.keyboard.type("Hello World!")
|
|
26
|
-
# await page.keyboard.press("ArrowLeft")
|
|
27
|
-
# await page.keyboard.down("Shift")
|
|
28
|
-
# for i in range(6):
|
|
29
|
-
# await page.keyboard.press("ArrowLeft")
|
|
30
|
-
# await page.keyboard.up("Shift")
|
|
31
|
-
# await page.keyboard.press("Backspace")
|
|
32
|
-
# # result text will end up saying "Hello!"
|
|
33
|
-
# ```
|
|
34
|
-
#
|
|
35
11
|
# ```python sync
|
|
36
12
|
# page.keyboard.type("Hello World!")
|
|
37
13
|
# page.keyboard.press("ArrowLeft")
|
|
@@ -42,143 +18,91 @@ module Playwright
|
|
|
42
18
|
# page.keyboard.press("Backspace")
|
|
43
19
|
# # result text will end up saying "Hello!"
|
|
44
20
|
# ```
|
|
45
|
-
#
|
|
21
|
+
#
|
|
46
22
|
# An example of pressing uppercase `A`
|
|
47
|
-
#
|
|
48
23
|
#
|
|
49
|
-
# ```js
|
|
50
|
-
# await page.keyboard.press('Shift+KeyA');
|
|
51
|
-
# // or
|
|
52
|
-
# await page.keyboard.press('Shift+A');
|
|
53
|
-
# ```
|
|
54
|
-
#
|
|
55
|
-
# ```python async
|
|
56
|
-
# await page.keyboard.press("Shift+KeyA")
|
|
57
|
-
# # or
|
|
58
|
-
# await page.keyboard.press("Shift+A")
|
|
59
|
-
# ```
|
|
60
|
-
#
|
|
61
24
|
# ```python sync
|
|
62
25
|
# page.keyboard.press("Shift+KeyA")
|
|
63
26
|
# # or
|
|
64
27
|
# page.keyboard.press("Shift+A")
|
|
65
28
|
# ```
|
|
66
|
-
#
|
|
29
|
+
#
|
|
67
30
|
# An example to trigger select-all with the keyboard
|
|
68
|
-
#
|
|
69
31
|
#
|
|
70
|
-
# ```js
|
|
71
|
-
# // on Windows and Linux
|
|
72
|
-
# await page.keyboard.press('Control+A');
|
|
73
|
-
# // on macOS
|
|
74
|
-
# await page.keyboard.press('Meta+A');
|
|
75
|
-
# ```
|
|
76
|
-
#
|
|
77
|
-
# ```python async
|
|
78
|
-
# # on windows and linux
|
|
79
|
-
# await page.keyboard.press("Control+A")
|
|
80
|
-
# # on mac_os
|
|
81
|
-
# await page.keyboard.press("Meta+A")
|
|
82
|
-
# ```
|
|
83
|
-
#
|
|
84
32
|
# ```python sync
|
|
85
|
-
#
|
|
86
|
-
# page.keyboard.press("Control+A")
|
|
87
|
-
# # on mac_os
|
|
88
|
-
# page.keyboard.press("Meta+A")
|
|
33
|
+
# page.keyboard.press("ControlOrMeta+A")
|
|
89
34
|
# ```
|
|
90
35
|
class Keyboard < PlaywrightApi
|
|
91
36
|
|
|
37
|
+
#
|
|
92
38
|
# Dispatches a `keydown` event.
|
|
93
|
-
#
|
|
94
|
-
# `key` can specify the intended
|
|
95
|
-
# value or a single character to
|
|
39
|
+
#
|
|
40
|
+
# `key` can specify the intended
|
|
41
|
+
# [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to
|
|
42
|
+
# generate the text for. A superset of the `key` values can be found
|
|
96
43
|
# [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
|
|
97
|
-
#
|
|
44
|
+
#
|
|
98
45
|
# `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
|
|
99
46
|
# `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
|
|
100
|
-
#
|
|
101
|
-
# Following modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`.
|
|
102
|
-
#
|
|
47
|
+
#
|
|
48
|
+
# Following modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`, `ControlOrMeta`.
|
|
49
|
+
# `ControlOrMeta` resolves to `Control` on Windows and Linux and to `Meta` on macOS.
|
|
50
|
+
#
|
|
103
51
|
# Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
|
|
104
|
-
#
|
|
105
|
-
# If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different
|
|
106
|
-
# texts.
|
|
107
|
-
#
|
|
108
|
-
# If `key` is a modifier key, `Shift`, `Meta`, `Control`, or `Alt`, subsequent key presses will be sent with that
|
|
109
|
-
# active. To release the modifier key, use [`method: Keyboard.up`].
|
|
110
|
-
#
|
|
52
|
+
#
|
|
53
|
+
# If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different
|
|
54
|
+
# respective texts.
|
|
55
|
+
#
|
|
56
|
+
# If `key` is a modifier key, `Shift`, `Meta`, `Control`, or `Alt`, subsequent key presses will be sent with that
|
|
57
|
+
# modifier active. To release the modifier key, use [`method: Keyboard.up`].
|
|
58
|
+
#
|
|
111
59
|
# After the key is pressed once, subsequent calls to [`method: Keyboard.down`] will have
|
|
112
60
|
# [repeat](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat) set to true. To release the key, use
|
|
113
61
|
# [`method: Keyboard.up`].
|
|
114
|
-
#
|
|
115
|
-
#
|
|
62
|
+
#
|
|
63
|
+
# **NOTE**: Modifier keys DO influence `keyboard.down`. Holding down `Shift` will type the text in upper case.
|
|
116
64
|
def down(key)
|
|
117
|
-
@impl.down(unwrap_impl(key))
|
|
65
|
+
wrap_impl(@impl.down(unwrap_impl(key)))
|
|
118
66
|
end
|
|
119
67
|
|
|
68
|
+
#
|
|
120
69
|
# Dispatches only `input` event, does not emit the `keydown`, `keyup` or `keypress` events.
|
|
121
|
-
#
|
|
122
70
|
#
|
|
123
|
-
#
|
|
124
|
-
#
|
|
125
|
-
# ```
|
|
126
|
-
#
|
|
127
|
-
# ```python async
|
|
128
|
-
# await page.keyboard.insert_text("嗨")
|
|
129
|
-
# ```
|
|
130
|
-
#
|
|
71
|
+
# **Usage**
|
|
72
|
+
#
|
|
131
73
|
# ```python sync
|
|
132
74
|
# page.keyboard.insert_text("嗨")
|
|
133
75
|
# ```
|
|
134
|
-
#
|
|
135
|
-
#
|
|
76
|
+
#
|
|
77
|
+
# **NOTE**: Modifier keys DO NOT effect `keyboard.insertText`. Holding down `Shift` will not type the text in upper case.
|
|
136
78
|
def insert_text(text)
|
|
137
|
-
@impl.insert_text(unwrap_impl(text))
|
|
79
|
+
wrap_impl(@impl.insert_text(unwrap_impl(text)))
|
|
138
80
|
end
|
|
139
81
|
|
|
140
|
-
#
|
|
141
|
-
#
|
|
82
|
+
#
|
|
83
|
+
# **NOTE**: In most cases, you should use [`method: Locator.press`] instead.
|
|
84
|
+
#
|
|
85
|
+
# `key` can specify the intended
|
|
86
|
+
# [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to
|
|
87
|
+
# generate the text for. A superset of the `key` values can be found
|
|
142
88
|
# [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
|
|
143
|
-
#
|
|
89
|
+
#
|
|
144
90
|
# `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
|
|
145
91
|
# `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
|
|
146
|
-
#
|
|
147
|
-
# Following modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`.
|
|
148
|
-
#
|
|
92
|
+
#
|
|
93
|
+
# Following modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`, `ControlOrMeta`.
|
|
94
|
+
# `ControlOrMeta` resolves to `Control` on Windows and Linux and to `Meta` on macOS.
|
|
95
|
+
#
|
|
149
96
|
# Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
|
|
150
|
-
#
|
|
151
|
-
# If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different
|
|
152
|
-
# texts.
|
|
153
|
-
#
|
|
154
|
-
# Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When
|
|
97
|
+
#
|
|
98
|
+
# If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different
|
|
99
|
+
# respective texts.
|
|
100
|
+
#
|
|
101
|
+
# Shortcuts such as `key: "Control+o"`, `key: "Control++` or `key: "Control+Shift+T"` are supported as well. When specified with the
|
|
155
102
|
# modifier, modifier is pressed and being held while the subsequent key is being pressed.
|
|
156
|
-
#
|
|
157
|
-
#
|
|
158
|
-
#
|
|
159
|
-
# const page = await browser.newPage();
|
|
160
|
-
# await page.goto('https://keycode.info');
|
|
161
|
-
# await page.keyboard.press('A');
|
|
162
|
-
# await page.screenshot({ path: 'A.png' });
|
|
163
|
-
# await page.keyboard.press('ArrowLeft');
|
|
164
|
-
# await page.screenshot({ path: 'ArrowLeft.png' });
|
|
165
|
-
# await page.keyboard.press('Shift+O');
|
|
166
|
-
# await page.screenshot({ path: 'O.png' });
|
|
167
|
-
# await browser.close();
|
|
168
|
-
# ```
|
|
169
|
-
#
|
|
170
|
-
# ```python async
|
|
171
|
-
# page = await browser.new_page()
|
|
172
|
-
# await page.goto("https://keycode.info")
|
|
173
|
-
# await page.keyboard.press("a")
|
|
174
|
-
# await page.screenshot(path="a.png")
|
|
175
|
-
# await page.keyboard.press("ArrowLeft")
|
|
176
|
-
# await page.screenshot(path="arrow_left.png")
|
|
177
|
-
# await page.keyboard.press("Shift+O")
|
|
178
|
-
# await page.screenshot(path="o.png")
|
|
179
|
-
# await browser.close()
|
|
180
|
-
# ```
|
|
181
|
-
#
|
|
103
|
+
#
|
|
104
|
+
# **Usage**
|
|
105
|
+
#
|
|
182
106
|
# ```python sync
|
|
183
107
|
# page = browser.new_page()
|
|
184
108
|
# page.goto("https://keycode.info")
|
|
@@ -190,40 +114,37 @@ module Playwright
|
|
|
190
114
|
# page.screenshot(path="o.png")
|
|
191
115
|
# browser.close()
|
|
192
116
|
# ```
|
|
193
|
-
#
|
|
117
|
+
#
|
|
194
118
|
# Shortcut for [`method: Keyboard.down`] and [`method: Keyboard.up`].
|
|
195
119
|
def press(key, delay: nil)
|
|
196
|
-
@impl.press(unwrap_impl(key), delay: unwrap_impl(delay))
|
|
120
|
+
wrap_impl(@impl.press(unwrap_impl(key), delay: unwrap_impl(delay)))
|
|
197
121
|
end
|
|
198
122
|
|
|
123
|
+
#
|
|
124
|
+
# **NOTE**: In most cases, you should use [`method: Locator.fill`] instead. You only need to press keys one by one if there is special keyboard handling on the page - in this case use [`method: Locator.pressSequentially`].
|
|
125
|
+
#
|
|
199
126
|
# Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
|
|
200
|
-
#
|
|
127
|
+
#
|
|
201
128
|
# To press a special key, like `Control` or `ArrowDown`, use [`method: Keyboard.press`].
|
|
202
|
-
#
|
|
203
129
|
#
|
|
204
|
-
#
|
|
205
|
-
#
|
|
206
|
-
# await page.keyboard.type('World', {delay: 100}); // Types slower, like a user
|
|
207
|
-
# ```
|
|
208
|
-
#
|
|
209
|
-
# ```python async
|
|
210
|
-
# await page.keyboard.type("Hello") # types instantly
|
|
211
|
-
# await page.keyboard.type("World", delay=100) # types slower, like a user
|
|
212
|
-
# ```
|
|
213
|
-
#
|
|
130
|
+
# **Usage**
|
|
131
|
+
#
|
|
214
132
|
# ```python sync
|
|
215
133
|
# page.keyboard.type("Hello") # types instantly
|
|
216
134
|
# page.keyboard.type("World", delay=100) # types slower, like a user
|
|
217
135
|
# ```
|
|
218
|
-
#
|
|
219
|
-
#
|
|
136
|
+
#
|
|
137
|
+
# **NOTE**: Modifier keys DO NOT effect `keyboard.type`. Holding down `Shift` will not type the text in upper case.
|
|
138
|
+
#
|
|
139
|
+
# **NOTE**: For characters that are not on a US keyboard, only an `input` event will be sent.
|
|
220
140
|
def type(text, delay: nil)
|
|
221
|
-
@impl.type(unwrap_impl(text), delay: unwrap_impl(delay))
|
|
141
|
+
wrap_impl(@impl.type(unwrap_impl(text), delay: unwrap_impl(delay)))
|
|
222
142
|
end
|
|
223
143
|
|
|
144
|
+
#
|
|
224
145
|
# Dispatches a `keyup` event.
|
|
225
146
|
def up(key)
|
|
226
|
-
@impl.up(unwrap_impl(key))
|
|
147
|
+
wrap_impl(@impl.up(unwrap_impl(key)))
|
|
227
148
|
end
|
|
228
149
|
end
|
|
229
150
|
end
|