playwright-ruby-client 0.6.0 → 0.6.5

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 (96) hide show
  1. checksums.yaml +4 -4
  2. data/documentation/README.md +33 -0
  3. data/documentation/babel.config.js +3 -0
  4. data/documentation/docs/api/accessibility.md +7 -0
  5. data/documentation/docs/api/browser.md +188 -0
  6. data/documentation/docs/api/browser_context.md +397 -0
  7. data/documentation/docs/api/browser_type.md +158 -0
  8. data/documentation/docs/api/cdp_session.md +7 -0
  9. data/documentation/docs/api/console_message.md +41 -0
  10. data/documentation/docs/api/dialog.md +71 -0
  11. data/documentation/docs/api/element_handle.md +618 -0
  12. data/documentation/docs/api/experimental/_category_.yml +3 -0
  13. data/documentation/docs/api/experimental/android.md +26 -0
  14. data/documentation/docs/api/experimental/android_device.md +92 -0
  15. data/documentation/docs/api/experimental/android_input.md +38 -0
  16. data/documentation/docs/api/experimental/android_socket.md +7 -0
  17. data/documentation/docs/api/experimental/android_web_view.md +7 -0
  18. data/documentation/docs/api/file_chooser.md +50 -0
  19. data/documentation/docs/api/frame.md +866 -0
  20. data/documentation/docs/api/js_handle.md +113 -0
  21. data/documentation/docs/api/keyboard.md +157 -0
  22. data/documentation/docs/api/mouse.md +69 -0
  23. data/documentation/docs/api/page.md +1402 -0
  24. data/documentation/docs/api/playwright.md +63 -0
  25. data/documentation/docs/api/request.md +188 -0
  26. data/documentation/docs/api/response.md +97 -0
  27. data/documentation/docs/api/route.md +79 -0
  28. data/documentation/docs/api/selectors.md +23 -0
  29. data/documentation/docs/api/touchscreen.md +8 -0
  30. data/documentation/docs/api/tracing.md +47 -0
  31. data/documentation/docs/api/web_socket.md +7 -0
  32. data/documentation/docs/api/worker.md +24 -0
  33. data/documentation/docs/article/api_coverage.mdx +11 -0
  34. data/documentation/docs/article/getting_started.md +152 -0
  35. data/documentation/docs/article/guides/_category_.yml +3 -0
  36. data/documentation/docs/article/guides/download_playwright_driver.md +49 -0
  37. data/documentation/docs/article/guides/launch_browser.md +119 -0
  38. data/documentation/docs/article/guides/rails_integration.md +205 -0
  39. data/documentation/docs/article/guides/recording_video.md +79 -0
  40. data/{docs → documentation/docs/include}/api_coverage.md +4 -3
  41. data/documentation/docusaurus.config.js +107 -0
  42. data/documentation/package.json +39 -0
  43. data/documentation/sidebars.js +15 -0
  44. data/documentation/src/components/HomepageFeatures.js +61 -0
  45. data/documentation/src/components/HomepageFeatures.module.css +13 -0
  46. data/documentation/src/css/custom.css +44 -0
  47. data/documentation/src/pages/index.js +50 -0
  48. data/documentation/src/pages/index.module.css +41 -0
  49. data/documentation/src/pages/markdown-page.md +7 -0
  50. data/documentation/static/.nojekyll +0 -0
  51. data/documentation/static/img/playwright-logo.svg +9 -0
  52. data/documentation/static/img/undraw_dropdown_menu.svg +1 -0
  53. data/documentation/static/img/undraw_web_development.svg +1 -0
  54. data/documentation/static/img/undraw_windows.svg +1 -0
  55. data/documentation/yarn.lock +8785 -0
  56. data/lib/playwright/channel_owners/binding_call.rb +33 -0
  57. data/lib/playwright/channel_owners/browser.rb +15 -27
  58. data/lib/playwright/channel_owners/browser_context.rb +15 -7
  59. data/lib/playwright/channel_owners/browser_type.rb +23 -8
  60. data/lib/playwright/channel_owners/element_handle.rb +2 -10
  61. data/lib/playwright/channel_owners/frame.rb +6 -28
  62. data/lib/playwright/channel_owners/js_handle.rb +2 -10
  63. data/lib/playwright/channel_owners/page.rb +18 -8
  64. data/lib/playwright/channel_owners/worker.rb +4 -0
  65. data/lib/playwright/input_files.rb +0 -8
  66. data/lib/playwright/javascript.rb +0 -10
  67. data/lib/playwright/javascript/expression.rb +2 -7
  68. data/lib/playwright/playwright_api.rb +16 -1
  69. data/lib/playwright/tracing_impl.rb +9 -9
  70. data/lib/playwright/version.rb +1 -1
  71. data/lib/playwright_api/accessibility.rb +7 -89
  72. data/lib/playwright_api/android.rb +10 -66
  73. data/lib/playwright_api/android_device.rb +10 -9
  74. data/lib/playwright_api/browser.rb +21 -172
  75. data/lib/playwright_api/browser_context.rb +54 -617
  76. data/lib/playwright_api/browser_type.rb +20 -108
  77. data/lib/playwright_api/cdp_session.rb +2 -25
  78. data/lib/playwright_api/console_message.rb +6 -6
  79. data/lib/playwright_api/dialog.rb +11 -92
  80. data/lib/playwright_api/element_handle.rb +60 -362
  81. data/lib/playwright_api/file_chooser.rb +0 -28
  82. data/lib/playwright_api/frame.rb +74 -713
  83. data/lib/playwright_api/js_handle.rb +16 -90
  84. data/lib/playwright_api/keyboard.rb +21 -213
  85. data/lib/playwright_api/mouse.rb +1 -45
  86. data/lib/playwright_api/page.rb +181 -1647
  87. data/lib/playwright_api/playwright.rb +14 -117
  88. data/lib/playwright_api/request.rb +15 -121
  89. data/lib/playwright_api/response.rb +7 -7
  90. data/lib/playwright_api/route.rb +8 -105
  91. data/lib/playwright_api/selectors.rb +6 -97
  92. data/lib/playwright_api/tracing.rb +7 -73
  93. data/lib/playwright_api/web_socket.rb +1 -1
  94. data/lib/playwright_api/worker.rb +28 -42
  95. metadata +57 -4
  96. data/lib/playwright/javascript/function.rb +0 -67
@@ -0,0 +1,158 @@
1
+ ---
2
+ sidebar_position: 10
3
+ ---
4
+
5
+ # BrowserType
6
+
7
+ BrowserType provides methods to launch a specific browser instance or connect to an existing one. The following is a
8
+ typical example of using Playwright to drive automation:
9
+
10
+ ```ruby
11
+ chromium = playwright.chromium
12
+ chromium.launch do |browser|
13
+ page = browser.new_page
14
+ page.goto('https://example.com/')
15
+
16
+ # other actions
17
+
18
+ end
19
+ ```
20
+
21
+
22
+
23
+ ## connect_over_cdp
24
+
25
+ ```
26
+ def connect_over_cdp(
27
+ endpointURL,
28
+ headers: nil,
29
+ slowMo: nil,
30
+ timeout: nil,
31
+ &block)
32
+ ```
33
+
34
+ This methods attaches Playwright to an existing browser instance using the Chrome DevTools Protocol.
35
+
36
+ The default browser context is accessible via [Browser#contexts](./browser#contexts).
37
+
38
+ > NOTE: Connecting over the Chrome DevTools Protocol is only supported for Chromium-based browsers.
39
+
40
+ ## executable_path
41
+
42
+ ```
43
+ def executable_path
44
+ ```
45
+
46
+ A path where Playwright expects to find a bundled browser executable.
47
+
48
+ ## launch
49
+
50
+ ```
51
+ def launch(
52
+ args: nil,
53
+ channel: nil,
54
+ chromiumSandbox: nil,
55
+ devtools: nil,
56
+ downloadsPath: nil,
57
+ env: nil,
58
+ executablePath: nil,
59
+ firefoxUserPrefs: nil,
60
+ handleSIGHUP: nil,
61
+ handleSIGINT: nil,
62
+ handleSIGTERM: nil,
63
+ headless: nil,
64
+ ignoreDefaultArgs: nil,
65
+ proxy: nil,
66
+ slowMo: nil,
67
+ timeout: nil,
68
+ tracesDir: nil,
69
+ &block)
70
+ ```
71
+
72
+ Returns the browser instance.
73
+
74
+ You can use `ignoreDefaultArgs` to filter out `--mute-audio` from default arguments:
75
+
76
+ ```ruby
77
+ browser = playwright.chromium.launch( # or "firefox" or "webkit".
78
+ ignoreDefaultArgs: ["--mute-audio"]
79
+ )
80
+
81
+ browser.close
82
+ ```
83
+
84
+ > **Chromium-only** Playwright can also be used to control the Google Chrome or Microsoft Edge browsers, but it works
85
+ best with the version of Chromium it is bundled with. There is no guarantee it will work with any other version. Use
86
+ `executablePath` option with extreme caution.
87
+ >
88
+ > If Google Chrome (rather than Chromium) is preferred, a
89
+ [Chrome Canary](https://www.google.com/chrome/browser/canary.html) or
90
+ [Dev Channel](https://www.chromium.org/getting-involved/dev-channel) build is suggested.
91
+ >
92
+ > Stock browsers like Google Chrome and Microsoft Edge are suitable for tests that require proprietary media codecs for
93
+ video playback. See
94
+ [this article](https://www.howtogeek.com/202825/what%E2%80%99s-the-difference-between-chromium-and-chrome/) for other
95
+ differences between Chromium and Chrome.
96
+ [This article](https://chromium.googlesource.com/chromium/src/+/lkgr/docs/chromium_browser_vs_google_chrome.md)
97
+ describes some differences for Linux users.
98
+
99
+ ## launch_persistent_context
100
+
101
+ ```
102
+ def launch_persistent_context(
103
+ userDataDir,
104
+ acceptDownloads: nil,
105
+ args: nil,
106
+ bypassCSP: nil,
107
+ channel: nil,
108
+ chromiumSandbox: nil,
109
+ colorScheme: nil,
110
+ deviceScaleFactor: nil,
111
+ devtools: nil,
112
+ downloadsPath: nil,
113
+ env: nil,
114
+ executablePath: nil,
115
+ extraHTTPHeaders: nil,
116
+ geolocation: nil,
117
+ handleSIGHUP: nil,
118
+ handleSIGINT: nil,
119
+ handleSIGTERM: nil,
120
+ hasTouch: nil,
121
+ headless: nil,
122
+ httpCredentials: nil,
123
+ ignoreDefaultArgs: nil,
124
+ ignoreHTTPSErrors: nil,
125
+ isMobile: nil,
126
+ javaScriptEnabled: nil,
127
+ locale: nil,
128
+ noViewport: nil,
129
+ offline: nil,
130
+ permissions: nil,
131
+ proxy: nil,
132
+ record_har_omit_content: nil,
133
+ record_har_path: nil,
134
+ record_video_dir: nil,
135
+ record_video_size: nil,
136
+ reducedMotion: nil,
137
+ screen: nil,
138
+ slowMo: nil,
139
+ timeout: nil,
140
+ timezoneId: nil,
141
+ tracesDir: nil,
142
+ userAgent: nil,
143
+ viewport: nil,
144
+ &block)
145
+ ```
146
+
147
+ Returns the persistent browser context instance.
148
+
149
+ Launches browser that uses persistent storage located at `userDataDir` and returns the only context. Closing this
150
+ context will automatically close the browser.
151
+
152
+ ## name
153
+
154
+ ```
155
+ def name
156
+ ```
157
+
158
+ Returns browser name. For example: `'chromium'`, `'webkit'` or `'firefox'`.
@@ -0,0 +1,7 @@
1
+ ---
2
+ sidebar_position: 10
3
+ ---
4
+
5
+ # CDPSession
6
+
7
+ Not Implemented
@@ -0,0 +1,41 @@
1
+ ---
2
+ sidebar_position: 10
3
+ ---
4
+
5
+ # ConsoleMessage
6
+
7
+ [ConsoleMessage](./console_message) objects are dispatched by page via the [`event: Page.console`] event.
8
+
9
+ ## args
10
+
11
+ ```
12
+ def args
13
+ ```
14
+
15
+ List of arguments passed to a `console` function call. See also [`event: Page.console`].
16
+
17
+ ## location
18
+
19
+ ```
20
+ def location
21
+ ```
22
+
23
+
24
+
25
+ ## text
26
+
27
+ ```
28
+ def text
29
+ ```
30
+
31
+ The text of the console message.
32
+
33
+ ## type
34
+
35
+ ```
36
+ def type
37
+ ```
38
+
39
+ One of the following values: `'log'`, `'debug'`, `'info'`, `'error'`, `'warning'`, `'dir'`, `'dirxml'`, `'table'`,
40
+ `'trace'`, `'clear'`, `'startGroup'`, `'startGroupCollapsed'`, `'endGroup'`, `'assert'`, `'profile'`, `'profileEnd'`,
41
+ `'count'`, `'timeEnd'`.
@@ -0,0 +1,71 @@
1
+ ---
2
+ sidebar_position: 10
3
+ ---
4
+
5
+ # Dialog
6
+
7
+ [Dialog](./dialog) objects are dispatched by page via the [`event: Page.dialog`] event.
8
+
9
+ An example of using [Dialog](./dialog) class:
10
+
11
+ ```ruby
12
+ def handle_dialog(dialog)
13
+ puts "[#{dialog.type}] #{dialog.message}"
14
+ if dialog.message =~ /foo/
15
+ dialog.accept_async
16
+ else
17
+ dialog.dismiss
18
+ end
19
+ end
20
+
21
+ page.on("dialog", method(:handle_dialog))
22
+ page.evaluate("confirm('foo')") # will be accepted
23
+ # => [confirm] foo
24
+ page.evaluate("alert('bar')") # will be dismissed
25
+ # => [alert] bar
26
+ ```
27
+
28
+ > NOTE: Dialogs are dismissed automatically, unless there is a [`event: Page.dialog`] listener. When listener is
29
+ present, it **must** either [Dialog#accept](./dialog#accept) or [Dialog#dismiss](./dialog#dismiss) the dialog - otherwise the page will
30
+ [freeze](https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop#never_blocking) waiting for the dialog, and
31
+ actions like click will never finish.
32
+
33
+ ## accept
34
+
35
+ ```
36
+ def accept(promptText: nil)
37
+ ```
38
+
39
+ Returns when the dialog has been accepted.
40
+
41
+ ## default_value
42
+
43
+ ```
44
+ def default_value
45
+ ```
46
+
47
+ If dialog is prompt, returns default prompt value. Otherwise, returns empty string.
48
+
49
+ ## dismiss
50
+
51
+ ```
52
+ def dismiss
53
+ ```
54
+
55
+ Returns when the dialog has been dismissed.
56
+
57
+ ## message
58
+
59
+ ```
60
+ def message
61
+ ```
62
+
63
+ A message displayed in the dialog.
64
+
65
+ ## type
66
+
67
+ ```
68
+ def type
69
+ ```
70
+
71
+ Returns dialog's type, can be one of `alert`, `beforeunload`, `confirm` or `prompt`.
@@ -0,0 +1,618 @@
1
+ ---
2
+ sidebar_position: 10
3
+ ---
4
+
5
+ # ElementHandle
6
+
7
+ - extends: [JSHandle](./js_handle)
8
+
9
+ ElementHandle represents an in-page DOM element. ElementHandles can be created with the [Page#query_selector](./page#query_selector)
10
+ method.
11
+
12
+ ```ruby
13
+ page.goto("https://example.com")
14
+ href_element = page.query_selector("a")
15
+ href_element.click
16
+ # ...
17
+ ```
18
+
19
+ ElementHandle prevents DOM element from garbage collection unless the handle is disposed with
20
+ [JSHandle#dispose](./js_handle#dispose). ElementHandles are auto-disposed when their origin frame gets navigated.
21
+
22
+ ElementHandle instances can be used as an argument in [Page#eval_on_selector](./page#eval_on_selector) and [Page#evaluate](./page#evaluate)
23
+ methods.
24
+
25
+ ## bounding_box
26
+
27
+ ```
28
+ def bounding_box
29
+ ```
30
+
31
+ This method returns the bounding box of the element, or `null` if the element is not visible. The bounding box is
32
+ calculated relative to the main frame viewport - which is usually the same as the browser window.
33
+
34
+ Scrolling affects the returned bonding box, similarly to
35
+ [Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect). That
36
+ means `x` and/or `y` may be negative.
37
+
38
+ Elements from child frames return the bounding box relative to the main frame, unlike the
39
+ [Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect).
40
+
41
+ Assuming the page is static, it is safe to use bounding box coordinates to perform input. For example, the following
42
+ snippet should click the center of the element.
43
+
44
+ ```ruby
45
+ box = element_handle.bounding_box
46
+ page.mouse.click(
47
+ box["x"] + box["width"] / 2,
48
+ box["y"] + box["height"] / 2,
49
+ )
50
+ ```
51
+
52
+
53
+
54
+ ## check
55
+
56
+ ```
57
+ def check(
58
+ force: nil,
59
+ noWaitAfter: nil,
60
+ position: nil,
61
+ timeout: nil,
62
+ trial: nil)
63
+ ```
64
+
65
+ This method checks the element by performing the following steps:
66
+ 1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already checked,
67
+ this method returns immediately.
68
+ 1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the element, unless `force` option is set.
69
+ 1. Scroll the element into view if needed.
70
+ 1. Use [Page#mouse](./page#mouse) to click in the center of the element.
71
+ 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
72
+ 1. Ensure that the element is now checked. If not, this method throws.
73
+
74
+ If the element is detached from the DOM at any moment during the action, this method throws.
75
+
76
+ When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
77
+ zero timeout disables this.
78
+
79
+ ## click
80
+
81
+ ```
82
+ def click(
83
+ button: nil,
84
+ clickCount: nil,
85
+ delay: nil,
86
+ force: nil,
87
+ modifiers: nil,
88
+ noWaitAfter: nil,
89
+ position: nil,
90
+ timeout: nil,
91
+ trial: nil)
92
+ ```
93
+
94
+ This method clicks the element by performing the following steps:
95
+ 1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the element, unless `force` option is set.
96
+ 1. Scroll the element into view if needed.
97
+ 1. Use [Page#mouse](./page#mouse) to click in the center of the element, or the specified `position`.
98
+ 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
99
+
100
+ If the element is detached from the DOM at any moment during the action, this method throws.
101
+
102
+ When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
103
+ zero timeout disables this.
104
+
105
+ ## content_frame
106
+
107
+ ```
108
+ def content_frame
109
+ ```
110
+
111
+ Returns the content frame for element handles referencing iframe nodes, or `null` otherwise
112
+
113
+ ## dblclick
114
+
115
+ ```
116
+ def dblclick(
117
+ button: nil,
118
+ delay: nil,
119
+ force: nil,
120
+ modifiers: nil,
121
+ noWaitAfter: nil,
122
+ position: nil,
123
+ timeout: nil,
124
+ trial: nil)
125
+ ```
126
+
127
+ This method double clicks the element by performing the following steps:
128
+ 1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the element, unless `force` option is set.
129
+ 1. Scroll the element into view if needed.
130
+ 1. Use [Page#mouse](./page#mouse) to double click in the center of the element, or the specified `position`.
131
+ 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the
132
+ first click of the `dblclick()` triggers a navigation event, this method will throw.
133
+
134
+ If the element is detached from the DOM at any moment during the action, this method throws.
135
+
136
+ When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
137
+ zero timeout disables this.
138
+
139
+ > NOTE: `elementHandle.dblclick()` dispatches two `click` events and a single `dblclick` event.
140
+
141
+ ## dispatch_event
142
+
143
+ ```
144
+ def dispatch_event(type, eventInit: nil)
145
+ ```
146
+
147
+ The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element,
148
+ `click` is dispatched. This is equivalent to calling
149
+ [element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
150
+
151
+ ```ruby
152
+ element_handle.dispatch_event("click")
153
+ ```
154
+
155
+ Under the hood, it creates an instance of an event based on the given `type`, initializes it with `eventInit` properties
156
+ and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default.
157
+
158
+ Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial properties:
159
+ - [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent)
160
+ - [FocusEvent](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent)
161
+ - [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent)
162
+ - [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent)
163
+ - [PointerEvent](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/PointerEvent)
164
+ - [TouchEvent](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/TouchEvent)
165
+ - [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event/Event)
166
+
167
+ You can also specify [JSHandle](./js_handle) as the property value if you want live objects to be passed into the event:
168
+
169
+ ```ruby
170
+ # note you can only create data_transfer in chromium and firefox
171
+ data_transfer = page.evaluate_handle("new DataTransfer()")
172
+ element_handle.dispatch_event("dragstart", eventInit: { dataTransfer: data_transfer })
173
+ ```
174
+
175
+
176
+
177
+ ## eval_on_selector
178
+
179
+ ```
180
+ def eval_on_selector(selector, expression, arg: nil)
181
+ ```
182
+
183
+ Returns the return value of `expression`.
184
+
185
+ The method finds an element matching the specified selector in the [ElementHandle](./element_handle)s subtree and passes it as a first
186
+ argument to `expression`. See [Working with selectors](https://playwright.dev/python/docs/selectors) for more details. If no elements match the
187
+ selector, the method throws an error.
188
+
189
+ If `expression` returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), then [ElementHandle#eval_on_selector](./element_handle#eval_on_selector) would wait for the promise to resolve
190
+ and return its value.
191
+
192
+ Examples:
193
+
194
+ ```ruby
195
+ tweet_handle = page.query_selector(".tweet")
196
+ tweet_handle.eval_on_selector(".like", "node => node.innerText") # => "100"
197
+ tweet_handle.eval_on_selector(".retweets", "node => node.innerText") # => "10"
198
+ ```
199
+
200
+
201
+
202
+ ## eval_on_selector_all
203
+
204
+ ```
205
+ def eval_on_selector_all(selector, expression, arg: nil)
206
+ ```
207
+
208
+ Returns the return value of `expression`.
209
+
210
+ The method finds all elements matching the specified selector in the [ElementHandle](./element_handle)'s subtree and passes an array of
211
+ matched elements as a first argument to `expression`. See [Working with selectors](https://playwright.dev/python/docs/selectors) for more details.
212
+
213
+ If `expression` returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), then [ElementHandle#eval_on_selector_all](./element_handle#eval_on_selector_all) would wait for the promise to
214
+ resolve and return its value.
215
+
216
+ Examples:
217
+
218
+ ```html
219
+ <div class="feed">
220
+ <div class="tweet">Hello!</div>
221
+ <div class="tweet">Hi!</div>
222
+ </div>
223
+ ```
224
+
225
+ ```ruby
226
+ feed_handle = page.query_selector(".feed")
227
+ feed_handle.eval_on_selector_all(".tweet", "nodes => nodes.map(n => n.innerText)") # => ["hello!", "hi!"]
228
+ ```
229
+
230
+
231
+
232
+ ## fill
233
+
234
+ ```
235
+ def fill(value, noWaitAfter: nil, timeout: nil)
236
+ ```
237
+
238
+ This method waits for [actionability](https://playwright.dev/python/docs/actionability) checks, focuses the element, fills it and triggers an `input`
239
+ event after filling. Note that you can pass an empty string to clear the input field.
240
+
241
+ If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error.
242
+ However, if the element is inside the `<label>` element that has an associated
243
+ [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled
244
+ instead.
245
+
246
+ To send fine-grained keyboard events, use [ElementHandle#type](./element_handle#type).
247
+
248
+ ## focus
249
+
250
+ ```
251
+ def focus
252
+ ```
253
+
254
+ Calls [focus](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the element.
255
+
256
+ ## get_attribute
257
+
258
+ ```
259
+ def get_attribute(name)
260
+ ```
261
+ alias: `[]`
262
+
263
+ Returns element attribute value.
264
+
265
+ ## hover
266
+
267
+ ```
268
+ def hover(
269
+ force: nil,
270
+ modifiers: nil,
271
+ position: nil,
272
+ timeout: nil,
273
+ trial: nil)
274
+ ```
275
+
276
+ This method hovers over the element by performing the following steps:
277
+ 1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the element, unless `force` option is set.
278
+ 1. Scroll the element into view if needed.
279
+ 1. Use [Page#mouse](./page#mouse) to hover over the center of the element, or the specified `position`.
280
+ 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
281
+
282
+ If the element is detached from the DOM at any moment during the action, this method throws.
283
+
284
+ When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
285
+ zero timeout disables this.
286
+
287
+ ## inner_html
288
+
289
+ ```
290
+ def inner_html
291
+ ```
292
+
293
+ Returns the `element.innerHTML`.
294
+
295
+ ## inner_text
296
+
297
+ ```
298
+ def inner_text
299
+ ```
300
+
301
+ Returns the `element.innerText`.
302
+
303
+ ## checked?
304
+
305
+ ```
306
+ def checked?
307
+ ```
308
+
309
+ Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
310
+
311
+ ## disabled?
312
+
313
+ ```
314
+ def disabled?
315
+ ```
316
+
317
+ Returns whether the element is disabled, the opposite of [enabled](https://playwright.dev/python/docs/actionability).
318
+
319
+ ## editable?
320
+
321
+ ```
322
+ def editable?
323
+ ```
324
+
325
+ Returns whether the element is [editable](https://playwright.dev/python/docs/actionability).
326
+
327
+ ## enabled?
328
+
329
+ ```
330
+ def enabled?
331
+ ```
332
+
333
+ Returns whether the element is [enabled](https://playwright.dev/python/docs/actionability).
334
+
335
+ ## hidden?
336
+
337
+ ```
338
+ def hidden?
339
+ ```
340
+
341
+ Returns whether the element is hidden, the opposite of [visible](https://playwright.dev/python/docs/actionability).
342
+
343
+ ## visible?
344
+
345
+ ```
346
+ def visible?
347
+ ```
348
+
349
+ Returns whether the element is [visible](https://playwright.dev/python/docs/actionability).
350
+
351
+ ## owner_frame
352
+
353
+ ```
354
+ def owner_frame
355
+ ```
356
+
357
+ Returns the frame containing the given element.
358
+
359
+ ## press
360
+
361
+ ```
362
+ def press(key, delay: nil, noWaitAfter: nil, timeout: nil)
363
+ ```
364
+
365
+ Focuses the element, and then uses [Keyboard#down](./keyboard#down) and [Keyboard#up](./keyboard#up).
366
+
367
+ `key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)
368
+ value or a single character to generate the text for. A superset of the `key` values can be found
369
+ [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
370
+
371
+ `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
372
+ `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
373
+
374
+ Following modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`.
375
+
376
+ Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
377
+
378
+ If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
379
+ texts.
380
+
381
+ Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
382
+ modifier, modifier is pressed and being held while the subsequent key is being pressed.
383
+
384
+ ## query_selector
385
+
386
+ ```
387
+ def query_selector(selector)
388
+ ```
389
+
390
+ The method finds an element matching the specified selector in the [ElementHandle](./element_handle)'s subtree. See
391
+ [Working with selectors](https://playwright.dev/python/docs/selectors) for more details. If no elements match the selector, returns `null`.
392
+
393
+ ## query_selector_all
394
+
395
+ ```
396
+ def query_selector_all(selector)
397
+ ```
398
+
399
+ The method finds all elements matching the specified selector in the [ElementHandle](./element_handle)s subtree. See
400
+ [Working with selectors](https://playwright.dev/python/docs/selectors) for more details. If no elements match the selector, returns empty array.
401
+
402
+ ## screenshot
403
+
404
+ ```
405
+ def screenshot(
406
+ omitBackground: nil,
407
+ path: nil,
408
+ quality: nil,
409
+ timeout: nil,
410
+ type: nil)
411
+ ```
412
+
413
+ Returns the buffer with the captured screenshot.
414
+
415
+ This method waits for the [actionability](https://playwright.dev/python/docs/actionability) checks, then scrolls element into view before taking a
416
+ screenshot. If the element is detached from DOM, the method throws an error.
417
+
418
+ ## scroll_into_view_if_needed
419
+
420
+ ```
421
+ def scroll_into_view_if_needed(timeout: nil)
422
+ ```
423
+
424
+ This method waits for [actionability](https://playwright.dev/python/docs/actionability) checks, then tries to scroll element into view, unless it is
425
+ completely visible as defined by
426
+ [IntersectionObserver](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API)'s `ratio`.
427
+
428
+ Throws when `elementHandle` does not point to an element
429
+ [connected](https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected) to a Document or a ShadowRoot.
430
+
431
+ ## select_option
432
+
433
+ ```
434
+ def select_option(
435
+ element: nil,
436
+ index: nil,
437
+ value: nil,
438
+ label: nil,
439
+ noWaitAfter: nil,
440
+ timeout: nil)
441
+ ```
442
+
443
+ This method waits for [actionability](https://playwright.dev/python/docs/actionability) checks, waits until all specified options are present in the
444
+ `<select>` element and selects these options.
445
+
446
+ If the target element is not a `<select>` element, this method throws an error. However, if the element is inside the
447
+ `<label>` element that has an associated
448
+ [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used instead.
449
+
450
+ Returns the array of option values that have been successfully selected.
451
+
452
+ Triggers a `change` and `input` event once all the provided options have been selected.
453
+
454
+ ```ruby
455
+ # single selection matching the value
456
+ element_handle.select_option(value: "blue")
457
+ # single selection matching both the label
458
+ element_handle.select_option(label: "blue")
459
+ # multiple selection
460
+ element_handle.select_option(value: ["red", "green", "blue"])
461
+ ```
462
+
463
+ ```ruby
464
+ # multiple selection for blue, red and second option
465
+ element_handle.select_option(value: "blue", index: 2, label: "red")
466
+ ```
467
+
468
+
469
+
470
+ ## select_text
471
+
472
+ ```
473
+ def select_text(timeout: nil)
474
+ ```
475
+
476
+ This method waits for [actionability](https://playwright.dev/python/docs/actionability) checks, then focuses the element and selects all its text
477
+ content.
478
+
479
+ ## set_input_files
480
+
481
+ ```
482
+ def set_input_files(files, noWaitAfter: nil, timeout: nil)
483
+ ```
484
+ alias: `input_files=`
485
+
486
+ This method expects `elementHandle` to point to an
487
+ [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
488
+
489
+ Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
490
+ are resolved relative to the the current working directory. For empty array, clears the selected files.
491
+
492
+ ## tap_point
493
+
494
+ ```
495
+ def tap_point(
496
+ force: nil,
497
+ modifiers: nil,
498
+ noWaitAfter: nil,
499
+ position: nil,
500
+ timeout: nil,
501
+ trial: nil)
502
+ ```
503
+
504
+ This method taps the element by performing the following steps:
505
+ 1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the element, unless `force` option is set.
506
+ 1. Scroll the element into view if needed.
507
+ 1. Use [Page#touchscreen](./page#touchscreen) to tap the center of the element, or the specified `position`.
508
+ 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
509
+
510
+ If the element is detached from the DOM at any moment during the action, this method throws.
511
+
512
+ When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
513
+ zero timeout disables this.
514
+
515
+ > NOTE: `elementHandle.tap()` requires that the `hasTouch` option of the browser context be set to true.
516
+
517
+ ## text_content
518
+
519
+ ```
520
+ def text_content
521
+ ```
522
+
523
+ Returns the `node.textContent`.
524
+
525
+ ## type
526
+
527
+ ```
528
+ def type(text, delay: nil, noWaitAfter: nil, timeout: nil)
529
+ ```
530
+
531
+ Focuses the element, and then sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
532
+
533
+ To press a special key, like `Control` or `ArrowDown`, use [ElementHandle#press](./element_handle#press).
534
+
535
+ ```ruby
536
+ element_handle.type("hello") # types instantly
537
+ element_handle.type("world", delay: 100) # types slower, like a user
538
+ ```
539
+
540
+ An example of typing into a text field and then submitting the form:
541
+
542
+ ```ruby
543
+ element_handle = page.query_selector("input")
544
+ element_handle.type("some text")
545
+ element_handle.press("Enter")
546
+ ```
547
+
548
+
549
+
550
+ ## uncheck
551
+
552
+ ```
553
+ def uncheck(
554
+ force: nil,
555
+ noWaitAfter: nil,
556
+ position: nil,
557
+ timeout: nil,
558
+ trial: nil)
559
+ ```
560
+
561
+ This method checks the element by performing the following steps:
562
+ 1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already
563
+ unchecked, this method returns immediately.
564
+ 1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the element, unless `force` option is set.
565
+ 1. Scroll the element into view if needed.
566
+ 1. Use [Page#mouse](./page#mouse) to click in the center of the element.
567
+ 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
568
+ 1. Ensure that the element is now unchecked. If not, this method throws.
569
+
570
+ If the element is detached from the DOM at any moment during the action, this method throws.
571
+
572
+ When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
573
+ zero timeout disables this.
574
+
575
+ ## wait_for_element_state
576
+
577
+ ```
578
+ def wait_for_element_state(state, timeout: nil)
579
+ ```
580
+
581
+ Returns when the element satisfies the `state`.
582
+
583
+ Depending on the `state` parameter, this method waits for one of the [actionability](https://playwright.dev/python/docs/actionability) checks to pass.
584
+ This method throws when the element is detached while waiting, unless waiting for the `"hidden"` state.
585
+ - `"visible"` Wait until the element is [visible](https://playwright.dev/python/docs/actionability).
586
+ - `"hidden"` Wait until the element is [not visible](https://playwright.dev/python/docs/actionability) or
587
+ [not attached](https://playwright.dev/python/docs/actionability). Note that waiting for hidden does not throw when the element detaches.
588
+ - `"stable"` Wait until the element is both [visible](https://playwright.dev/python/docs/actionability) and
589
+ [stable](https://playwright.dev/python/docs/actionability).
590
+ - `"enabled"` Wait until the element is [enabled](https://playwright.dev/python/docs/actionability).
591
+ - `"disabled"` Wait until the element is [not enabled](https://playwright.dev/python/docs/actionability).
592
+ - `"editable"` Wait until the element is [editable](https://playwright.dev/python/docs/actionability).
593
+
594
+ If the element does not satisfy the condition for the `timeout` milliseconds, this method will throw.
595
+
596
+ ## wait_for_selector
597
+
598
+ ```
599
+ def wait_for_selector(selector, state: nil, timeout: nil)
600
+ ```
601
+
602
+ Returns element specified by selector when it satisfies `state` option. Returns `null` if waiting for `hidden` or
603
+ `detached`.
604
+
605
+ Wait for the `selector` relative to the element handle to satisfy `state` option (either appear/disappear from dom, or
606
+ become visible/hidden). If at the moment of calling the method `selector` already satisfies the condition, the method
607
+ will return immediately. If the selector doesn't satisfy the condition for the `timeout` milliseconds, the function will
608
+ throw.
609
+
610
+ ```python sync title=example_3b0f6c6573db513b7b707a39d6c5bbf5ce5896b4785466d80f525968cfbd0be7.py
611
+ page.set_content("<div><span></span></div>")
612
+ div = page.query_selector("div")
613
+ # waiting for the "span" selector relative to the div.
614
+ span = div.wait_for_selector("span", state="attached")
615
+
616
+ ```
617
+
618
+ > NOTE: This method does not work across navigations, use [Page#wait_for_selector](./page#wait_for_selector) instead.