playwright-ruby-client 1.28.1 → 1.29.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/documentation/docs/api/accessibility.md +9 -14
  3. data/documentation/docs/api/api_request_context.md +44 -41
  4. data/documentation/docs/api/api_response.md +13 -3
  5. data/documentation/docs/api/browser.md +24 -23
  6. data/documentation/docs/api/browser_context.md +71 -45
  7. data/documentation/docs/api/browser_type.md +21 -14
  8. data/documentation/docs/api/cdp_session.md +3 -5
  9. data/documentation/docs/api/console_message.md +7 -4
  10. data/documentation/docs/api/dialog.md +9 -5
  11. data/documentation/docs/api/download.md +19 -11
  12. data/documentation/docs/api/element_handle.md +125 -116
  13. data/documentation/docs/api/experimental/android.md +4 -5
  14. data/documentation/docs/api/experimental/android_device.md +11 -2
  15. data/documentation/docs/api/experimental/android_input.md +5 -0
  16. data/documentation/docs/api/file_chooser.md +6 -3
  17. data/documentation/docs/api/frame.md +182 -171
  18. data/documentation/docs/api/frame_locator.md +27 -38
  19. data/documentation/docs/api/js_handle.md +16 -10
  20. data/documentation/docs/api/keyboard.md +29 -16
  21. data/documentation/docs/api/locator.md +189 -140
  22. data/documentation/docs/api/mouse.md +9 -4
  23. data/documentation/docs/api/page.md +304 -289
  24. data/documentation/docs/api/playwright.md +8 -5
  25. data/documentation/docs/api/request.md +34 -15
  26. data/documentation/docs/api/response.md +27 -10
  27. data/documentation/docs/api/route.md +44 -12
  28. data/documentation/docs/api/selectors.md +5 -3
  29. data/documentation/docs/api/touchscreen.md +2 -0
  30. data/documentation/docs/api/tracing.md +11 -11
  31. data/documentation/docs/api/web_socket.md +9 -4
  32. data/documentation/docs/api/worker.md +12 -11
  33. data/documentation/docs/include/api_coverage.md +2 -0
  34. data/lib/playwright/channel_owners/api_request_context.rb +37 -2
  35. data/lib/playwright/channel_owners/browser_context.rb +22 -26
  36. data/lib/playwright/channel_owners/page.rb +35 -25
  37. data/lib/playwright/channel_owners/route.rb +28 -8
  38. data/lib/playwright/event_emitter.rb +6 -1
  39. data/lib/playwright/locator_impl.rb +8 -0
  40. data/lib/playwright/select_option_values.rb +2 -0
  41. data/lib/playwright/version.rb +2 -2
  42. data/lib/playwright_api/accessibility.rb +9 -13
  43. data/lib/playwright_api/android.rb +8 -6
  44. data/lib/playwright_api/android_device.rb +32 -7
  45. data/lib/playwright_api/android_input.rb +5 -0
  46. data/lib/playwright_api/android_socket.rb +4 -2
  47. data/lib/playwright_api/android_web_view.rb +5 -2
  48. data/lib/playwright_api/api_request.rb +6 -3
  49. data/lib/playwright_api/api_request_context.rb +46 -36
  50. data/lib/playwright_api/api_response.rb +13 -2
  51. data/lib/playwright_api/browser.rb +24 -16
  52. data/lib/playwright_api/browser_context.rb +76 -39
  53. data/lib/playwright_api/browser_type.rb +23 -13
  54. data/lib/playwright_api/cdp_session.rb +3 -4
  55. data/lib/playwright_api/console_message.rb +7 -2
  56. data/lib/playwright_api/dialog.rb +8 -4
  57. data/lib/playwright_api/download.rb +19 -9
  58. data/lib/playwright_api/element_handle.rb +116 -93
  59. data/lib/playwright_api/file_chooser.rb +6 -1
  60. data/lib/playwright_api/frame.rb +180 -135
  61. data/lib/playwright_api/frame_locator.rb +29 -32
  62. data/lib/playwright_api/js_handle.rb +16 -6
  63. data/lib/playwright_api/keyboard.rb +29 -14
  64. data/lib/playwright_api/locator.rb +183 -112
  65. data/lib/playwright_api/mouse.rb +9 -2
  66. data/lib/playwright_api/page.rb +301 -253
  67. data/lib/playwright_api/playwright.rb +11 -4
  68. data/lib/playwright_api/request.rb +34 -7
  69. data/lib/playwright_api/response.rb +27 -10
  70. data/lib/playwright_api/route.rb +44 -11
  71. data/lib/playwright_api/selectors.rb +6 -1
  72. data/lib/playwright_api/touchscreen.rb +2 -0
  73. data/lib/playwright_api/tracing.rb +11 -5
  74. data/lib/playwright_api/web_socket.rb +9 -4
  75. data/lib/playwright_api/worker.rb +16 -13
  76. data/playwright.gemspec +1 -1
  77. metadata +7 -7
@@ -1,25 +1,44 @@
1
1
  module Playwright
2
- # Locators are the central piece of Playwright's auto-waiting and retry-ability. In a nutshell, locators represent a way
3
- # to find element(s) on the page at any moment. Locator can be created with the [`method: Page.locator`] method.
2
+ #
3
+ # Locators are the central piece of Playwright's auto-waiting and retry-ability. In a nutshell, locators represent
4
+ # a way to find element(s) on the page at any moment. Locator can be created with the [`method: Page.locator`] method.
4
5
  #
5
6
  # [Learn more about locators](../locators.md).
6
7
  class Locator < PlaywrightApi
7
8
 
9
+ #
10
+ # When locator points to a list of elements, returns array of locators, pointing
11
+ # to respective elements.
12
+ #
13
+ # **Usage**
14
+ #
15
+ # ```python sync
16
+ # for li in page.get_by_role('listitem').all():
17
+ # li.click();
18
+ # ```
19
+ def all
20
+ wrap_impl(@impl.all)
21
+ end
22
+
23
+ #
8
24
  # Returns an array of `node.innerText` values for all matching nodes.
9
25
  def all_inner_texts
10
26
  wrap_impl(@impl.all_inner_texts)
11
27
  end
12
28
 
29
+ #
13
30
  # Returns an array of `node.textContent` values for all matching nodes.
14
31
  def all_text_contents
15
32
  wrap_impl(@impl.all_text_contents)
16
33
  end
17
34
 
35
+ #
18
36
  # Calls [blur](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/blur) on the element.
19
37
  def blur(timeout: nil)
20
38
  wrap_impl(@impl.blur(timeout: unwrap_impl(timeout)))
21
39
  end
22
40
 
41
+ #
23
42
  # This method returns the bounding box of the element, or `null` if the element is not visible. The bounding box is
24
43
  # calculated relative to the main frame viewport - which is usually the same as the browser window.
25
44
  #
@@ -33,6 +52,8 @@ module Playwright
33
52
  # Assuming the page is static, it is safe to use bounding box coordinates to perform input. For example, the following
34
53
  # snippet should click the center of the element.
35
54
  #
55
+ # **Usage**
56
+ #
36
57
  # ```python sync
37
58
  # box = element.bounding_box()
38
59
  # page.mouse.click(box["x"] + box["width"] / 2, box["y"] + box["height"] / 2)
@@ -41,9 +62,9 @@ module Playwright
41
62
  wrap_impl(@impl.bounding_box(timeout: unwrap_impl(timeout)))
42
63
  end
43
64
 
65
+ #
44
66
  # This method checks the element by performing the following steps:
45
- # 1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already checked,
46
- # this method returns immediately.
67
+ # 1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already checked, this method returns immediately.
47
68
  # 1. Wait for [actionability](../actionability.md) checks on the element, unless `force` option is set.
48
69
  # 1. Scroll the element into view if needed.
49
70
  # 1. Use [`property: Page.mouse`] to click in the center of the element.
@@ -52,8 +73,8 @@ module Playwright
52
73
  #
53
74
  # If the element is detached from the DOM at any moment during the action, this method throws.
54
75
  #
55
- # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
56
- # zero timeout disables this.
76
+ # When all steps combined have not finished during the specified `timeout`, this method throws a
77
+ # `TimeoutError`. Passing zero timeout disables this.
57
78
  def check(
58
79
  force: nil,
59
80
  noWaitAfter: nil,
@@ -63,17 +84,19 @@ module Playwright
63
84
  wrap_impl(@impl.check(force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
64
85
  end
65
86
 
66
- # This method waits for [actionability](../actionability.md) checks, focuses the element, clears it and triggers an
67
- # `input` event after clearing.
68
87
  #
69
- # If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error.
70
- # However, if the element is inside the `<label>` element that has an associated
71
- # [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be cleared
72
- # instead.
88
+ # This method waits for [actionability](../actionability.md) checks, focuses the element, clears it and triggers an `input` event after clearing.
89
+ #
90
+ # If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error. However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be cleared instead.
73
91
  def clear(force: nil, noWaitAfter: nil, timeout: nil)
74
92
  wrap_impl(@impl.clear(force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
75
93
  end
76
94
 
95
+ #
96
+ # Click an element.
97
+ #
98
+ # **Details**
99
+ #
77
100
  # This method clicks the element by performing the following steps:
78
101
  # 1. Wait for [actionability](../actionability.md) checks on the element, unless `force` option is set.
79
102
  # 1. Scroll the element into view if needed.
@@ -82,8 +105,8 @@ module Playwright
82
105
  #
83
106
  # If the element is detached from the DOM at any moment during the action, this method throws.
84
107
  #
85
- # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
86
- # zero timeout disables this.
108
+ # When all steps combined have not finished during the specified `timeout`, this method throws a
109
+ # `TimeoutError`. Passing zero timeout disables this.
87
110
  def click(
88
111
  button: nil,
89
112
  clickCount: nil,
@@ -97,24 +120,25 @@ module Playwright
97
120
  wrap_impl(@impl.click(button: unwrap_impl(button), clickCount: unwrap_impl(clickCount), delay: unwrap_impl(delay), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
98
121
  end
99
122
 
123
+ #
100
124
  # Returns the number of elements matching given selector.
101
125
  def count
102
126
  wrap_impl(@impl.count)
103
127
  end
104
128
 
129
+ #
105
130
  # This method double clicks the element by performing the following steps:
106
131
  # 1. Wait for [actionability](../actionability.md) checks on the element, unless `force` option is set.
107
132
  # 1. Scroll the element into view if needed.
108
133
  # 1. Use [`property: Page.mouse`] to double click in the center of the element, or the specified `position`.
109
- # 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the
110
- # first click of the `dblclick()` triggers a navigation event, this method will throw.
134
+ # 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the first click of the `dblclick()` triggers a navigation event, this method will throw.
111
135
  #
112
136
  # If the element is detached from the DOM at any moment during the action, this method throws.
113
137
  #
114
- # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
115
- # zero timeout disables this.
138
+ # When all steps combined have not finished during the specified `timeout`, this method throws a
139
+ # `TimeoutError`. Passing zero timeout disables this.
116
140
  #
117
- # > NOTE: `element.dblclick()` dispatches two `click` events and a single `dblclick` event.
141
+ # **NOTE**: `element.dblclick()` dispatches two `click` events and a single `dblclick` event.
118
142
  def dblclick(
119
143
  button: nil,
120
144
  delay: nil,
@@ -127,18 +151,23 @@ module Playwright
127
151
  wrap_impl(@impl.dblclick(button: unwrap_impl(button), delay: unwrap_impl(delay), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
128
152
  end
129
153
 
130
- # The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element,
131
- # `click` is dispatched. This is equivalent to calling
154
+ #
155
+ # The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element, `click`
156
+ # is dispatched. This is equivalent to calling
132
157
  # [element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
133
158
  #
159
+ # **Usage**
160
+ #
134
161
  # ```python sync
135
162
  # element.dispatch_event("click")
136
163
  # ```
137
164
  #
138
- # Under the hood, it creates an instance of an event based on the given `type`, initializes it with `eventInit` properties
139
- # and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default.
165
+ # Under the hood, it creates an instance of an event based on the given `type`, initializes it with
166
+ # `eventInit` properties and dispatches it on the element. Events are `composed`, `cancelable` and bubble by
167
+ # default.
140
168
  #
141
- # Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial properties:
169
+ # Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial
170
+ # properties:
142
171
  # - [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent)
143
172
  # - [FocusEvent](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent)
144
173
  # - [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent)
@@ -158,8 +187,12 @@ module Playwright
158
187
  wrap_impl(@impl.dispatch_event(unwrap_impl(type), eventInit: unwrap_impl(eventInit), timeout: unwrap_impl(timeout)))
159
188
  end
160
189
 
161
- # This method drags the locator to another target locator or target position. It will first move to the source element,
162
- # perform a `mousedown`, then move to the target element or position and perform a `mouseup`.
190
+ #
191
+ # This method drags the locator to another target locator or target position. It will
192
+ # first move to the source element, perform a `mousedown`, then move to the target
193
+ # element or position and perform a `mouseup`.
194
+ #
195
+ # **Usage**
163
196
  #
164
197
  # ```python sync
165
198
  # source = page.locator("#source")
@@ -184,24 +217,27 @@ module Playwright
184
217
  wrap_impl(@impl.drag_to(unwrap_impl(target), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), sourcePosition: unwrap_impl(sourcePosition), targetPosition: unwrap_impl(targetPosition), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
185
218
  end
186
219
 
187
- # Resolves given locator to the first matching DOM element. If no elements matching the query are visible, waits for them
188
- # up to a given timeout. If multiple elements match the selector, throws.
220
+ #
221
+ # Resolves given locator to the first matching DOM element. If no elements matching the query are visible, waits for them up to a given timeout. If multiple elements match the selector, throws.
189
222
  def element_handle(timeout: nil)
190
223
  wrap_impl(@impl.element_handle(timeout: unwrap_impl(timeout)))
191
224
  end
192
225
 
226
+ #
193
227
  # Resolves given locator to all matching DOM elements.
194
228
  def element_handles
195
229
  wrap_impl(@impl.element_handles)
196
230
  end
197
231
 
232
+ #
198
233
  # Returns the return value of `expression`.
199
234
  #
200
235
  # This method passes this handle as the first argument to `expression`.
201
236
  #
202
- # If `expression` returns a [Promise], then `handle.evaluate` would wait for the promise to resolve and return its value.
237
+ # If `expression` returns a [Promise], then `handle.evaluate` would wait for the promise to resolve and return
238
+ # its value.
203
239
  #
204
- # Examples:
240
+ # **Usage**
205
241
  #
206
242
  # ```python sync
207
243
  # tweets = page.locator(".tweet .retweets")
@@ -211,52 +247,53 @@ module Playwright
211
247
  wrap_impl(@impl.evaluate(unwrap_impl(expression), arg: unwrap_impl(arg), timeout: unwrap_impl(timeout)))
212
248
  end
213
249
 
214
- # The method finds all elements matching the specified locator and passes an array of matched elements as a first argument
215
- # to `expression`. Returns the result of `expression` invocation.
216
250
  #
217
- # If `expression` returns a [Promise], then [`method: Locator.evaluateAll`] would wait for the promise to resolve and
218
- # return its value.
251
+ # The method finds all elements matching the specified locator and passes an array of matched elements as
252
+ # a first argument to `expression`. Returns the result of `expression` invocation.
253
+ #
254
+ # If `expression` returns a [Promise], then [`method: Locator.evaluateAll`] would wait for the promise
255
+ # to resolve and return its value.
219
256
  #
220
- # Examples:
257
+ # **Usage**
221
258
  #
222
259
  # ```python sync
223
260
  # elements = page.locator("div")
224
- # div_counts = elements("(divs, min) => divs.length >= min", 10)
261
+ # div_counts = elements.evaluate_all("(divs, min) => divs.length >= min", 10)
225
262
  # ```
226
263
  def evaluate_all(expression, arg: nil)
227
264
  wrap_impl(@impl.evaluate_all(unwrap_impl(expression), arg: unwrap_impl(arg)))
228
265
  end
229
266
 
267
+ #
230
268
  # Returns the return value of `expression` as a `JSHandle`.
231
269
  #
232
270
  # This method passes this handle as the first argument to `expression`.
233
271
  #
234
- # The only difference between [`method: Locator.evaluate`] and [`method: Locator.evaluateHandle`] is that
235
- # [`method: Locator.evaluateHandle`] returns `JSHandle`.
272
+ # The only difference between [`method: Locator.evaluate`] and [`method: Locator.evaluateHandle`] is that [`method: Locator.evaluateHandle`] returns `JSHandle`.
236
273
  #
237
- # If the function passed to the [`method: Locator.evaluateHandle`] returns a [Promise], then
238
- # [`method: Locator.evaluateHandle`] would wait for the promise to resolve and return its value.
274
+ # If the function passed to the [`method: Locator.evaluateHandle`] returns a [Promise], then [`method: Locator.evaluateHandle`] would wait
275
+ # for the promise to resolve and return its value.
239
276
  #
240
277
  # See [`method: Page.evaluateHandle`] for more details.
241
278
  def evaluate_handle(expression, arg: nil, timeout: nil)
242
279
  wrap_impl(@impl.evaluate_handle(unwrap_impl(expression), arg: unwrap_impl(arg), timeout: unwrap_impl(timeout)))
243
280
  end
244
281
 
245
- # This method waits for [actionability](../actionability.md) checks, focuses the element, fills it and triggers an `input`
246
- # event after filling. Note that you can pass an empty string to clear the input field.
247
282
  #
248
- # If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error.
249
- # However, if the element is inside the `<label>` element that has an associated
250
- # [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled
251
- # instead.
283
+ # This method waits for [actionability](../actionability.md) checks, focuses the element, fills it and triggers an `input` event after filling. Note that you can pass an empty string to clear the input field.
284
+ #
285
+ # If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error. However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled instead.
252
286
  #
253
287
  # To send fine-grained keyboard events, use [`method: Locator.type`].
254
288
  def fill(value, force: nil, noWaitAfter: nil, timeout: nil)
255
289
  wrap_impl(@impl.fill(unwrap_impl(value), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
256
290
  end
257
291
 
258
- # This method narrows existing locator according to the options, for example filters by text. It can be chained to filter
259
- # multiple times.
292
+ #
293
+ # This method narrows existing locator according to the options, for example filters by text.
294
+ # It can be chained to filter multiple times.
295
+ #
296
+ # **Usage**
260
297
  #
261
298
  # ```python sync
262
299
  # row_locator = page.locator("tr")
@@ -270,18 +307,23 @@ module Playwright
270
307
  wrap_impl(@impl.filter(has: unwrap_impl(has), hasText: unwrap_impl(hasText)))
271
308
  end
272
309
 
310
+ #
273
311
  # Returns locator to the first matching element.
274
312
  def first
275
313
  wrap_impl(@impl.first)
276
314
  end
277
315
 
316
+ #
278
317
  # Calls [focus](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the element.
279
318
  def focus(timeout: nil)
280
319
  wrap_impl(@impl.focus(timeout: unwrap_impl(timeout)))
281
320
  end
282
321
 
283
- # When working with iframes, you can create a frame locator that will enter the iframe and allow selecting elements in
284
- # that iframe:
322
+ #
323
+ # **Usage**
324
+ #
325
+ # When working with iframes, you can create a frame locator that will enter the iframe and allow selecting elements
326
+ # in that iframe:
285
327
  #
286
328
  # ```python sync
287
329
  # locator = page.frame_locator("iframe").get_by_text("Submit")
@@ -291,12 +333,14 @@ module Playwright
291
333
  wrap_impl(@impl.frame_locator(unwrap_impl(selector)))
292
334
  end
293
335
 
336
+ #
294
337
  # Returns element attribute value.
295
338
  def get_attribute(name, timeout: nil)
296
339
  wrap_impl(@impl.get_attribute(unwrap_impl(name), timeout: unwrap_impl(timeout)))
297
340
  end
298
341
  alias_method :[], :get_attribute
299
342
 
343
+ #
300
344
  # Allows locating elements by their alt text. For example, this method will find the image by alt text "Castle":
301
345
  #
302
346
  # ```html
@@ -306,8 +350,8 @@ module Playwright
306
350
  wrap_impl(@impl.get_by_alt_text(unwrap_impl(text), exact: unwrap_impl(exact)))
307
351
  end
308
352
 
309
- # Allows locating input elements by the text of the associated label. For example, this method will find the input by
310
- # label text "Password" in the following DOM:
353
+ #
354
+ # 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:
311
355
  #
312
356
  # ```html
313
357
  # <label for="password-input">Password:</label>
@@ -317,8 +361,8 @@ module Playwright
317
361
  wrap_impl(@impl.get_by_label(unwrap_impl(text), exact: unwrap_impl(exact)))
318
362
  end
319
363
 
320
- # Allows locating input elements by the placeholder text. For example, this method will find the input by placeholder
321
- # "Country":
364
+ #
365
+ # Allows locating input elements by the placeholder text. For example, this method will find the input by placeholder "Country":
322
366
  #
323
367
  # ```html
324
368
  # <input placeholder="Country">
@@ -327,15 +371,10 @@ module Playwright
327
371
  wrap_impl(@impl.get_by_placeholder(unwrap_impl(text), exact: unwrap_impl(exact)))
328
372
  end
329
373
 
330
- # Allows locating elements by their [ARIA role](https://www.w3.org/TR/wai-aria-1.2/#roles),
331
- # [ARIA attributes](https://www.w3.org/TR/wai-aria-1.2/#aria-attributes) and
332
- # [accessible name](https://w3c.github.io/accname/#dfn-accessible-name). Note that role selector **does not replace**
333
- # accessibility audits and conformance tests, but rather gives early feedback about the ARIA guidelines.
334
374
  #
335
- # Note that many html elements have an implicitly
336
- # [defined role](https://w3c.github.io/html-aam/#html-element-role-mappings) that is recognized by the role selector. You
337
- # can find all the [supported roles here](https://www.w3.org/TR/wai-aria-1.2/#role_definitions). ARIA guidelines **do not
338
- # recommend** duplicating implicit roles and attributes by setting `role` and/or `aria-*` attributes to default values.
375
+ # 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.
376
+ #
377
+ # 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.
339
378
  def get_by_role(
340
379
  role,
341
380
  checked: nil,
@@ -350,12 +389,13 @@ module Playwright
350
389
  wrap_impl(@impl.get_by_role(unwrap_impl(role), checked: unwrap_impl(checked), disabled: unwrap_impl(disabled), exact: unwrap_impl(exact), expanded: unwrap_impl(expanded), includeHidden: unwrap_impl(includeHidden), level: unwrap_impl(level), name: unwrap_impl(name), pressed: unwrap_impl(pressed), selected: unwrap_impl(selected)))
351
390
  end
352
391
 
353
- # Locate element by the test id. By default, the `data-testid` attribute is used as a test id. Use
354
- # [`method: Selectors.setTestIdAttribute`] to configure a different test id attribute if necessary.
392
+ #
393
+ # Locate element by the test id. By default, the `data-testid` attribute is used as a test id. Use [`method: Selectors.setTestIdAttribute`] to configure a different test id attribute if necessary.
355
394
  def get_by_test_id(testId)
356
395
  wrap_impl(@impl.get_by_test_id(unwrap_impl(testId)))
357
396
  end
358
397
 
398
+ #
359
399
  # Allows locating elements that contain given text. Consider the following DOM structure:
360
400
  #
361
401
  # ```html
@@ -382,17 +422,16 @@ module Playwright
382
422
  # page.get_by_text(re.compile("^hello$", re.IGNORECASE))
383
423
  # ```
384
424
  #
385
- # See also [`method: Locator.filter`] that allows to match by another criteria, like an accessible role, and then filter
386
- # by the text content.
425
+ # See also [`method: Locator.filter`] that allows to match by another criteria, like an accessible role, and then filter by the text content.
387
426
  #
388
- # > NOTE: Matching by text always normalizes whitespace, even with exact match. For example, it turns multiple spaces into
389
- # one, turns line breaks into spaces and ignores leading and trailing whitespace.
390
- # > NOTE: Input elements of the type `button` and `submit` are matched by their `value` instead of the text content. For
391
- # example, locating by text `"Log in"` matches `<input type=button value="Log in">`.
427
+ # **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.
428
+ #
429
+ # **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">`.
392
430
  def get_by_text(text, exact: nil)
393
431
  wrap_impl(@impl.get_by_text(unwrap_impl(text), exact: unwrap_impl(exact)))
394
432
  end
395
433
 
434
+ #
396
435
  # Allows locating elements by their title. For example, this method will find the button by its title "Place the order":
397
436
  #
398
437
  # ```html
@@ -402,12 +441,13 @@ module Playwright
402
441
  wrap_impl(@impl.get_by_title(unwrap_impl(text), exact: unwrap_impl(exact)))
403
442
  end
404
443
 
405
- # Highlight the corresponding element(s) on the screen. Useful for debugging, don't commit the code that uses
406
- # [`method: Locator.highlight`].
444
+ #
445
+ # Highlight the corresponding element(s) on the screen. Useful for debugging, don't commit the code that uses [`method: Locator.highlight`].
407
446
  def highlight
408
447
  wrap_impl(@impl.highlight)
409
448
  end
410
449
 
450
+ #
411
451
  # This method hovers over the element by performing the following steps:
412
452
  # 1. Wait for [actionability](../actionability.md) checks on the element, unless `force` option is set.
413
453
  # 1. Scroll the element into view if needed.
@@ -416,8 +456,8 @@ module Playwright
416
456
  #
417
457
  # If the element is detached from the DOM at any moment during the action, this method throws.
418
458
  #
419
- # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
420
- # zero timeout disables this.
459
+ # When all steps combined have not finished during the specified `timeout`, this method throws a
460
+ # `TimeoutError`. Passing zero timeout disables this.
421
461
  def hover(
422
462
  force: nil,
423
463
  modifiers: nil,
@@ -428,81 +468,94 @@ module Playwright
428
468
  wrap_impl(@impl.hover(force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
429
469
  end
430
470
 
471
+ #
431
472
  # Returns the `element.innerHTML`.
432
473
  def inner_html(timeout: nil)
433
474
  wrap_impl(@impl.inner_html(timeout: unwrap_impl(timeout)))
434
475
  end
435
476
 
477
+ #
436
478
  # Returns the `element.innerText`.
437
479
  def inner_text(timeout: nil)
438
480
  wrap_impl(@impl.inner_text(timeout: unwrap_impl(timeout)))
439
481
  end
440
482
 
483
+ #
441
484
  # Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element.
442
485
  #
443
- # Throws for non-input elements. However, if the element is inside the `<label>` element that has an associated
444
- # [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), returns the value of the control.
486
+ # Throws for non-input elements. However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), returns the value of the control.
445
487
  def input_value(timeout: nil)
446
488
  wrap_impl(@impl.input_value(timeout: unwrap_impl(timeout)))
447
489
  end
448
490
 
491
+ #
449
492
  # Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
450
493
  def checked?(timeout: nil)
451
494
  wrap_impl(@impl.checked?(timeout: unwrap_impl(timeout)))
452
495
  end
453
496
 
497
+ #
454
498
  # Returns whether the element is disabled, the opposite of [enabled](../actionability.md#enabled).
455
499
  def disabled?(timeout: nil)
456
500
  wrap_impl(@impl.disabled?(timeout: unwrap_impl(timeout)))
457
501
  end
458
502
 
503
+ #
459
504
  # Returns whether the element is [editable](../actionability.md#editable).
460
505
  def editable?(timeout: nil)
461
506
  wrap_impl(@impl.editable?(timeout: unwrap_impl(timeout)))
462
507
  end
463
508
 
509
+ #
464
510
  # Returns whether the element is [enabled](../actionability.md#enabled).
465
511
  def enabled?(timeout: nil)
466
512
  wrap_impl(@impl.enabled?(timeout: unwrap_impl(timeout)))
467
513
  end
468
514
 
515
+ #
469
516
  # Returns whether the element is hidden, the opposite of [visible](../actionability.md#visible).
470
517
  def hidden?(timeout: nil)
471
518
  wrap_impl(@impl.hidden?(timeout: unwrap_impl(timeout)))
472
519
  end
473
520
 
521
+ #
474
522
  # Returns whether the element is [visible](../actionability.md#visible).
475
523
  def visible?(timeout: nil)
476
524
  wrap_impl(@impl.visible?(timeout: unwrap_impl(timeout)))
477
525
  end
478
526
 
527
+ #
479
528
  # Returns locator to the last matching element.
480
529
  def last
481
530
  wrap_impl(@impl.last)
482
531
  end
483
532
 
484
- # The method finds an element matching the specified selector in the locator's subtree. It also accepts filter options,
485
- # similar to [`method: Locator.filter`] method.
533
+ #
534
+ # The method finds an element matching the specified selector in the locator's subtree. It also accepts filter options, similar to [`method: Locator.filter`] method.
486
535
  #
487
536
  # [Learn more about locators](../locators.md).
488
537
  def locator(selector, has: nil, hasText: nil)
489
538
  wrap_impl(@impl.locator(unwrap_impl(selector), has: unwrap_impl(has), hasText: unwrap_impl(hasText)))
490
539
  end
491
540
 
541
+ #
492
542
  # Returns locator to the n-th matching element. It's zero based, `nth(0)` selects the first element.
493
543
  def nth(index)
494
544
  wrap_impl(@impl.nth(unwrap_impl(index)))
495
545
  end
496
546
 
547
+ #
497
548
  # A page this locator belongs to.
498
549
  def page
499
550
  wrap_impl(@impl.page)
500
551
  end
501
552
 
553
+ #
502
554
  # Focuses the element, and then uses [`method: Keyboard.down`] and [`method: Keyboard.up`].
503
555
  #
504
- # `key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)
505
- # value or a single character to generate the text for. A superset of the `key` values can be found
556
+ # `key` can specify the intended
557
+ # [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to
558
+ # generate the text for. A superset of the `key` values can be found
506
559
  # [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
507
560
  #
508
561
  # `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
@@ -512,8 +565,8 @@ module Playwright
512
565
  #
513
566
  # Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
514
567
  #
515
- # If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
516
- # texts.
568
+ # If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different
569
+ # respective texts.
517
570
  #
518
571
  # Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
519
572
  # modifier, modifier is pressed and being held while the subsequent key is being pressed.
@@ -521,9 +574,8 @@ module Playwright
521
574
  wrap_impl(@impl.press(unwrap_impl(key), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
522
575
  end
523
576
 
524
- # This method captures a screenshot of the page, clipped to the size and position of a particular element matching the
525
- # locator. If the element is covered by other elements, it will not be actually visible on the screenshot. If the element
526
- # is a scrollable container, only the currently scrolled content will be visible on the screenshot.
577
+ #
578
+ # This method captures a screenshot of the page, clipped to the size and position of a particular element matching the locator. If the element is covered by other elements, it will not be actually visible on the screenshot. If the element is a scrollable container, only the currently scrolled content will be visible on the screenshot.
527
579
  #
528
580
  # This method waits for the [actionability](../actionability.md) checks, then scrolls element into view before taking a
529
581
  # screenshot. If the element is detached from DOM, the method throws an error.
@@ -542,6 +594,7 @@ module Playwright
542
594
  wrap_impl(@impl.screenshot(animations: unwrap_impl(animations), caret: unwrap_impl(caret), mask: unwrap_impl(mask), omitBackground: unwrap_impl(omitBackground), path: unwrap_impl(path), quality: unwrap_impl(quality), scale: unwrap_impl(scale), timeout: unwrap_impl(timeout), type: unwrap_impl(type)))
543
595
  end
544
596
 
597
+ #
545
598
  # This method waits for [actionability](../actionability.md) checks, then tries to scroll element into view, unless it is
546
599
  # completely visible as defined by
547
600
  # [IntersectionObserver](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API)'s `ratio`.
@@ -549,23 +602,35 @@ module Playwright
549
602
  wrap_impl(@impl.scroll_into_view_if_needed(timeout: unwrap_impl(timeout)))
550
603
  end
551
604
 
552
- # This method waits for [actionability](../actionability.md) checks, waits until all specified options are present in the
553
- # `<select>` element and selects these options.
554
605
  #
555
- # If the target element is not a `<select>` element, this method throws an error. However, if the element is inside the
556
- # `<label>` element that has an associated
557
- # [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used instead.
606
+ # Selects option or options in `<select>`.
607
+ #
608
+ # **Details**
609
+ #
610
+ # This method waits for [actionability](../actionability.md) checks, waits until all specified options are present in the `<select>` element and selects these options.
611
+ #
612
+ # If the target element is not a `<select>` element, this method throws an error. However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used instead.
558
613
  #
559
614
  # Returns the array of option values that have been successfully selected.
560
615
  #
561
616
  # Triggers a `change` and `input` event once all the provided options have been selected.
562
617
  #
618
+ # **Usage**
619
+ #
620
+ # ```html
621
+ # <select multiple>
622
+ # <option value="red">Red</div>
623
+ # <option value="green">Green</div>
624
+ # <option value="blue">Blue</div>
625
+ # </select>
626
+ # ```
627
+ #
563
628
  # ```python sync
564
- # # single selection matching the value
629
+ # # single selection matching the value or label
565
630
  # element.select_option("blue")
566
- # # single selection matching both the label
631
+ # # single selection matching the label
567
632
  # element.select_option(label="blue")
568
- # # multiple selection
633
+ # # multiple selection for blue, red and second option
569
634
  # element.select_option(value=["red", "green", "blue"])
570
635
  # ```
571
636
  def select_option(
@@ -579,28 +644,27 @@ module Playwright
579
644
  wrap_impl(@impl.select_option(element: unwrap_impl(element), index: unwrap_impl(index), value: unwrap_impl(value), label: unwrap_impl(label), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
580
645
  end
581
646
 
647
+ #
582
648
  # This method waits for [actionability](../actionability.md) checks, then focuses the element and selects all its text
583
649
  # content.
584
650
  #
585
- # If the element is inside the `<label>` element that has an associated
586
- # [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), focuses and selects text in the
587
- # control instead.
651
+ # If the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), focuses and selects text in the control instead.
588
652
  def select_text(force: nil, timeout: nil)
589
653
  wrap_impl(@impl.select_text(force: unwrap_impl(force), timeout: unwrap_impl(timeout)))
590
654
  end
591
655
 
656
+ #
592
657
  # This method checks or unchecks an element by performing the following steps:
593
658
  # 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws.
594
659
  # 1. If the element already has the right checked state, this method returns immediately.
595
- # 1. Wait for [actionability](../actionability.md) checks on the matched element, unless `force` option is set. If the
596
- # element is detached during the checks, the whole action is retried.
660
+ # 1. Wait for [actionability](../actionability.md) checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
597
661
  # 1. Scroll the element into view if needed.
598
662
  # 1. Use [`property: Page.mouse`] to click in the center of the element.
599
663
  # 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
600
664
  # 1. Ensure that the element is now checked or unchecked. If not, this method throws.
601
665
  #
602
- # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
603
- # zero timeout disables this.
666
+ # When all steps combined have not finished during the specified `timeout`, this method throws a
667
+ # `TimeoutError`. Passing zero timeout disables this.
604
668
  def set_checked(
605
669
  checked,
606
670
  force: nil,
@@ -612,18 +676,18 @@ module Playwright
612
676
  end
613
677
  alias_method :checked=, :set_checked
614
678
 
679
+ #
615
680
  # Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
616
681
  # are resolved relative to the current working directory. For empty array, clears the selected files.
617
682
  #
618
683
  # This method expects `Locator` to point to an
619
- # [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). However, if the element is inside the
620
- # `<label>` element that has an associated
621
- # [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), targets the control instead.
684
+ # [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), targets the control instead.
622
685
  def set_input_files(files, noWaitAfter: nil, timeout: nil)
623
686
  wrap_impl(@impl.set_input_files(unwrap_impl(files), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
624
687
  end
625
688
  alias_method :input_files=, :set_input_files
626
689
 
690
+ #
627
691
  # This method taps the element by performing the following steps:
628
692
  # 1. Wait for [actionability](../actionability.md) checks on the element, unless `force` option is set.
629
693
  # 1. Scroll the element into view if needed.
@@ -632,10 +696,10 @@ module Playwright
632
696
  #
633
697
  # If the element is detached from the DOM at any moment during the action, this method throws.
634
698
  #
635
- # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
636
- # zero timeout disables this.
699
+ # When all steps combined have not finished during the specified `timeout`, this method throws a
700
+ # `TimeoutError`. Passing zero timeout disables this.
637
701
  #
638
- # > NOTE: `element.tap()` requires that the `hasTouch` option of the browser context be set to true.
702
+ # **NOTE**: `element.tap()` requires that the `hasTouch` option of the browser context be set to true.
639
703
  def tap_point(
640
704
  force: nil,
641
705
  modifiers: nil,
@@ -646,15 +710,19 @@ module Playwright
646
710
  wrap_impl(@impl.tap_point(force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
647
711
  end
648
712
 
713
+ #
649
714
  # Returns the `node.textContent`.
650
715
  def text_content(timeout: nil)
651
716
  wrap_impl(@impl.text_content(timeout: unwrap_impl(timeout)))
652
717
  end
653
718
 
719
+ #
654
720
  # Focuses the element, and then sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
655
721
  #
656
722
  # To press a special key, like `Control` or `ArrowDown`, use [`method: Locator.press`].
657
723
  #
724
+ # **Usage**
725
+ #
658
726
  # ```python sync
659
727
  # element.type("hello") # types instantly
660
728
  # element.type("world", delay=100) # types slower, like a user
@@ -671,9 +739,9 @@ module Playwright
671
739
  wrap_impl(@impl.type(unwrap_impl(text), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
672
740
  end
673
741
 
742
+ #
674
743
  # This method checks the element by performing the following steps:
675
- # 1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already
676
- # unchecked, this method returns immediately.
744
+ # 1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already unchecked, this method returns immediately.
677
745
  # 1. Wait for [actionability](../actionability.md) checks on the element, unless `force` option is set.
678
746
  # 1. Scroll the element into view if needed.
679
747
  # 1. Use [`property: Page.mouse`] to click in the center of the element.
@@ -682,8 +750,8 @@ module Playwright
682
750
  #
683
751
  # If the element is detached from the DOM at any moment during the action, this method throws.
684
752
  #
685
- # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
686
- # zero timeout disables this.
753
+ # When all steps combined have not finished during the specified `timeout`, this method throws a
754
+ # `TimeoutError`. Passing zero timeout disables this.
687
755
  def uncheck(
688
756
  force: nil,
689
757
  noWaitAfter: nil,
@@ -693,10 +761,13 @@ module Playwright
693
761
  wrap_impl(@impl.uncheck(force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
694
762
  end
695
763
 
764
+ #
696
765
  # Returns when element specified by locator satisfies the `state` option.
697
766
  #
698
- # If target element already satisfies the condition, the method returns immediately. Otherwise, waits for up to `timeout`
699
- # milliseconds until the condition is met.
767
+ # If target element already satisfies the condition, the method returns immediately. Otherwise, waits for up to
768
+ # `timeout` milliseconds until the condition is met.
769
+ #
770
+ # **Usage**
700
771
  #
701
772
  # ```python sync
702
773
  # order_sent = page.locator("#order-sent")