playwright-ruby-client 1.29.1 → 1.30.beta1

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,12 +22,24 @@ module Playwright
22
22
 
23
23
  #
24
24
  # Returns an array of `node.innerText` values for all matching nodes.
25
+ #
26
+ # **Usage**
27
+ #
28
+ # ```python sync
29
+ # texts = page.get_by_role("link").all_inner_texts()
30
+ # ```
25
31
  def all_inner_texts
26
32
  wrap_impl(@impl.all_inner_texts)
27
33
  end
28
34
 
29
35
  #
30
36
  # Returns an array of `node.textContent` values for all matching nodes.
37
+ #
38
+ # **Usage**
39
+ #
40
+ # ```python sync
41
+ # texts = page.get_by_role("link").all_text_contents()
42
+ # ```
31
43
  def all_text_contents
32
44
  wrap_impl(@impl.all_text_contents)
33
45
  end
@@ -39,9 +51,11 @@ module Playwright
39
51
  end
40
52
 
41
53
  #
42
- # This method returns the bounding box of the element, or `null` if the element is not visible. The bounding box is
54
+ # This method returns the bounding box of the element matching the locator, or `null` if the element is not visible. The bounding box is
43
55
  # calculated relative to the main frame viewport - which is usually the same as the browser window.
44
56
  #
57
+ # **Details**
58
+ #
45
59
  # Scrolling affects the returned bounding box, similarly to
46
60
  # [Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect). That
47
61
  # means `x` and/or `y` may be negative.
@@ -55,7 +69,7 @@ module Playwright
55
69
  # **Usage**
56
70
  #
57
71
  # ```python sync
58
- # box = element.bounding_box()
72
+ # box = page.get_by_role("button").bounding_box()
59
73
  # page.mouse.click(box["x"] + box["width"] / 2, box["y"] + box["height"] / 2)
60
74
  # ```
61
75
  def bounding_box(timeout: nil)
@@ -63,7 +77,11 @@ module Playwright
63
77
  end
64
78
 
65
79
  #
66
- # This method checks the element by performing the following steps:
80
+ # Ensure that checkbox or radio element is checked.
81
+ #
82
+ # **Details**
83
+ #
84
+ # Performs the following steps:
67
85
  # 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.
68
86
  # 1. Wait for [actionability](../actionability.md) checks on the element, unless `force` option is set.
69
87
  # 1. Scroll the element into view if needed.
@@ -75,6 +93,12 @@ module Playwright
75
93
  #
76
94
  # When all steps combined have not finished during the specified `timeout`, this method throws a
77
95
  # `TimeoutError`. Passing zero timeout disables this.
96
+ #
97
+ # **Usage**
98
+ #
99
+ # ```python sync
100
+ # page.get_by_role("checkbox").check()
101
+ # ```
78
102
  def check(
79
103
  force: nil,
80
104
  noWaitAfter: nil,
@@ -84,10 +108,20 @@ module Playwright
84
108
  wrap_impl(@impl.check(force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
85
109
  end
86
110
 
111
+ #
112
+ # Clear the input field.
113
+ #
114
+ # **Details**
87
115
  #
88
116
  # This method waits for [actionability](../actionability.md) checks, focuses the element, clears it and triggers an `input` event after clearing.
89
117
  #
90
118
  # 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.
119
+ #
120
+ # **Usage**
121
+ #
122
+ # ```python sync
123
+ # page.get_by_role("textbox").clear()
124
+ # ```
91
125
  def clear(force: nil, noWaitAfter: nil, timeout: nil)
92
126
  wrap_impl(@impl.clear(force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
93
127
  end
@@ -107,6 +141,22 @@ module Playwright
107
141
  #
108
142
  # When all steps combined have not finished during the specified `timeout`, this method throws a
109
143
  # `TimeoutError`. Passing zero timeout disables this.
144
+ #
145
+ # **Usage**
146
+ #
147
+ # Click a button:
148
+ #
149
+ # ```python sync
150
+ # page.get_by_role("button").click()
151
+ # ```
152
+ #
153
+ # Shift-right-click at a specific position on a canvas:
154
+ #
155
+ # ```python sync
156
+ # page.locator("canvas").click(
157
+ # button="right", modifiers=["Shift"], position={"x": 23, "y": 32}
158
+ # )
159
+ # ```
110
160
  def click(
111
161
  button: nil,
112
162
  clickCount: nil,
@@ -121,11 +171,21 @@ module Playwright
121
171
  end
122
172
 
123
173
  #
124
- # Returns the number of elements matching given selector.
174
+ # Returns the number of elements matching the locator.
175
+ #
176
+ # **Usage**
177
+ #
178
+ # ```python sync
179
+ # count = page.get_by_role("listitem").count()
180
+ # ```
125
181
  def count
126
182
  wrap_impl(@impl.count)
127
183
  end
128
184
 
185
+ #
186
+ # Double-click an element.
187
+ #
188
+ # **Details**
129
189
  #
130
190
  # This method double clicks the element by performing the following steps:
131
191
  # 1. Wait for [actionability](../actionability.md) checks on the element, unless `force` option is set.
@@ -152,16 +212,20 @@ module Playwright
152
212
  end
153
213
 
154
214
  #
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
157
- # [element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
215
+ # Programmaticaly dispatch an event on the matching element.
158
216
  #
159
217
  # **Usage**
160
218
  #
161
219
  # ```python sync
162
- # element.dispatch_event("click")
220
+ # locator.dispatch_event("click")
163
221
  # ```
164
222
  #
223
+ # **Details**
224
+ #
225
+ # The snippet above dispatches the `click` event on the element. Regardless of the visibility state of the element, `click`
226
+ # is dispatched. This is equivalent to calling
227
+ # [element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
228
+ #
165
229
  # Under the hood, it creates an instance of an event based on the given `type`, initializes it with
166
230
  # `eventInit` properties and dispatches it on the element. Events are `composed`, `cancelable` and bubble by
167
231
  # default.
@@ -181,12 +245,16 @@ module Playwright
181
245
  # ```python sync
182
246
  # # note you can only create data_transfer in chromium and firefox
183
247
  # data_transfer = page.evaluate_handle("new DataTransfer()")
184
- # element.dispatch_event("#source", "dragstart", {"dataTransfer": data_transfer})
248
+ # locator.dispatch_event("#source", "dragstart", {"dataTransfer": data_transfer})
185
249
  # ```
186
250
  def dispatch_event(type, eventInit: nil, timeout: nil)
187
251
  wrap_impl(@impl.dispatch_event(unwrap_impl(type), eventInit: unwrap_impl(eventInit), timeout: unwrap_impl(timeout)))
188
252
  end
189
253
 
254
+ #
255
+ # Drag the source element towards the target element and drop it.
256
+ #
257
+ # **Details**
190
258
  #
191
259
  # This method drags the locator to another target locator or target position. It will
192
260
  # first move to the source element, perform a `mousedown`, then move to the target
@@ -218,24 +286,27 @@ module Playwright
218
286
  end
219
287
 
220
288
  #
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.
289
+ # Resolves given locator to the first matching DOM element. If there are no matching elements, waits for one. If multiple elements match the locator, throws.
222
290
  def element_handle(timeout: nil)
223
291
  wrap_impl(@impl.element_handle(timeout: unwrap_impl(timeout)))
224
292
  end
225
293
 
226
294
  #
227
- # Resolves given locator to all matching DOM elements.
295
+ # Resolves given locator to all matching DOM elements. If there are no matching elements, returns an empty list.
228
296
  def element_handles
229
297
  wrap_impl(@impl.element_handles)
230
298
  end
231
299
 
232
300
  #
233
- # Returns the return value of `expression`.
301
+ # Execute JavaScript code in the page, taking the matching element as an argument.
302
+ #
303
+ # **Details**
234
304
  #
235
- # This method passes this handle as the first argument to `expression`.
305
+ # Returns the return value of `expression`, called with the matching element as a first argument, and `arg` as a second argument.
236
306
  #
237
- # If `expression` returns a [Promise], then `handle.evaluate` would wait for the promise to resolve and return
238
- # its value.
307
+ # If `expression` returns a [Promise], this method will wait for the promise to resolve and return its value.
308
+ #
309
+ # If `expression` throws or rejects, this method throws.
239
310
  #
240
311
  # **Usage**
241
312
  #
@@ -248,37 +319,54 @@ module Playwright
248
319
  end
249
320
 
250
321
  #
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.
322
+ # Execute JavaScript code in the page, taking all matching elements as an argument.
323
+ #
324
+ # **Details**
253
325
  #
254
- # If `expression` returns a [Promise], then [`method: Locator.evaluateAll`] would wait for the promise
255
- # to resolve and return its value.
326
+ # Returns the return value of `expression`, called with an array of all matching elements as a first argument, and `arg` as a second argument.
327
+ #
328
+ # If `expression` returns a [Promise], this method will wait for the promise to resolve and return its value.
329
+ #
330
+ # If `expression` throws or rejects, this method throws.
256
331
  #
257
332
  # **Usage**
258
333
  #
259
334
  # ```python sync
260
- # elements = page.locator("div")
261
- # div_counts = elements.evaluate_all("(divs, min) => divs.length >= min", 10)
335
+ # locator = page.locator("div")
336
+ # more_than_ten = locator.evaluate_all("(divs, min) => divs.length > min", 10)
262
337
  # ```
263
338
  def evaluate_all(expression, arg: nil)
264
339
  wrap_impl(@impl.evaluate_all(unwrap_impl(expression), arg: unwrap_impl(arg)))
265
340
  end
266
341
 
267
342
  #
268
- # Returns the return value of `expression` as a `JSHandle`.
343
+ # Execute JavaScript code in the page, taking the matching element as an argument, and return a `JSHandle` with the result.
344
+ #
345
+ # **Details**
269
346
  #
270
- # This method passes this handle as the first argument to `expression`.
347
+ # Returns the return value of `expression` as a`JSHandle`, called with the matching element as a first argument, and `arg` as a second argument.
271
348
  #
272
349
  # The only difference between [`method: Locator.evaluate`] and [`method: Locator.evaluateHandle`] is that [`method: Locator.evaluateHandle`] returns `JSHandle`.
273
350
  #
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.
351
+ # If `expression` returns a [Promise], this method will wait for the promise to resolve and return its value.
352
+ #
353
+ # If `expression` throws or rejects, this method throws.
276
354
  #
277
355
  # See [`method: Page.evaluateHandle`] for more details.
278
356
  def evaluate_handle(expression, arg: nil, timeout: nil)
279
357
  wrap_impl(@impl.evaluate_handle(unwrap_impl(expression), arg: unwrap_impl(arg), timeout: unwrap_impl(timeout)))
280
358
  end
281
359
 
360
+ #
361
+ # Set a value to the input field.
362
+ #
363
+ # **Usage**
364
+ #
365
+ # ```python sync
366
+ # page.get_by_role("textbox").fill("example value")
367
+ # ```
368
+ #
369
+ # **Details**
282
370
  #
283
371
  # 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
372
  #
@@ -314,17 +402,17 @@ module Playwright
314
402
  end
315
403
 
316
404
  #
317
- # Calls [focus](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the element.
405
+ # Calls [focus](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the matching element.
318
406
  def focus(timeout: nil)
319
407
  wrap_impl(@impl.focus(timeout: unwrap_impl(timeout)))
320
408
  end
321
409
 
322
410
  #
323
- # **Usage**
324
- #
325
- # When working with iframes, you can create a frame locator that will enter the iframe and allow selecting elements
411
+ # When working with iframes, you can create a frame locator that will enter the iframe and allow locating elements
326
412
  # in that iframe:
327
413
  #
414
+ # **Usage**
415
+ #
328
416
  # ```python sync
329
417
  # locator = page.frame_locator("iframe").get_by_text("Submit")
330
418
  # locator.click()
@@ -334,47 +422,100 @@ module Playwright
334
422
  end
335
423
 
336
424
  #
337
- # Returns element attribute value.
425
+ # Returns the matching element's attribute value.
338
426
  def get_attribute(name, timeout: nil)
339
427
  wrap_impl(@impl.get_attribute(unwrap_impl(name), timeout: unwrap_impl(timeout)))
340
428
  end
341
429
  alias_method :[], :get_attribute
342
430
 
343
431
  #
344
- # Allows locating elements by their alt text. For example, this method will find the image by alt text "Castle":
432
+ # Allows locating elements by their alt text.
433
+ #
434
+ # **Usage**
435
+ #
436
+ # For example, this method will find the image by alt text "Playwright logo":
345
437
  #
346
438
  # ```html
347
- # <img alt='Castle'>
439
+ # <img alt='Playwright logo'>
440
+ # ```
441
+ #
442
+ # ```python sync
443
+ # page.get_by_alt_text("Playwright logo").click()
348
444
  # ```
349
445
  def get_by_alt_text(text, exact: nil)
350
446
  wrap_impl(@impl.get_by_alt_text(unwrap_impl(text), exact: unwrap_impl(exact)))
351
447
  end
352
448
 
353
449
  #
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:
450
+ # Allows locating input elements by the text of the associated label.
451
+ #
452
+ # **Usage**
453
+ #
454
+ # For example, this method will find the input by label text "Password" in the following DOM:
355
455
  #
356
456
  # ```html
357
457
  # <label for="password-input">Password:</label>
358
458
  # <input id="password-input">
359
459
  # ```
460
+ #
461
+ # ```python sync
462
+ # page.get_by_label("Password").fill("secret")
463
+ # ```
360
464
  def get_by_label(text, exact: nil)
361
465
  wrap_impl(@impl.get_by_label(unwrap_impl(text), exact: unwrap_impl(exact)))
362
466
  end
363
467
 
364
468
  #
365
- # Allows locating input elements by the placeholder text. For example, this method will find the input by placeholder "Country":
469
+ # Allows locating input elements by the placeholder text.
470
+ #
471
+ # **Usage**
472
+ #
473
+ # For example, consider the following DOM structure.
366
474
  #
367
475
  # ```html
368
- # <input placeholder="Country">
476
+ # <input type="email" placeholder="name@example.com" />
477
+ # ```
478
+ #
479
+ # You can fill the input after locating it by the placeholder text:
480
+ #
481
+ # ```python sync
482
+ # page.get_by_placeholder("name@example.com").fill("playwright@microsoft.com")
369
483
  # ```
370
484
  def get_by_placeholder(text, exact: nil)
371
485
  wrap_impl(@impl.get_by_placeholder(unwrap_impl(text), exact: unwrap_impl(exact)))
372
486
  end
373
487
 
374
488
  #
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.
489
+ # 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).
490
+ #
491
+ # **Usage**
492
+ #
493
+ # Consider the following DOM structure.
494
+ #
495
+ # ```html
496
+ # <h3>Sign up</h3>
497
+ # <label>
498
+ # <input type="checkbox" /> Subscribe
499
+ # </label>
500
+ # <br/>
501
+ # <button>Submit</button>
502
+ # ```
503
+ #
504
+ # You can locate each element by it's implicit role:
505
+ #
506
+ # ```python sync
507
+ # expect(page.get_by_role("heading", name="Sign up")).to_be_visible()
508
+ #
509
+ # page.get_by_role("checkbox", name="Subscribe").check()
376
510
  #
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.
511
+ # page.get_by_role("button", name=re.compile("submit", re.IGNORECASE)).click()
512
+ # ```
513
+ #
514
+ # **Details**
515
+ #
516
+ # Role selector **does not replace** accessibility audits and conformance tests, but rather gives early feedback about the ARIA guidelines.
517
+ #
518
+ # 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.
378
519
  def get_by_role(
379
520
  role,
380
521
  checked: nil,
@@ -390,13 +531,37 @@ module Playwright
390
531
  end
391
532
 
392
533
  #
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.
534
+ # Locate element by the test id.
535
+ #
536
+ # **Usage**
537
+ #
538
+ # Consider the following DOM structure.
539
+ #
540
+ # ```html
541
+ # <button data-testid="directions">Itinéraire</button>
542
+ # ```
543
+ #
544
+ # You can locate the element by it's test id:
545
+ #
546
+ # ```python sync
547
+ # page.get_by_test_id("directions").click()
548
+ # ```
549
+ #
550
+ # **Details**
551
+ #
552
+ # 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.
394
553
  def get_by_test_id(testId)
395
554
  wrap_impl(@impl.get_by_test_id(unwrap_impl(testId)))
396
555
  end
397
556
 
398
557
  #
399
- # Allows locating elements that contain given text. Consider the following DOM structure:
558
+ # Allows locating elements that contain given text.
559
+ #
560
+ # See also [`method: Locator.filter`] that allows to match by another criteria, like an accessible role, and then filter by the text content.
561
+ #
562
+ # **Usage**
563
+ #
564
+ # Consider the following DOM structure:
400
565
  #
401
566
  # ```html
402
567
  # <div>Hello <span>world</span></div>
@@ -422,20 +587,30 @@ module Playwright
422
587
  # page.get_by_text(re.compile("^hello$", re.IGNORECASE))
423
588
  # ```
424
589
  #
425
- # See also [`method: Locator.filter`] that allows to match by another criteria, like an accessible role, and then filter by the text content.
590
+ # **Details**
426
591
  #
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.
592
+ # 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
593
  #
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">`.
594
+ # 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">`.
430
595
  def get_by_text(text, exact: nil)
431
596
  wrap_impl(@impl.get_by_text(unwrap_impl(text), exact: unwrap_impl(exact)))
432
597
  end
433
598
 
434
599
  #
435
- # Allows locating elements by their title. For example, this method will find the button by its title "Place the order":
600
+ # Allows locating elements by their title attribute.
601
+ #
602
+ # **Usage**
603
+ #
604
+ # Consider the following DOM structure.
436
605
  #
437
606
  # ```html
438
- # <button title='Place the order'>Order Now</button>
607
+ # <span title='Issues count'>25 issues</span>
608
+ # ```
609
+ #
610
+ # You can check the issues count after locating it by the title text:
611
+ #
612
+ # ```python sync
613
+ # expect(page.get_by_title("Issues count")).to_have_text("25 issues")
439
614
  # ```
440
615
  def get_by_title(text, exact: nil)
441
616
  wrap_impl(@impl.get_by_title(unwrap_impl(text), exact: unwrap_impl(exact)))
@@ -447,6 +622,16 @@ module Playwright
447
622
  wrap_impl(@impl.highlight)
448
623
  end
449
624
 
625
+ #
626
+ # Hover over the matching element.
627
+ #
628
+ # **Usage**
629
+ #
630
+ # ```python sync
631
+ # page.get_by_role("link").hover()
632
+ # ```
633
+ #
634
+ # **Details**
450
635
  #
451
636
  # This method hovers over the element by performing the following steps:
452
637
  # 1. Wait for [actionability](../actionability.md) checks on the element, unless `force` option is set.
@@ -469,63 +654,113 @@ module Playwright
469
654
  end
470
655
 
471
656
  #
472
- # Returns the `element.innerHTML`.
657
+ # Returns the [`element.innerHTML`](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML).
473
658
  def inner_html(timeout: nil)
474
659
  wrap_impl(@impl.inner_html(timeout: unwrap_impl(timeout)))
475
660
  end
476
661
 
477
662
  #
478
- # Returns the `element.innerText`.
663
+ # Returns the [`element.innerText`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText).
479
664
  def inner_text(timeout: nil)
480
665
  wrap_impl(@impl.inner_text(timeout: unwrap_impl(timeout)))
481
666
  end
482
667
 
483
668
  #
484
- # Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element.
669
+ # Returns the value for the matching `<input>` or `<textarea>` or `<select>` element.
670
+ #
671
+ # **Usage**
672
+ #
673
+ # ```python sync
674
+ # value = page.get_by_role("textbox").input_value()
675
+ # ```
676
+ #
677
+ # **Details**
485
678
  #
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.
679
+ # Throws elements that are not an input, textarea or a select. 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.
487
680
  def input_value(timeout: nil)
488
681
  wrap_impl(@impl.input_value(timeout: unwrap_impl(timeout)))
489
682
  end
490
683
 
491
684
  #
492
685
  # Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
686
+ #
687
+ # **Usage**
688
+ #
689
+ # ```python sync
690
+ # checked = page.get_by_role("checkbox").is_checked()
691
+ # ```
493
692
  def checked?(timeout: nil)
494
693
  wrap_impl(@impl.checked?(timeout: unwrap_impl(timeout)))
495
694
  end
496
695
 
497
696
  #
498
697
  # Returns whether the element is disabled, the opposite of [enabled](../actionability.md#enabled).
698
+ #
699
+ # **Usage**
700
+ #
701
+ # ```python sync
702
+ # disabled = page.get_by_role("button").is_disabled()
703
+ # ```
499
704
  def disabled?(timeout: nil)
500
705
  wrap_impl(@impl.disabled?(timeout: unwrap_impl(timeout)))
501
706
  end
502
707
 
503
708
  #
504
709
  # Returns whether the element is [editable](../actionability.md#editable).
710
+ #
711
+ # **Usage**
712
+ #
713
+ # ```python sync
714
+ # editable = page.get_by_role("textbox").is_editable()
715
+ # ```
505
716
  def editable?(timeout: nil)
506
717
  wrap_impl(@impl.editable?(timeout: unwrap_impl(timeout)))
507
718
  end
508
719
 
509
720
  #
510
721
  # Returns whether the element is [enabled](../actionability.md#enabled).
722
+ #
723
+ # **Usage**
724
+ #
725
+ # ```python sync
726
+ # enabled = page.get_by_role("button").is_enabled()
727
+ # ```
511
728
  def enabled?(timeout: nil)
512
729
  wrap_impl(@impl.enabled?(timeout: unwrap_impl(timeout)))
513
730
  end
514
731
 
515
732
  #
516
733
  # Returns whether the element is hidden, the opposite of [visible](../actionability.md#visible).
734
+ #
735
+ # **Usage**
736
+ #
737
+ # ```python sync
738
+ # hidden = page.get_by_role("button").is_hidden()
739
+ # ```
517
740
  def hidden?(timeout: nil)
518
741
  wrap_impl(@impl.hidden?(timeout: unwrap_impl(timeout)))
519
742
  end
520
743
 
521
744
  #
522
745
  # Returns whether the element is [visible](../actionability.md#visible).
746
+ #
747
+ # **Usage**
748
+ #
749
+ # ```python sync
750
+ # visible = page.get_by_role("button").is_visible()
751
+ # ```
523
752
  def visible?(timeout: nil)
524
753
  wrap_impl(@impl.visible?(timeout: unwrap_impl(timeout)))
525
754
  end
526
755
 
527
756
  #
528
757
  # Returns locator to the last matching element.
758
+ #
759
+ # **Usage**
760
+ #
761
+ # ```python sync
762
+ # banana = page.get_by_role("listitem").last()
763
+ # ```
529
764
  def last
530
765
  wrap_impl(@impl.last)
531
766
  end
@@ -540,6 +775,12 @@ module Playwright
540
775
 
541
776
  #
542
777
  # Returns locator to the n-th matching element. It's zero based, `nth(0)` selects the first element.
778
+ #
779
+ # **Usage**
780
+ #
781
+ # ```python sync
782
+ # banana = page.get_by_role("listitem").nth(2)
783
+ # ```
543
784
  def nth(index)
544
785
  wrap_impl(@impl.nth(unwrap_impl(index)))
545
786
  end
@@ -550,6 +791,16 @@ module Playwright
550
791
  wrap_impl(@impl.page)
551
792
  end
552
793
 
794
+ #
795
+ # Focuses the mathing element and presses a combintation of the keys.
796
+ #
797
+ # **Usage**
798
+ #
799
+ # ```python sync
800
+ # page.get_by_role("textbox").press("Backspace")
801
+ # ```
802
+ #
803
+ # **Details**
553
804
  #
554
805
  # Focuses the element, and then uses [`method: Keyboard.down`] and [`method: Keyboard.up`].
555
806
  #
@@ -574,6 +825,22 @@ module Playwright
574
825
  wrap_impl(@impl.press(unwrap_impl(key), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
575
826
  end
576
827
 
828
+ #
829
+ # Take a screenshot of the element matching the locator.
830
+ #
831
+ # **Usage**
832
+ #
833
+ # ```python sync
834
+ # page.get_by_role("link").screenshot()
835
+ # ```
836
+ #
837
+ # Disable animations and save screenshot to a file:
838
+ #
839
+ # ```python sync
840
+ # page.get_by_role("link").screenshot(animations="disabled", path="link.png")
841
+ # ```
842
+ #
843
+ # **Details**
577
844
  #
578
845
  # 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.
579
846
  #
@@ -653,6 +920,16 @@ module Playwright
653
920
  wrap_impl(@impl.select_text(force: unwrap_impl(force), timeout: unwrap_impl(timeout)))
654
921
  end
655
922
 
923
+ #
924
+ # Set the state of a checkbox or a radio element.
925
+ #
926
+ # **Usage**
927
+ #
928
+ # ```python sync
929
+ # page.get_by_role("checkbox").set_checked(True)
930
+ # ```
931
+ #
932
+ # **Details**
656
933
  #
657
934
  # This method checks or unchecks an element by performing the following steps:
658
935
  # 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws.
@@ -676,6 +953,30 @@ module Playwright
676
953
  end
677
954
  alias_method :checked=, :set_checked
678
955
 
956
+ #
957
+ # Upload file or multiple files into `<input type=file>`.
958
+ #
959
+ # **Usage**
960
+ #
961
+ # ```python sync
962
+ # # Select one file
963
+ # page.get_by_label("Upload file").set_input_files('myfile.pdf')
964
+ #
965
+ # # Select multiple files
966
+ # page.get_by_label("Upload files").set_input_files(['file1.txt', 'file2.txt'])
967
+ #
968
+ # # Remove all the selected files
969
+ # page.get_by_label("Upload file").set_input_files([])
970
+ #
971
+ # # Upload buffer from memory
972
+ # page.get_by_label("Upload file").set_input_files(
973
+ # files=[
974
+ # {"name": "test.txt", "mimeType": "text/plain", "buffer": b"this is a test"}
975
+ # ],
976
+ # )
977
+ # ```
978
+ #
979
+ # **Details**
679
980
  #
680
981
  # Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
681
982
  # are resolved relative to the current working directory. For empty array, clears the selected files.
@@ -687,6 +988,10 @@ module Playwright
687
988
  end
688
989
  alias_method :input_files=, :set_input_files
689
990
 
991
+ #
992
+ # Perform a tap gesture on the element matching the locator.
993
+ #
994
+ # **Details**
690
995
  #
691
996
  # This method taps the element by performing the following steps:
692
997
  # 1. Wait for [actionability](../actionability.md) checks on the element, unless `force` option is set.
@@ -711,7 +1016,7 @@ module Playwright
711
1016
  end
712
1017
 
713
1018
  #
714
- # Returns the `node.textContent`.
1019
+ # Returns the [`node.textContent`](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent).
715
1020
  def text_content(timeout: nil)
716
1021
  wrap_impl(@impl.text_content(timeout: unwrap_impl(timeout)))
717
1022
  end
@@ -740,7 +1045,17 @@ module Playwright
740
1045
  end
741
1046
 
742
1047
  #
743
- # This method checks the element by performing the following steps:
1048
+ # Ensure that checkbox or radio element is unchecked.
1049
+ #
1050
+ # **Usage**
1051
+ #
1052
+ # ```python sync
1053
+ # page.get_by_role("checkbox").uncheck()
1054
+ # ```
1055
+ #
1056
+ # **Details**
1057
+ #
1058
+ # This method unchecks the element by performing the following steps:
744
1059
  # 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.
745
1060
  # 1. Wait for [actionability](../actionability.md) checks on the element, unless `force` option is set.
746
1061
  # 1. Scroll the element into view if needed.