playwright-ruby-client 0.0.3 → 0.0.8

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.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +119 -12
  3. data/docs/api_coverage.md +354 -0
  4. data/lib/playwright.rb +8 -0
  5. data/lib/playwright/channel_owner.rb +16 -2
  6. data/lib/playwright/channel_owners/android.rb +10 -1
  7. data/lib/playwright/channel_owners/android_device.rb +163 -0
  8. data/lib/playwright/channel_owners/browser.rb +22 -29
  9. data/lib/playwright/channel_owners/browser_context.rb +43 -0
  10. data/lib/playwright/channel_owners/console_message.rb +21 -0
  11. data/lib/playwright/channel_owners/element_handle.rb +314 -0
  12. data/lib/playwright/channel_owners/frame.rb +466 -7
  13. data/lib/playwright/channel_owners/js_handle.rb +55 -0
  14. data/lib/playwright/channel_owners/page.rb +353 -5
  15. data/lib/playwright/channel_owners/request.rb +90 -0
  16. data/lib/playwright/channel_owners/webkit_browser.rb +1 -1
  17. data/lib/playwright/connection.rb +15 -14
  18. data/lib/playwright/errors.rb +1 -1
  19. data/lib/playwright/event_emitter.rb +13 -0
  20. data/lib/playwright/input_files.rb +42 -0
  21. data/lib/playwright/input_type.rb +19 -0
  22. data/lib/playwright/input_types/android_input.rb +19 -0
  23. data/lib/playwright/input_types/keyboard.rb +32 -0
  24. data/lib/playwright/input_types/mouse.rb +4 -0
  25. data/lib/playwright/input_types/touchscreen.rb +4 -0
  26. data/lib/playwright/javascript.rb +13 -0
  27. data/lib/playwright/javascript/expression.rb +67 -0
  28. data/lib/playwright/javascript/function.rb +67 -0
  29. data/lib/playwright/javascript/value_parser.rb +75 -0
  30. data/lib/playwright/javascript/value_serializer.rb +54 -0
  31. data/lib/playwright/playwright_api.rb +45 -25
  32. data/lib/playwright/select_option_values.rb +32 -0
  33. data/lib/playwright/timeout_settings.rb +19 -0
  34. data/lib/playwright/url_matcher.rb +19 -0
  35. data/lib/playwright/utils.rb +37 -0
  36. data/lib/playwright/version.rb +1 -1
  37. data/lib/playwright/wait_helper.rb +73 -0
  38. data/lib/playwright_api/accessibility.rb +60 -6
  39. data/lib/playwright_api/android.rb +33 -0
  40. data/lib/playwright_api/android_device.rb +78 -0
  41. data/lib/playwright_api/android_input.rb +25 -0
  42. data/lib/playwright_api/binding_call.rb +18 -0
  43. data/lib/playwright_api/browser.rb +136 -44
  44. data/lib/playwright_api/browser_context.rb +378 -51
  45. data/lib/playwright_api/browser_type.rb +137 -55
  46. data/lib/playwright_api/cdp_session.rb +32 -7
  47. data/lib/playwright_api/chromium_browser_context.rb +31 -0
  48. data/lib/playwright_api/console_message.rb +27 -7
  49. data/lib/playwright_api/dialog.rb +47 -3
  50. data/lib/playwright_api/download.rb +29 -5
  51. data/lib/playwright_api/element_handle.rb +429 -143
  52. data/lib/playwright_api/file_chooser.rb +13 -2
  53. data/lib/playwright_api/frame.rb +633 -179
  54. data/lib/playwright_api/js_handle.rb +97 -17
  55. data/lib/playwright_api/keyboard.rb +152 -24
  56. data/lib/playwright_api/mouse.rb +28 -3
  57. data/lib/playwright_api/page.rb +1183 -317
  58. data/lib/playwright_api/playwright.rb +174 -13
  59. data/lib/playwright_api/request.rb +115 -30
  60. data/lib/playwright_api/response.rb +22 -3
  61. data/lib/playwright_api/route.rb +63 -4
  62. data/lib/playwright_api/selectors.rb +29 -7
  63. data/lib/playwright_api/touchscreen.rb +2 -1
  64. data/lib/playwright_api/video.rb +11 -1
  65. data/lib/playwright_api/web_socket.rb +5 -5
  66. data/lib/playwright_api/worker.rb +29 -5
  67. data/playwright.gemspec +3 -0
  68. metadata +68 -2
@@ -1,47 +1,86 @@
1
1
  module Playwright
2
- # JSHandle represents an in-page JavaScript object. JSHandles can be created with the `page.evaluateHandle(pageFunction[, arg])` method.
2
+ # JSHandle represents an in-page JavaScript object. JSHandles can be created with the [`method: Page.evaluateHandle`]
3
+ # method.
4
+ #
3
5
  #
4
6
  # ```js
5
7
  # const windowHandle = await page.evaluateHandle(() => window);
6
8
  # // ...
7
9
  # ```
8
- # JSHandle prevents the referenced JavaScript object being garbage collected unless the handle is exposed with `jsHandle.dispose()`. JSHandles are auto-disposed when their origin frame gets navigated or the parent context gets destroyed.
9
- # JSHandle instances can be used as an argument in `page.$eval(selector, pageFunction[, arg])`, `page.evaluate(pageFunction[, arg])` and `page.evaluateHandle(pageFunction[, arg])` methods.
10
+ #
11
+ # ```python async
12
+ # window_handle = await page.evaluate_handle("window")
13
+ # # ...
14
+ # ```
15
+ #
16
+ # ```python sync
17
+ # window_handle = page.evaluate_handle("window")
18
+ # # ...
19
+ # ```
20
+ #
21
+ # JSHandle prevents the referenced JavaScript object being garbage collected unless the handle is exposed with
22
+ # [`method: JSHandle.dispose`]. JSHandles are auto-disposed when their origin frame gets navigated or the parent context
23
+ # gets destroyed.
24
+ #
25
+ # JSHandle instances can be used as an argument in [`method: Page.$eval`], [`method: Page.evaluate`] and
26
+ # [`method: Page.evaluateHandle`] methods.
10
27
  class JSHandle < PlaywrightApi
11
28
 
12
- # Returns either `null` or the object handle itself, if the object handle is an instance of ElementHandle.
29
+ # Returns either `null` or the object handle itself, if the object handle is an instance of `ElementHandle`.
13
30
  def as_element
14
- raise NotImplementedError.new('as_element is not implemented yet.')
31
+ wrap_impl(@impl.as_element)
15
32
  end
16
33
 
17
34
  # The `jsHandle.dispose` method stops referencing the element handle.
18
35
  def dispose
19
- raise NotImplementedError.new('dispose is not implemented yet.')
36
+ wrap_impl(@impl.dispose)
20
37
  end
21
38
 
22
39
  # Returns the return value of `pageFunction`
40
+ #
23
41
  # This method passes this handle as the first argument to `pageFunction`.
24
- # If `pageFunction` returns a Promise, then `handle.evaluate` would wait for the promise to resolve and return its value.
42
+ #
43
+ # If `pageFunction` returns a [Promise], then `handle.evaluate` would wait for the promise to resolve and return its
44
+ # value.
45
+ #
25
46
  # Examples:
47
+ #
26
48
  #
27
49
  # ```js
28
50
  # const tweetHandle = await page.$('.tweet .retweets');
29
- # expect(await tweetHandle.evaluate((node, suffix) => node.innerText, ' retweets')).toBe('10 retweets');
51
+ # expect(await tweetHandle.evaluate(node => node.innerText)).toBe('10 retweets');
52
+ # ```
53
+ #
54
+ # ```python async
55
+ # tweet_handle = await page.query_selector(".tweet .retweets")
56
+ # assert await tweet_handle.evaluate("node => node.innerText") == "10 retweets"
57
+ # ```
58
+ #
59
+ # ```python sync
60
+ # tweet_handle = page.query_selector(".tweet .retweets")
61
+ # assert tweet_handle.evaluate("node => node.innerText") == "10 retweets"
30
62
  # ```
31
63
  def evaluate(pageFunction, arg: nil)
32
- raise NotImplementedError.new('evaluate is not implemented yet.')
64
+ wrap_impl(@impl.evaluate(unwrap_impl(pageFunction), arg: unwrap_impl(arg)))
33
65
  end
34
66
 
35
67
  # Returns the return value of `pageFunction` as in-page object (JSHandle).
68
+ #
36
69
  # This method passes this handle as the first argument to `pageFunction`.
37
- # The only difference between `jsHandle.evaluate` and `jsHandle.evaluateHandle` is that `jsHandle.evaluateHandle` returns in-page object (JSHandle).
38
- # If the function passed to the `jsHandle.evaluateHandle` returns a Promise, then `jsHandle.evaluateHandle` would wait for the promise to resolve and return its value.
39
- # See `page.evaluateHandle(pageFunction[, arg])` for more details.
70
+ #
71
+ # The only difference between `jsHandle.evaluate` and `jsHandle.evaluateHandle` is that `jsHandle.evaluateHandle` returns
72
+ # in-page object (JSHandle).
73
+ #
74
+ # If the function passed to the `jsHandle.evaluateHandle` returns a [Promise], then `jsHandle.evaluateHandle` would wait
75
+ # for the promise to resolve and return its value.
76
+ #
77
+ # See [`method: Page.evaluateHandle`] for more details.
40
78
  def evaluate_handle(pageFunction, arg: nil)
41
- raise NotImplementedError.new('evaluate_handle is not implemented yet.')
79
+ wrap_impl(@impl.evaluate_handle(unwrap_impl(pageFunction), arg: unwrap_impl(arg)))
42
80
  end
43
81
 
44
82
  # The method returns a map with **own property names** as keys and JSHandle instances for the property values.
83
+ #
45
84
  #
46
85
  # ```js
47
86
  # const handle = await page.evaluateHandle(() => ({window, document}));
@@ -50,20 +89,61 @@ module Playwright
50
89
  # const documentHandle = properties.get('document');
51
90
  # await handle.dispose();
52
91
  # ```
92
+ #
93
+ # ```python async
94
+ # handle = await page.evaluate_handle("{window, document}")
95
+ # properties = await handle.get_properties()
96
+ # window_handle = properties.get("window")
97
+ # document_handle = properties.get("document")
98
+ # await handle.dispose()
99
+ # ```
100
+ #
101
+ # ```python sync
102
+ # handle = page.evaluate_handle("{window, document}")
103
+ # properties = handle.get_properties()
104
+ # window_handle = properties.get("window")
105
+ # document_handle = properties.get("document")
106
+ # handle.dispose()
107
+ # ```
53
108
  def get_properties
54
- raise NotImplementedError.new('get_properties is not implemented yet.')
109
+ wrap_impl(@impl.get_properties)
55
110
  end
111
+ alias_method :properties, :get_properties
56
112
 
57
113
  # Fetches a single property from the referenced object.
58
114
  def get_property(propertyName)
59
- raise NotImplementedError.new('get_property is not implemented yet.')
115
+ wrap_impl(@impl.get_property(unwrap_impl(propertyName)))
60
116
  end
61
117
 
62
118
  # Returns a JSON representation of the object. If the object has a `toJSON` function, it **will not be called**.
63
119
  #
64
- # **NOTE** The method will return an empty JSON object if the referenced object is not stringifiable. It will throw an error if the object has circular references.
120
+ # > NOTE: The method will return an empty JSON object if the referenced object is not stringifiable. It will throw an
121
+ # error if the object has circular references.
65
122
  def json_value
66
- raise NotImplementedError.new('json_value is not implemented yet.')
123
+ wrap_impl(@impl.json_value)
124
+ end
125
+
126
+ # @nodoc
127
+ def after_initialize
128
+ wrap_impl(@impl.after_initialize)
129
+ end
130
+
131
+ # -- inherited from EventEmitter --
132
+ # @nodoc
133
+ def on(event, callback)
134
+ wrap_impl(@impl.on(unwrap_impl(event), unwrap_impl(callback)))
135
+ end
136
+
137
+ # -- inherited from EventEmitter --
138
+ # @nodoc
139
+ def off(event, callback)
140
+ wrap_impl(@impl.off(unwrap_impl(event), unwrap_impl(callback)))
141
+ end
142
+
143
+ # -- inherited from EventEmitter --
144
+ # @nodoc
145
+ def once(event, callback)
146
+ wrap_impl(@impl.once(unwrap_impl(event), unwrap_impl(callback)))
67
147
  end
68
148
  end
69
149
  end
@@ -1,7 +1,12 @@
1
1
  module Playwright
2
- # Keyboard provides an api for managing a virtual keyboard. The high level api is `keyboard.type(text[, options])`, which takes raw characters and generates proper keydown, keypress/input, and keyup events on your page.
3
- # For finer control, you can use `keyboard.down(key)`, `keyboard.up(key)`, and `keyboard.insertText(text)` to manually fire events as if they were generated from a real keyboard.
2
+ # 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, keypress/input, and keyup events on your page.
4
+ #
5
+ # For finer control, you can use [`method: Keyboard.down`], [`method: Keyboard.up`], and [`method: Keyboard.insertText`]
6
+ # to manually fire events as if they were generated from a real keyboard.
7
+ #
4
8
  # An example of holding down `Shift` in order to select and delete some text:
9
+ #
5
10
  #
6
11
  # ```js
7
12
  # await page.keyboard.type('Hello World!');
@@ -15,14 +20,52 @@ module Playwright
15
20
  # await page.keyboard.press('Backspace');
16
21
  # // Result text will end up saying 'Hello!'
17
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
+ # ```python sync
36
+ # page.keyboard.type("Hello World!")
37
+ # page.keyboard.press("ArrowLeft")
38
+ # page.keyboard.down("Shift")
39
+ # for i in range(6):
40
+ # page.keyboard.press("ArrowLeft")
41
+ # page.keyboard.up("Shift")
42
+ # page.keyboard.press("Backspace")
43
+ # # result text will end up saying "Hello!"
44
+ # ```
45
+ #
18
46
  # An example of pressing uppercase `A`
47
+ #
19
48
  #
20
49
  # ```js
21
50
  # await page.keyboard.press('Shift+KeyA');
22
51
  # // or
23
52
  # await page.keyboard.press('Shift+A');
24
53
  # ```
54
+ #
55
+ # ```python async
56
+ # await page.keyboard.press("Shift+KeyA")
57
+ # # or
58
+ # await page.keyboard.press("Shift+A")
59
+ # ```
60
+ #
61
+ # ```python sync
62
+ # page.keyboard.press("Shift+KeyA")
63
+ # # or
64
+ # page.keyboard.press("Shift+A")
65
+ # ```
66
+ #
25
67
  # An example to trigger select-all with the keyboard
68
+ #
26
69
  #
27
70
  # ```js
28
71
  # // on Windows and Linux
@@ -30,39 +73,87 @@ module Playwright
30
73
  # // on macOS
31
74
  # await page.keyboard.press('Meta+A');
32
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
+ # ```python sync
85
+ # # on windows and linux
86
+ # page.keyboard.press("Control+A")
87
+ # # on mac_os
88
+ # page.keyboard.press("Meta+A")
89
+ # ```
33
90
  class Keyboard < PlaywrightApi
34
91
 
35
92
  # Dispatches a `keydown` event.
36
- # `key` can specify the intended keyboardEvent.key value or a single character to generate the text for. A superset of the `key` values can be found here. Examples of the keys are:
37
- # `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`, `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
38
- # Following modification shortcuts are also suported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`.
93
+ #
94
+ # `key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)
95
+ # value or a single character to generate the text for. A superset of the `key` values can be found
96
+ # [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
97
+ #
98
+ # `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
99
+ # `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
+ #
39
103
  # Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
40
- # If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective texts.
41
- # If `key` is a modifier key, `Shift`, `Meta`, `Control`, or `Alt`, subsequent key presses will be sent with that modifier active. To release the modifier key, use `keyboard.up(key)`.
42
- # After the key is pressed once, subsequent calls to `keyboard.down(key)` will have repeat set to true. To release the key, use `keyboard.up(key)`.
43
104
  #
44
- # **NOTE** Modifier keys DO influence `keyboard.down`. Holding down `Shift` will type the text in upper case.
105
+ # If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
106
+ # texts.
107
+ #
108
+ # If `key` is a modifier key, `Shift`, `Meta`, `Control`, or `Alt`, subsequent key presses will be sent with that modifier
109
+ # active. To release the modifier key, use [`method: Keyboard.up`].
110
+ #
111
+ # After the key is pressed once, subsequent calls to [`method: Keyboard.down`] will have
112
+ # [repeat](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat) set to true. To release the key, use
113
+ # [`method: Keyboard.up`].
114
+ #
115
+ # > NOTE: Modifier keys DO influence `keyboard.down`. Holding down `Shift` will type the text in upper case.
45
116
  def down(key)
46
- raise NotImplementedError.new('down is not implemented yet.')
117
+ @impl.down(unwrap_impl(key))
47
118
  end
48
119
 
49
120
  # Dispatches only `input` event, does not emit the `keydown`, `keyup` or `keypress` events.
121
+ #
50
122
  #
51
123
  # ```js
52
124
  # page.keyboard.insertText('嗨');
53
125
  # ```
54
126
  #
55
- # **NOTE** Modifier keys DO NOT effect `keyboard.insertText`. Holding down `Shift` will not type the text in upper case.
127
+ # ```python async
128
+ # await page.keyboard.insert_text("嗨")
129
+ # ```
130
+ #
131
+ # ```python sync
132
+ # page.keyboard.insert_text("嗨")
133
+ # ```
134
+ #
135
+ # > NOTE: Modifier keys DO NOT effect `keyboard.insertText`. Holding down `Shift` will not type the text in upper case.
56
136
  def insert_text(text)
57
- raise NotImplementedError.new('insert_text is not implemented yet.')
137
+ @impl.insert_text(unwrap_impl(text))
58
138
  end
59
139
 
60
- # `key` can specify the intended keyboardEvent.key value or a single character to generate the text for. A superset of the `key` values can be found here. Examples of the keys are:
61
- # `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`, `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
62
- # Following modification shortcuts are also suported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`.
140
+ # `key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)
141
+ # value or a single character to generate the text for. A superset of the `key` values can be found
142
+ # [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
143
+ #
144
+ # `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
145
+ # `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
+ #
63
149
  # Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
64
- # If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective texts.
65
- # Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When speficied with the modifier, modifier is pressed and being held while the subsequent key is being pressed.
150
+ #
151
+ # If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
152
+ # texts.
153
+ #
154
+ # Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When speficied with the
155
+ # modifier, modifier is pressed and being held while the subsequent key is being pressed.
156
+ #
66
157
  #
67
158
  # ```js
68
159
  # const page = await browser.newPage();
@@ -75,27 +166,64 @@ module Playwright
75
166
  # await page.screenshot({ path: 'O.png' });
76
167
  # await browser.close();
77
168
  # ```
78
- # Shortcut for `keyboard.down(key)` and `keyboard.up(key)`.
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
+ #
182
+ # ```python sync
183
+ # page = browser.new_page()
184
+ # page.goto("https://keycode.info")
185
+ # page.keyboard.press("a")
186
+ # page.screenshot(path="a.png")
187
+ # page.keyboard.press("ArrowLeft")
188
+ # page.screenshot(path="arrow_left.png")
189
+ # page.keyboard.press("Shift+O")
190
+ # page.screenshot(path="o.png")
191
+ # browser.close()
192
+ # ```
193
+ #
194
+ # Shortcut for [`method: Keyboard.down`] and [`method: Keyboard.up`].
79
195
  def press(key, delay: nil)
80
- raise NotImplementedError.new('press is not implemented yet.')
196
+ @impl.press(unwrap_impl(key), delay: unwrap_impl(delay))
81
197
  end
82
198
 
83
199
  # Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
84
- # To press a special key, like `Control` or `ArrowDown`, use `keyboard.press(key[, options])`.
200
+ #
201
+ # To press a special key, like `Control` or `ArrowDown`, use [`method: Keyboard.press`].
202
+ #
85
203
  #
86
204
  # ```js
87
205
  # await page.keyboard.type('Hello'); // Types instantly
88
206
  # await page.keyboard.type('World', {delay: 100}); // Types slower, like a user
89
207
  # ```
90
208
  #
91
- # **NOTE** Modifier keys DO NOT effect `keyboard.type`. Holding down `Shift` will not type the text in upper case.
92
- def type_text(text, delay: nil)
93
- raise NotImplementedError.new('type_text is not implemented yet.')
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
+ #
214
+ # ```python sync
215
+ # page.keyboard.type("Hello") # types instantly
216
+ # page.keyboard.type("World", delay=100) # types slower, like a user
217
+ # ```
218
+ #
219
+ # > NOTE: Modifier keys DO NOT effect `keyboard.type`. Holding down `Shift` will not type the text in upper case.
220
+ def type(text, delay: nil)
221
+ @impl.type(unwrap_impl(text), delay: unwrap_impl(delay))
94
222
  end
95
223
 
96
224
  # Dispatches a `keyup` event.
97
225
  def up(key)
98
- raise NotImplementedError.new('up is not implemented yet.')
226
+ @impl.up(unwrap_impl(key))
99
227
  end
100
228
  end
101
229
  end
@@ -1,6 +1,8 @@
1
1
  module Playwright
2
2
  # The Mouse class operates in main-frame CSS pixels relative to the top-left corner of the viewport.
3
- # Every `page` object has its own Mouse, accessible with page.mouse.
3
+ #
4
+ # Every `page` object has its own Mouse, accessible with [`property: Page.mouse`].
5
+ #
4
6
  #
5
7
  # ```js
6
8
  # // Using ‘page.mouse’ to trace a 100x100 square.
@@ -12,9 +14,31 @@ module Playwright
12
14
  # await page.mouse.move(0, 0);
13
15
  # await page.mouse.up();
14
16
  # ```
17
+ #
18
+ # ```python async
19
+ # # using ‘page.mouse’ to trace a 100x100 square.
20
+ # await page.mouse.move(0, 0)
21
+ # await page.mouse.down()
22
+ # await page.mouse.move(0, 100)
23
+ # await page.mouse.move(100, 100)
24
+ # await page.mouse.move(100, 0)
25
+ # await page.mouse.move(0, 0)
26
+ # await page.mouse.up()
27
+ # ```
28
+ #
29
+ # ```python sync
30
+ # # using ‘page.mouse’ to trace a 100x100 square.
31
+ # page.mouse.move(0, 0)
32
+ # page.mouse.down()
33
+ # page.mouse.move(0, 100)
34
+ # page.mouse.move(100, 100)
35
+ # page.mouse.move(100, 0)
36
+ # page.mouse.move(0, 0)
37
+ # page.mouse.up()
38
+ # ```
15
39
  class Mouse < PlaywrightApi
16
40
 
17
- # Shortcut for `mouse.move(x, y[, options])`, `mouse.down([options])`, `mouse.up([options])`.
41
+ # Shortcut for [`method: Mouse.move`], [`method: Mouse.down`], [`method: Mouse.up`].
18
42
  def click(
19
43
  x,
20
44
  y,
@@ -24,7 +48,8 @@ module Playwright
24
48
  raise NotImplementedError.new('click is not implemented yet.')
25
49
  end
26
50
 
27
- # Shortcut for `mouse.move(x, y[, options])`, `mouse.down([options])`, `mouse.up([options])`, `mouse.down([options])` and `mouse.up([options])`.
51
+ # Shortcut for [`method: Mouse.move`], [`method: Mouse.down`], [`method: Mouse.up`], [`method: Mouse.down`] and
52
+ # [`method: Mouse.up`].
28
53
  def dblclick(x, y, button: nil, delay: nil)
29
54
  raise NotImplementedError.new('dblclick is not implemented yet.')
30
55
  end