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
@@ -4,17 +4,37 @@ sidebar_position: 10
4
4
 
5
5
  # Locator
6
6
 
7
- Locators are the central piece of Playwright's auto-waiting and retry-ability. In a nutshell, locators represent a way
8
- to find element(s) on the page at any moment. Locator can be created with the [Page#locator](./page#locator) method.
7
+
8
+ Locators are the central piece of Playwright's auto-waiting and retry-ability. In a nutshell, locators represent
9
+ a way to find element(s) on the page at any moment. Locator can be created with the [Page#locator](./page#locator) method.
9
10
 
10
11
  [Learn more about locators](https://playwright.dev/python/docs/locators).
11
12
 
13
+ ## all
14
+
15
+ ```
16
+ def all
17
+ ```
18
+
19
+
20
+ When locator points to a list of elements, returns array of locators, pointing
21
+ to respective elements.
22
+
23
+ **Usage**
24
+
25
+ ```ruby
26
+ page.get_by_role('listitem').all.each do |li|
27
+ li.click
28
+ end
29
+ ```
30
+
12
31
  ## all_inner_texts
13
32
 
14
33
  ```
15
34
  def all_inner_texts
16
35
  ```
17
36
 
37
+
18
38
  Returns an array of `node.innerText` values for all matching nodes.
19
39
 
20
40
  ## all_text_contents
@@ -23,6 +43,7 @@ Returns an array of `node.innerText` values for all matching nodes.
23
43
  def all_text_contents
24
44
  ```
25
45
 
46
+
26
47
  Returns an array of `node.textContent` values for all matching nodes.
27
48
 
28
49
  ## blur
@@ -31,6 +52,7 @@ Returns an array of `node.textContent` values for all matching nodes.
31
52
  def blur(timeout: nil)
32
53
  ```
33
54
 
55
+
34
56
  Calls [blur](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/blur) on the element.
35
57
 
36
58
  ## bounding_box
@@ -39,6 +61,7 @@ Calls [blur](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/blur)
39
61
  def bounding_box(timeout: nil)
40
62
  ```
41
63
 
64
+
42
65
  This method returns the bounding box of the element, or `null` if the element is not visible. The bounding box is
43
66
  calculated relative to the main frame viewport - which is usually the same as the browser window.
44
67
 
@@ -52,6 +75,8 @@ Elements from child frames return the bounding box relative to the main frame, u
52
75
  Assuming the page is static, it is safe to use bounding box coordinates to perform input. For example, the following
53
76
  snippet should click the center of the element.
54
77
 
78
+ **Usage**
79
+
55
80
  ```ruby
56
81
  box = element.bounding_box
57
82
  page.mouse.click(
@@ -60,8 +85,6 @@ page.mouse.click(
60
85
  )
61
86
  ```
62
87
 
63
-
64
-
65
88
  ## check
66
89
 
67
90
  ```
@@ -73,9 +96,9 @@ def check(
73
96
  trial: nil)
74
97
  ```
75
98
 
99
+
76
100
  This method checks the element by performing the following steps:
77
- 1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already checked,
78
- this method returns immediately.
101
+ 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.
79
102
  1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the element, unless `force` option is set.
80
103
  1. Scroll the element into view if needed.
81
104
  1. Use [Page#mouse](./page#mouse) to click in the center of the element.
@@ -84,8 +107,8 @@ This method checks the element by performing the following steps:
84
107
 
85
108
  If the element is detached from the DOM at any moment during the action, this method throws.
86
109
 
87
- When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
88
- zero timeout disables this.
110
+ When all steps combined have not finished during the specified `timeout`, this method throws a
111
+ `TimeoutError`. Passing zero timeout disables this.
89
112
 
90
113
  ## clear
91
114
 
@@ -93,13 +116,10 @@ zero timeout disables this.
93
116
  def clear(force: nil, noWaitAfter: nil, timeout: nil)
94
117
  ```
95
118
 
96
- This method waits for [actionability](https://playwright.dev/python/docs/actionability) checks, focuses the element, clears it and triggers an
97
- `input` event after clearing.
98
119
 
99
- If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error.
100
- However, if the element is inside the `<label>` element that has an associated
101
- [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be cleared
102
- instead.
120
+ This method waits for [actionability](https://playwright.dev/python/docs/actionability) checks, focuses the element, clears it and triggers an `input` event after clearing.
121
+
122
+ 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.
103
123
 
104
124
  ## click
105
125
 
@@ -116,6 +136,11 @@ def click(
116
136
  trial: nil)
117
137
  ```
118
138
 
139
+
140
+ Click an element.
141
+
142
+ **Details**
143
+
119
144
  This method clicks the element by performing the following steps:
120
145
  1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the element, unless `force` option is set.
121
146
  1. Scroll the element into view if needed.
@@ -124,8 +149,8 @@ This method clicks the element by performing the following steps:
124
149
 
125
150
  If the element is detached from the DOM at any moment during the action, this method throws.
126
151
 
127
- When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
128
- zero timeout disables this.
152
+ When all steps combined have not finished during the specified `timeout`, this method throws a
153
+ `TimeoutError`. Passing zero timeout disables this.
129
154
 
130
155
  ## count
131
156
 
@@ -133,6 +158,7 @@ zero timeout disables this.
133
158
  def count
134
159
  ```
135
160
 
161
+
136
162
  Returns the number of elements matching given selector.
137
163
 
138
164
  ## dblclick
@@ -149,19 +175,19 @@ def dblclick(
149
175
  trial: nil)
150
176
  ```
151
177
 
178
+
152
179
  This method double clicks the element by performing the following steps:
153
180
  1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the element, unless `force` option is set.
154
181
  1. Scroll the element into view if needed.
155
182
  1. Use [Page#mouse](./page#mouse) to double click in the center of the element, or the specified `position`.
156
- 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the
157
- first click of the `dblclick()` triggers a navigation event, this method will throw.
183
+ 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.
158
184
 
159
185
  If the element is detached from the DOM at any moment during the action, this method throws.
160
186
 
161
- When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
162
- zero timeout disables this.
187
+ When all steps combined have not finished during the specified `timeout`, this method throws a
188
+ `TimeoutError`. Passing zero timeout disables this.
163
189
 
164
- > NOTE: `element.dblclick()` dispatches two `click` events and a single `dblclick` event.
190
+ **NOTE**: `element.dblclick()` dispatches two `click` events and a single `dblclick` event.
165
191
 
166
192
  ## dispatch_event
167
193
 
@@ -169,18 +195,23 @@ zero timeout disables this.
169
195
  def dispatch_event(type, eventInit: nil, timeout: nil)
170
196
  ```
171
197
 
172
- The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element,
173
- `click` is dispatched. This is equivalent to calling
198
+
199
+ The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element, `click`
200
+ is dispatched. This is equivalent to calling
174
201
  [element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
175
202
 
203
+ **Usage**
204
+
176
205
  ```ruby
177
206
  element.dispatch_event("click")
178
207
  ```
179
208
 
180
- Under the hood, it creates an instance of an event based on the given `type`, initializes it with `eventInit` properties
181
- and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default.
209
+ Under the hood, it creates an instance of an event based on the given `type`, initializes it with
210
+ `eventInit` properties and dispatches it on the element. Events are `composed`, `cancelable` and bubble by
211
+ default.
182
212
 
183
- Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial properties:
213
+ Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial
214
+ properties:
184
215
  - [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent)
185
216
  - [FocusEvent](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent)
186
217
  - [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent)
@@ -197,8 +228,6 @@ data_transfer = page.evaluate_handle("new DataTransfer()")
197
228
  element.dispatch_event("dragstart", eventInit: { dataTransfer: data_transfer })
198
229
  ```
199
230
 
200
-
201
-
202
231
  ## drag_to
203
232
 
204
233
  ```
@@ -212,8 +241,12 @@ def drag_to(
212
241
  trial: nil)
213
242
  ```
214
243
 
215
- This method drags the locator to another target locator or target position. It will first move to the source element,
216
- perform a `mousedown`, then move to the target element or position and perform a `mouseup`.
244
+
245
+ This method drags the locator to another target locator or target position. It will
246
+ first move to the source element, perform a `mousedown`, then move to the target
247
+ element or position and perform a `mouseup`.
248
+
249
+ **Usage**
217
250
 
218
251
  ```ruby
219
252
  source = page.locator("#source")
@@ -228,16 +261,14 @@ source.drag_to(
228
261
  )
229
262
  ```
230
263
 
231
-
232
-
233
264
  ## element_handle
234
265
 
235
266
  ```
236
267
  def element_handle(timeout: nil)
237
268
  ```
238
269
 
239
- Resolves given locator to the first matching DOM element. If no elements matching the query are visible, waits for them
240
- up to a given timeout. If multiple elements match the selector, throws.
270
+
271
+ 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.
241
272
 
242
273
  ## element_handles
243
274
 
@@ -245,6 +276,7 @@ up to a given timeout. If multiple elements match the selector, throws.
245
276
  def element_handles
246
277
  ```
247
278
 
279
+
248
280
  Resolves given locator to all matching DOM elements.
249
281
 
250
282
  ## evaluate
@@ -253,57 +285,56 @@ Resolves given locator to all matching DOM elements.
253
285
  def evaluate(expression, arg: nil, timeout: nil)
254
286
  ```
255
287
 
288
+
256
289
  Returns the return value of `expression`.
257
290
 
258
291
  This method passes this handle as the first argument to `expression`.
259
292
 
260
- If `expression` returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), then `handle.evaluate` would wait for the promise to resolve and return its value.
293
+ If `expression` returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), then `handle.evaluate` would wait for the promise to resolve and return
294
+ its value.
261
295
 
262
- Examples:
296
+ **Usage**
263
297
 
264
298
  ```ruby
265
299
  tweet = page.query_selector(".tweet .retweets")
266
300
  tweet.evaluate("node => node.innerText") # => "10 retweets"
267
301
  ```
268
302
 
269
-
270
-
271
303
  ## evaluate_all
272
304
 
273
305
  ```
274
306
  def evaluate_all(expression, arg: nil)
275
307
  ```
276
308
 
277
- The method finds all elements matching the specified locator and passes an array of matched elements as a first argument
278
- to `expression`. Returns the result of `expression` invocation.
279
309
 
280
- If `expression` returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), then [Locator#evaluate_all](./locator#evaluate_all) would wait for the promise to resolve and
281
- return its value.
310
+ The method finds all elements matching the specified locator and passes an array of matched elements as
311
+ a first argument to `expression`. Returns the result of `expression` invocation.
282
312
 
283
- Examples:
313
+ If `expression` returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), then [Locator#evaluate_all](./locator#evaluate_all) would wait for the promise
314
+ to resolve and return its value.
315
+
316
+ **Usage**
284
317
 
285
318
  ```ruby
286
319
  elements = page.locator("div")
287
- elements.evaluate_all("(divs, min) => divs.length >= min", arg: 10)
320
+ div_counts = elements.evaluate_all("(divs, min) => divs.length >= min", arg: 10)
288
321
  ```
289
322
 
290
-
291
-
292
323
  ## evaluate_handle
293
324
 
294
325
  ```
295
326
  def evaluate_handle(expression, arg: nil, timeout: nil)
296
327
  ```
297
328
 
329
+
298
330
  Returns the return value of `expression` as a [JSHandle](./js_handle).
299
331
 
300
332
  This method passes this handle as the first argument to `expression`.
301
333
 
302
- The only difference between [Locator#evaluate](./locator#evaluate) and [Locator#evaluate_handle](./locator#evaluate_handle) is that
303
- [Locator#evaluate_handle](./locator#evaluate_handle) returns [JSHandle](./js_handle).
334
+ The only difference between [Locator#evaluate](./locator#evaluate) and [Locator#evaluate_handle](./locator#evaluate_handle) is that [Locator#evaluate_handle](./locator#evaluate_handle) returns [JSHandle](./js_handle).
304
335
 
305
- If the function passed to the [Locator#evaluate_handle](./locator#evaluate_handle) returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), then
306
- [Locator#evaluate_handle](./locator#evaluate_handle) would wait for the promise to resolve and return its value.
336
+ If the function passed to the [Locator#evaluate_handle](./locator#evaluate_handle) returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), then [Locator#evaluate_handle](./locator#evaluate_handle) would wait
337
+ for the promise to resolve and return its value.
307
338
 
308
339
  See [Page#evaluate_handle](./page#evaluate_handle) for more details.
309
340
 
@@ -313,13 +344,10 @@ See [Page#evaluate_handle](./page#evaluate_handle) for more details.
313
344
  def fill(value, force: nil, noWaitAfter: nil, timeout: nil)
314
345
  ```
315
346
 
316
- This method waits for [actionability](https://playwright.dev/python/docs/actionability) checks, focuses the element, fills it and triggers an `input`
317
- event after filling. Note that you can pass an empty string to clear the input field.
318
347
 
319
- If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error.
320
- However, if the element is inside the `<label>` element that has an associated
321
- [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled
322
- instead.
348
+ This method waits for [actionability](https://playwright.dev/python/docs/actionability) 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.
349
+
350
+ 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.
323
351
 
324
352
  To send fine-grained keyboard events, use [Locator#type](./locator#type).
325
353
 
@@ -329,8 +357,11 @@ To send fine-grained keyboard events, use [Locator#type](./locator#type).
329
357
  def filter(has: nil, hasText: nil)
330
358
  ```
331
359
 
332
- This method narrows existing locator according to the options, for example filters by text. It can be chained to filter
333
- multiple times.
360
+
361
+ This method narrows existing locator according to the options, for example filters by text.
362
+ It can be chained to filter multiple times.
363
+
364
+ **Usage**
334
365
 
335
366
  ```ruby
336
367
  row_locator = page.locator("tr")
@@ -341,14 +372,13 @@ row_locator.
341
372
  screenshot
342
373
  ```
343
374
 
344
-
345
-
346
375
  ## first
347
376
 
348
377
  ```
349
378
  def first
350
379
  ```
351
380
 
381
+
352
382
  Returns locator to the first matching element.
353
383
 
354
384
  ## focus
@@ -357,6 +387,7 @@ Returns locator to the first matching element.
357
387
  def focus(timeout: nil)
358
388
  ```
359
389
 
390
+
360
391
  Calls [focus](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the element.
361
392
 
362
393
  ## frame_locator
@@ -365,16 +396,17 @@ Calls [focus](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus
365
396
  def frame_locator(selector)
366
397
  ```
367
398
 
368
- When working with iframes, you can create a frame locator that will enter the iframe and allow selecting elements in
369
- that iframe:
399
+
400
+ **Usage**
401
+
402
+ When working with iframes, you can create a frame locator that will enter the iframe and allow selecting elements
403
+ in that iframe:
370
404
 
371
405
  ```ruby
372
406
  locator = page.frame_locator("iframe").get_by_text("Submit")
373
407
  locator.click
374
408
  ```
375
409
 
376
-
377
-
378
410
  ## get_attribute
379
411
 
380
412
  ```
@@ -382,6 +414,7 @@ def get_attribute(name, timeout: nil)
382
414
  ```
383
415
  alias: `[]`
384
416
 
417
+
385
418
  Returns element attribute value.
386
419
 
387
420
  ## get_by_alt_text
@@ -390,42 +423,40 @@ Returns element attribute value.
390
423
  def get_by_alt_text(text, exact: nil)
391
424
  ```
392
425
 
426
+
393
427
  Allows locating elements by their alt text. For example, this method will find the image by alt text "Castle":
394
428
 
395
429
  ```html
396
430
  <img alt='Castle'>
397
431
  ```
398
432
 
399
-
400
433
  ## get_by_label
401
434
 
402
435
  ```
403
436
  def get_by_label(text, exact: nil)
404
437
  ```
405
438
 
406
- Allows locating input elements by the text of the associated label. For example, this method will find the input by
407
- label text "Password" in the following DOM:
439
+
440
+ 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:
408
441
 
409
442
  ```html
410
443
  <label for="password-input">Password:</label>
411
444
  <input id="password-input">
412
445
  ```
413
446
 
414
-
415
447
  ## get_by_placeholder
416
448
 
417
449
  ```
418
450
  def get_by_placeholder(text, exact: nil)
419
451
  ```
420
452
 
421
- Allows locating input elements by the placeholder text. For example, this method will find the input by placeholder
422
- "Country":
453
+
454
+ Allows locating input elements by the placeholder text. For example, this method will find the input by placeholder "Country":
423
455
 
424
456
  ```html
425
457
  <input placeholder="Country">
426
458
  ```
427
459
 
428
-
429
460
  ## get_by_role
430
461
 
431
462
  ```
@@ -442,15 +473,10 @@ def get_by_role(
442
473
  selected: nil)
443
474
  ```
444
475
 
445
- Allows locating elements by their [ARIA role](https://www.w3.org/TR/wai-aria-1.2/#roles),
446
- [ARIA attributes](https://www.w3.org/TR/wai-aria-1.2/#aria-attributes) and
447
- [accessible name](https://w3c.github.io/accname/#dfn-accessible-name). Note that role selector **does not replace**
448
- accessibility audits and conformance tests, but rather gives early feedback about the ARIA guidelines.
449
476
 
450
- Note that many html elements have an implicitly
451
- [defined role](https://w3c.github.io/html-aam/#html-element-role-mappings) that is recognized by the role selector. You
452
- can find all the [supported roles here](https://www.w3.org/TR/wai-aria-1.2/#role_definitions). ARIA guidelines **do not
453
- recommend** duplicating implicit roles and attributes by setting `role` and/or `aria-*` attributes to default values.
477
+ 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.
478
+
479
+ 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.
454
480
 
455
481
  ## get_by_test_id
456
482
 
@@ -458,10 +484,8 @@ recommend** duplicating implicit roles and attributes by setting `role` and/or `
458
484
  def get_by_test_id(testId)
459
485
  ```
460
486
 
461
- Locate element by the test id. By default, the `data-testid` attribute is used as a test id. Use
462
- [Selectors#set_test_id_attribute](./selectors#set_test_id_attribute) to configure a different test id attribute if necessary.
463
-
464
487
 
488
+ Locate element by the test id. By default, the `data-testid` attribute is used as a test id. Use [Selectors#set_test_id_attribute](./selectors#set_test_id_attribute) to configure a different test id attribute if necessary.
465
489
 
466
490
  ## get_by_text
467
491
 
@@ -469,6 +493,7 @@ Locate element by the test id. By default, the `data-testid` attribute is used a
469
493
  def get_by_text(text, exact: nil)
470
494
  ```
471
495
 
496
+
472
497
  Allows locating elements that contain given text. Consider the following DOM structure:
473
498
 
474
499
  ```html
@@ -507,13 +532,11 @@ locator = page.get_by_text(/^hello$/i)
507
532
  expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
508
533
  ```
509
534
 
510
- See also [Locator#filter](./locator#filter) that allows to match by another criteria, like an accessible role, and then filter
511
- by the text content.
535
+ See also [Locator#filter](./locator#filter) that allows to match by another criteria, like an accessible role, and then filter by the text content.
512
536
 
513
- > NOTE: Matching by text always normalizes whitespace, even with exact match. For example, it turns multiple spaces into
514
- one, turns line breaks into spaces and ignores leading and trailing whitespace.
515
- > NOTE: Input elements of the type `button` and `submit` are matched by their `value` instead of the text content. For
516
- example, locating by text `"Log in"` matches `<input type=button value="Log in">`.
537
+ **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.
538
+
539
+ **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">`.
517
540
 
518
541
  ## get_by_title
519
542
 
@@ -521,21 +544,21 @@ example, locating by text `"Log in"` matches `<input type=button value="Log in">
521
544
  def get_by_title(text, exact: nil)
522
545
  ```
523
546
 
547
+
524
548
  Allows locating elements by their title. For example, this method will find the button by its title "Place the order":
525
549
 
526
550
  ```html
527
551
  <button title='Place the order'>Order Now</button>
528
552
  ```
529
553
 
530
-
531
554
  ## highlight
532
555
 
533
556
  ```
534
557
  def highlight
535
558
  ```
536
559
 
537
- Highlight the corresponding element(s) on the screen. Useful for debugging, don't commit the code that uses
538
- [Locator#highlight](./locator#highlight).
560
+
561
+ Highlight the corresponding element(s) on the screen. Useful for debugging, don't commit the code that uses [Locator#highlight](./locator#highlight).
539
562
 
540
563
  ## hover
541
564
 
@@ -549,6 +572,7 @@ def hover(
549
572
  trial: nil)
550
573
  ```
551
574
 
575
+
552
576
  This method hovers over the element by performing the following steps:
553
577
  1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the element, unless `force` option is set.
554
578
  1. Scroll the element into view if needed.
@@ -557,8 +581,8 @@ This method hovers over the element by performing the following steps:
557
581
 
558
582
  If the element is detached from the DOM at any moment during the action, this method throws.
559
583
 
560
- When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
561
- zero timeout disables this.
584
+ When all steps combined have not finished during the specified `timeout`, this method throws a
585
+ `TimeoutError`. Passing zero timeout disables this.
562
586
 
563
587
  ## inner_html
564
588
 
@@ -566,6 +590,7 @@ zero timeout disables this.
566
590
  def inner_html(timeout: nil)
567
591
  ```
568
592
 
593
+
569
594
  Returns the `element.innerHTML`.
570
595
 
571
596
  ## inner_text
@@ -574,6 +599,7 @@ Returns the `element.innerHTML`.
574
599
  def inner_text(timeout: nil)
575
600
  ```
576
601
 
602
+
577
603
  Returns the `element.innerText`.
578
604
 
579
605
  ## input_value
@@ -582,10 +608,10 @@ Returns the `element.innerText`.
582
608
  def input_value(timeout: nil)
583
609
  ```
584
610
 
611
+
585
612
  Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element.
586
613
 
587
- Throws for non-input elements. However, if the element is inside the `<label>` element that has an associated
588
- [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), returns the value of the control.
614
+ 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.
589
615
 
590
616
  ## checked?
591
617
 
@@ -593,6 +619,7 @@ Throws for non-input elements. However, if the element is inside the `<label>` e
593
619
  def checked?(timeout: nil)
594
620
  ```
595
621
 
622
+
596
623
  Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
597
624
 
598
625
  ## disabled?
@@ -601,7 +628,8 @@ Returns whether the element is checked. Throws if the element is not a checkbox
601
628
  def disabled?(timeout: nil)
602
629
  ```
603
630
 
604
- Returns whether the element is disabled, the opposite of [enabled](https://playwright.dev/python/docs/actionability).
631
+
632
+ Returns whether the element is disabled, the opposite of [enabled](https://playwright.dev/python/docs/actionability#enabled).
605
633
 
606
634
  ## editable?
607
635
 
@@ -609,7 +637,8 @@ Returns whether the element is disabled, the opposite of [enabled](https://playw
609
637
  def editable?(timeout: nil)
610
638
  ```
611
639
 
612
- Returns whether the element is [editable](https://playwright.dev/python/docs/actionability).
640
+
641
+ Returns whether the element is [editable](https://playwright.dev/python/docs/actionability#editable).
613
642
 
614
643
  ## enabled?
615
644
 
@@ -617,7 +646,8 @@ Returns whether the element is [editable](https://playwright.dev/python/docs/act
617
646
  def enabled?(timeout: nil)
618
647
  ```
619
648
 
620
- Returns whether the element is [enabled](https://playwright.dev/python/docs/actionability).
649
+
650
+ Returns whether the element is [enabled](https://playwright.dev/python/docs/actionability#enabled).
621
651
 
622
652
  ## hidden?
623
653
 
@@ -625,7 +655,8 @@ Returns whether the element is [enabled](https://playwright.dev/python/docs/acti
625
655
  def hidden?(timeout: nil)
626
656
  ```
627
657
 
628
- Returns whether the element is hidden, the opposite of [visible](https://playwright.dev/python/docs/actionability).
658
+
659
+ Returns whether the element is hidden, the opposite of [visible](https://playwright.dev/python/docs/actionability#visible).
629
660
 
630
661
  ## visible?
631
662
 
@@ -633,7 +664,8 @@ Returns whether the element is hidden, the opposite of [visible](https://playwri
633
664
  def visible?(timeout: nil)
634
665
  ```
635
666
 
636
- Returns whether the element is [visible](https://playwright.dev/python/docs/actionability).
667
+
668
+ Returns whether the element is [visible](https://playwright.dev/python/docs/actionability#visible).
637
669
 
638
670
  ## last
639
671
 
@@ -641,6 +673,7 @@ Returns whether the element is [visible](https://playwright.dev/python/docs/acti
641
673
  def last
642
674
  ```
643
675
 
676
+
644
677
  Returns locator to the last matching element.
645
678
 
646
679
  ## locator
@@ -649,8 +682,8 @@ Returns locator to the last matching element.
649
682
  def locator(selector, has: nil, hasText: nil)
650
683
  ```
651
684
 
652
- The method finds an element matching the specified selector in the locator's subtree. It also accepts filter options,
653
- similar to [Locator#filter](./locator#filter) method.
685
+
686
+ The method finds an element matching the specified selector in the locator's subtree. It also accepts filter options, similar to [Locator#filter](./locator#filter) method.
654
687
 
655
688
  [Learn more about locators](https://playwright.dev/python/docs/locators).
656
689
 
@@ -660,6 +693,7 @@ similar to [Locator#filter](./locator#filter) method.
660
693
  def nth(index)
661
694
  ```
662
695
 
696
+
663
697
  Returns locator to the n-th matching element. It's zero based, `nth(0)` selects the first element.
664
698
 
665
699
  ## page
@@ -668,6 +702,7 @@ Returns locator to the n-th matching element. It's zero based, `nth(0)` selects
668
702
  def page
669
703
  ```
670
704
 
705
+
671
706
  A page this locator belongs to.
672
707
 
673
708
  ## press
@@ -676,10 +711,12 @@ A page this locator belongs to.
676
711
  def press(key, delay: nil, noWaitAfter: nil, timeout: nil)
677
712
  ```
678
713
 
714
+
679
715
  Focuses the element, and then uses [Keyboard#down](./keyboard#down) and [Keyboard#up](./keyboard#up).
680
716
 
681
- `key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)
682
- value or a single character to generate the text for. A superset of the `key` values can be found
717
+ `key` can specify the intended
718
+ [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to
719
+ generate the text for. A superset of the `key` values can be found
683
720
  [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
684
721
 
685
722
  `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
@@ -689,8 +726,8 @@ Following modification shortcuts are also supported: `Shift`, `Control`, `Alt`,
689
726
 
690
727
  Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
691
728
 
692
- If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
693
- texts.
729
+ If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different
730
+ respective texts.
694
731
 
695
732
  Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
696
733
  modifier, modifier is pressed and being held while the subsequent key is being pressed.
@@ -710,9 +747,8 @@ def screenshot(
710
747
  type: nil)
711
748
  ```
712
749
 
713
- This method captures a screenshot of the page, clipped to the size and position of a particular element matching the
714
- locator. If the element is covered by other elements, it will not be actually visible on the screenshot. If the element
715
- is a scrollable container, only the currently scrolled content will be visible on the screenshot.
750
+
751
+ 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.
716
752
 
717
753
  This method waits for the [actionability](https://playwright.dev/python/docs/actionability) checks, then scrolls element into view before taking a
718
754
  screenshot. If the element is detached from DOM, the method throws an error.
@@ -725,6 +761,7 @@ Returns the buffer with the captured screenshot.
725
761
  def scroll_into_view_if_needed(timeout: nil)
726
762
  ```
727
763
 
764
+
728
765
  This method waits for [actionability](https://playwright.dev/python/docs/actionability) checks, then tries to scroll element into view, unless it is
729
766
  completely visible as defined by
730
767
  [IntersectionObserver](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API)'s `ratio`.
@@ -742,19 +779,31 @@ def select_option(
742
779
  timeout: nil)
743
780
  ```
744
781
 
745
- This method waits for [actionability](https://playwright.dev/python/docs/actionability) checks, waits until all specified options are present in the
746
- `<select>` element and selects these options.
747
782
 
748
- If the target element is not a `<select>` element, this method throws an error. However, if the element is inside the
749
- `<label>` element that has an associated
750
- [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used instead.
783
+ Selects option or options in `<select>`.
784
+
785
+ **Details**
786
+
787
+ This method waits for [actionability](https://playwright.dev/python/docs/actionability) checks, waits until all specified options are present in the `<select>` element and selects these options.
788
+
789
+ 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.
751
790
 
752
791
  Returns the array of option values that have been successfully selected.
753
792
 
754
793
  Triggers a `change` and `input` event once all the provided options have been selected.
755
794
 
795
+ **Usage**
796
+
797
+ ```html
798
+ <select multiple>
799
+ <option value="red">Red</div>
800
+ <option value="green">Green</div>
801
+ <option value="blue">Blue</div>
802
+ </select>
803
+ ```
804
+
756
805
  ```ruby
757
- # single selection matching the value
806
+ # single selection matching the value or label
758
807
  element.select_option(value: "blue")
759
808
  # single selection matching both the label
760
809
  element.select_option(label: "blue")
@@ -762,20 +811,17 @@ element.select_option(label: "blue")
762
811
  element.select_option(value: ["red", "green", "blue"])
763
812
  ```
764
813
 
765
-
766
-
767
814
  ## select_text
768
815
 
769
816
  ```
770
817
  def select_text(force: nil, timeout: nil)
771
818
  ```
772
819
 
820
+
773
821
  This method waits for [actionability](https://playwright.dev/python/docs/actionability) checks, then focuses the element and selects all its text
774
822
  content.
775
823
 
776
- If the element is inside the `<label>` element that has an associated
777
- [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), focuses and selects text in the
778
- control instead.
824
+ 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.
779
825
 
780
826
  ## set_checked
781
827
 
@@ -790,18 +836,18 @@ def set_checked(
790
836
  ```
791
837
  alias: `checked=`
792
838
 
839
+
793
840
  This method checks or unchecks an element by performing the following steps:
794
841
  1. Ensure that matched element is a checkbox or a radio input. If not, this method throws.
795
842
  1. If the element already has the right checked state, this method returns immediately.
796
- 1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the matched element, unless `force` option is set. If the
797
- element is detached during the checks, the whole action is retried.
843
+ 1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
798
844
  1. Scroll the element into view if needed.
799
845
  1. Use [Page#mouse](./page#mouse) to click in the center of the element.
800
846
  1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
801
847
  1. Ensure that the element is now checked or unchecked. If not, this method throws.
802
848
 
803
- When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
804
- zero timeout disables this.
849
+ When all steps combined have not finished during the specified `timeout`, this method throws a
850
+ `TimeoutError`. Passing zero timeout disables this.
805
851
 
806
852
  ## set_input_files
807
853
 
@@ -810,13 +856,12 @@ def set_input_files(files, noWaitAfter: nil, timeout: nil)
810
856
  ```
811
857
  alias: `input_files=`
812
858
 
859
+
813
860
  Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
814
861
  are resolved relative to the current working directory. For empty array, clears the selected files.
815
862
 
816
863
  This method expects [Locator](./locator) to point to an
817
- [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). However, if the element is inside the
818
- `<label>` element that has an associated
819
- [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), targets the control instead.
864
+ [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.
820
865
 
821
866
  ## tap_point
822
867
 
@@ -830,6 +875,7 @@ def tap_point(
830
875
  trial: nil)
831
876
  ```
832
877
 
878
+
833
879
  This method taps the element by performing the following steps:
834
880
  1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the element, unless `force` option is set.
835
881
  1. Scroll the element into view if needed.
@@ -838,10 +884,10 @@ This method taps the element by performing the following steps:
838
884
 
839
885
  If the element is detached from the DOM at any moment during the action, this method throws.
840
886
 
841
- When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
842
- zero timeout disables this.
887
+ When all steps combined have not finished during the specified `timeout`, this method throws a
888
+ `TimeoutError`. Passing zero timeout disables this.
843
889
 
844
- > NOTE: `element.tap()` requires that the `hasTouch` option of the browser context be set to true.
890
+ **NOTE**: `element.tap()` requires that the `hasTouch` option of the browser context be set to true.
845
891
 
846
892
  ## text_content
847
893
 
@@ -849,6 +895,7 @@ zero timeout disables this.
849
895
  def text_content(timeout: nil)
850
896
  ```
851
897
 
898
+
852
899
  Returns the `node.textContent`.
853
900
 
854
901
  ## type
@@ -857,10 +904,13 @@ Returns the `node.textContent`.
857
904
  def type(text, delay: nil, noWaitAfter: nil, timeout: nil)
858
905
  ```
859
906
 
907
+
860
908
  Focuses the element, and then sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
861
909
 
862
910
  To press a special key, like `Control` or `ArrowDown`, use [Locator#press](./locator#press).
863
911
 
912
+ **Usage**
913
+
864
914
  ```ruby
865
915
  element.type("hello") # types instantly
866
916
  element.type("world", delay: 100) # types slower, like a user
@@ -874,8 +924,6 @@ element.type("my password")
874
924
  element.press("Enter")
875
925
  ```
876
926
 
877
-
878
-
879
927
  ## uncheck
880
928
 
881
929
  ```
@@ -887,9 +935,9 @@ def uncheck(
887
935
  trial: nil)
888
936
  ```
889
937
 
938
+
890
939
  This method checks the element by performing the following steps:
891
- 1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already
892
- unchecked, this method returns immediately.
940
+ 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.
893
941
  1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the element, unless `force` option is set.
894
942
  1. Scroll the element into view if needed.
895
943
  1. Use [Page#mouse](./page#mouse) to click in the center of the element.
@@ -898,8 +946,8 @@ This method checks the element by performing the following steps:
898
946
 
899
947
  If the element is detached from the DOM at any moment during the action, this method throws.
900
948
 
901
- When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
902
- zero timeout disables this.
949
+ When all steps combined have not finished during the specified `timeout`, this method throws a
950
+ `TimeoutError`. Passing zero timeout disables this.
903
951
 
904
952
  ## wait_for
905
953
 
@@ -907,14 +955,15 @@ zero timeout disables this.
907
955
  def wait_for(state: nil, timeout: nil)
908
956
  ```
909
957
 
958
+
910
959
  Returns when element specified by locator satisfies the `state` option.
911
960
 
912
- If target element already satisfies the condition, the method returns immediately. Otherwise, waits for up to `timeout`
913
- milliseconds until the condition is met.
961
+ If target element already satisfies the condition, the method returns immediately. Otherwise, waits for up to
962
+ `timeout` milliseconds until the condition is met.
963
+
964
+ **Usage**
914
965
 
915
966
  ```ruby
916
967
  order_sent = page.locator("#order-sent")
917
968
  order_sent.wait_for
918
969
  ```
919
-
920
-