playwright-ruby-client 1.29.1 → 1.30.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/documentation/docs/api/frame.md +99 -14
- data/documentation/docs/api/frame_locator.md +99 -14
- data/documentation/docs/api/locator.md +355 -49
- data/documentation/docs/api/page.md +99 -14
- data/lib/playwright/version.rb +2 -2
- data/lib/playwright_api/frame.rb +101 -14
- data/lib/playwright_api/frame_locator.rb +101 -14
- data/lib/playwright_api/locator.rb +365 -50
- data/lib/playwright_api/page.rb +101 -14
- data/lib/playwright_api/route.rb +1 -1
- metadata +5 -5
@@ -37,6 +37,12 @@ def all_inner_texts
|
|
37
37
|
|
38
38
|
Returns an array of `node.innerText` values for all matching nodes.
|
39
39
|
|
40
|
+
**Usage**
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
texts = page.get_by_role("link").all_inner_texts
|
44
|
+
```
|
45
|
+
|
40
46
|
## all_text_contents
|
41
47
|
|
42
48
|
```
|
@@ -46,6 +52,12 @@ def all_text_contents
|
|
46
52
|
|
47
53
|
Returns an array of `node.textContent` values for all matching nodes.
|
48
54
|
|
55
|
+
**Usage**
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
texts = page.get_by_role("link").all_text_contents
|
59
|
+
```
|
60
|
+
|
49
61
|
## blur
|
50
62
|
|
51
63
|
```
|
@@ -62,9 +74,11 @@ def bounding_box(timeout: nil)
|
|
62
74
|
```
|
63
75
|
|
64
76
|
|
65
|
-
This method returns the bounding box of the element, or `null` if the element is not visible. The bounding box is
|
77
|
+
This method returns the bounding box of the element matching the locator, or `null` if the element is not visible. The bounding box is
|
66
78
|
calculated relative to the main frame viewport - which is usually the same as the browser window.
|
67
79
|
|
80
|
+
**Details**
|
81
|
+
|
68
82
|
Scrolling affects the returned bounding box, similarly to
|
69
83
|
[Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect). That
|
70
84
|
means `x` and/or `y` may be negative.
|
@@ -78,6 +92,7 @@ snippet should click the center of the element.
|
|
78
92
|
**Usage**
|
79
93
|
|
80
94
|
```ruby
|
95
|
+
element = page.get_by_role("button")
|
81
96
|
box = element.bounding_box
|
82
97
|
page.mouse.click(
|
83
98
|
box["x"] + box["width"] / 2,
|
@@ -97,7 +112,11 @@ def check(
|
|
97
112
|
```
|
98
113
|
|
99
114
|
|
100
|
-
|
115
|
+
Ensure that checkbox or radio element is checked.
|
116
|
+
|
117
|
+
**Details**
|
118
|
+
|
119
|
+
Performs the following steps:
|
101
120
|
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.
|
102
121
|
1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the element, unless `force` option is set.
|
103
122
|
1. Scroll the element into view if needed.
|
@@ -110,6 +129,12 @@ If the element is detached from the DOM at any moment during the action, this me
|
|
110
129
|
When all steps combined have not finished during the specified `timeout`, this method throws a
|
111
130
|
`TimeoutError`. Passing zero timeout disables this.
|
112
131
|
|
132
|
+
**Usage**
|
133
|
+
|
134
|
+
```ruby
|
135
|
+
page.get_by_role("checkbox").check
|
136
|
+
```
|
137
|
+
|
113
138
|
## clear
|
114
139
|
|
115
140
|
```
|
@@ -117,10 +142,20 @@ def clear(force: nil, noWaitAfter: nil, timeout: nil)
|
|
117
142
|
```
|
118
143
|
|
119
144
|
|
145
|
+
Clear the input field.
|
146
|
+
|
147
|
+
**Details**
|
148
|
+
|
120
149
|
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
150
|
|
122
151
|
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.
|
123
152
|
|
153
|
+
**Usage**
|
154
|
+
|
155
|
+
```ruby
|
156
|
+
page.get_by_role("textbox").clear
|
157
|
+
```
|
158
|
+
|
124
159
|
## click
|
125
160
|
|
126
161
|
```
|
@@ -152,6 +187,20 @@ If the element is detached from the DOM at any moment during the action, this me
|
|
152
187
|
When all steps combined have not finished during the specified `timeout`, this method throws a
|
153
188
|
`TimeoutError`. Passing zero timeout disables this.
|
154
189
|
|
190
|
+
**Usage**
|
191
|
+
|
192
|
+
Click a button:
|
193
|
+
|
194
|
+
```ruby
|
195
|
+
page.get_by_role("button").click
|
196
|
+
```
|
197
|
+
|
198
|
+
Shift-right-click at a specific position on a canvas:
|
199
|
+
|
200
|
+
```ruby
|
201
|
+
page.locator("canvas").click(button: "right", modifiers: ["Shift"], position: { x: 23, y: 32 })
|
202
|
+
```
|
203
|
+
|
155
204
|
## count
|
156
205
|
|
157
206
|
```
|
@@ -159,7 +208,13 @@ def count
|
|
159
208
|
```
|
160
209
|
|
161
210
|
|
162
|
-
Returns the number of elements matching
|
211
|
+
Returns the number of elements matching the locator.
|
212
|
+
|
213
|
+
**Usage**
|
214
|
+
|
215
|
+
```ruby
|
216
|
+
count = page.get_by_role("listitem").count
|
217
|
+
```
|
163
218
|
|
164
219
|
## dblclick
|
165
220
|
|
@@ -176,6 +231,10 @@ def dblclick(
|
|
176
231
|
```
|
177
232
|
|
178
233
|
|
234
|
+
Double-click an element.
|
235
|
+
|
236
|
+
**Details**
|
237
|
+
|
179
238
|
This method double clicks the element by performing the following steps:
|
180
239
|
1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the element, unless `force` option is set.
|
181
240
|
1. Scroll the element into view if needed.
|
@@ -196,16 +255,20 @@ def dispatch_event(type, eventInit: nil, timeout: nil)
|
|
196
255
|
```
|
197
256
|
|
198
257
|
|
199
|
-
|
200
|
-
is dispatched. This is equivalent to calling
|
201
|
-
[element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
|
258
|
+
Programmaticaly dispatch an event on the matching element.
|
202
259
|
|
203
260
|
**Usage**
|
204
261
|
|
205
262
|
```ruby
|
206
|
-
|
263
|
+
locator.dispatch_event("click")
|
207
264
|
```
|
208
265
|
|
266
|
+
**Details**
|
267
|
+
|
268
|
+
The snippet above dispatches the `click` event on the element. Regardless of the visibility state of the element, `click`
|
269
|
+
is dispatched. This is equivalent to calling
|
270
|
+
[element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
|
271
|
+
|
209
272
|
Under the hood, it creates an instance of an event based on the given `type`, initializes it with
|
210
273
|
`eventInit` properties and dispatches it on the element. Events are `composed`, `cancelable` and bubble by
|
211
274
|
default.
|
@@ -225,7 +288,7 @@ You can also specify [JSHandle](./js_handle) as the property value if you want l
|
|
225
288
|
```ruby
|
226
289
|
# note you can only create data_transfer in chromium and firefox
|
227
290
|
data_transfer = page.evaluate_handle("new DataTransfer()")
|
228
|
-
|
291
|
+
locator.dispatch_event("dragstart", eventInit: { dataTransfer: data_transfer })
|
229
292
|
```
|
230
293
|
|
231
294
|
## drag_to
|
@@ -242,6 +305,10 @@ def drag_to(
|
|
242
305
|
```
|
243
306
|
|
244
307
|
|
308
|
+
Drag the source element towards the target element and drop it.
|
309
|
+
|
310
|
+
**Details**
|
311
|
+
|
245
312
|
This method drags the locator to another target locator or target position. It will
|
246
313
|
first move to the source element, perform a `mousedown`, then move to the target
|
247
314
|
element or position and perform a `mouseup`.
|
@@ -268,7 +335,7 @@ def element_handle(timeout: nil)
|
|
268
335
|
```
|
269
336
|
|
270
337
|
|
271
|
-
Resolves given locator to the first matching DOM element. If no
|
338
|
+
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.
|
272
339
|
|
273
340
|
## element_handles
|
274
341
|
|
@@ -277,7 +344,7 @@ def element_handles
|
|
277
344
|
```
|
278
345
|
|
279
346
|
|
280
|
-
Resolves given locator to all matching DOM elements.
|
347
|
+
Resolves given locator to all matching DOM elements. If there are no matching elements, returns an empty list.
|
281
348
|
|
282
349
|
## evaluate
|
283
350
|
|
@@ -286,12 +353,15 @@ def evaluate(expression, arg: nil, timeout: nil)
|
|
286
353
|
```
|
287
354
|
|
288
355
|
|
289
|
-
|
356
|
+
Execute JavaScript code in the page, taking the matching element as an argument.
|
357
|
+
|
358
|
+
**Details**
|
290
359
|
|
291
|
-
|
360
|
+
Returns the return value of `expression`, called with the matching element as a first argument, and `arg` as a second argument.
|
292
361
|
|
293
|
-
If `expression` returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise),
|
294
|
-
|
362
|
+
If `expression` returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), this method will wait for the promise to resolve and return its value.
|
363
|
+
|
364
|
+
If `expression` throws or rejects, this method throws.
|
295
365
|
|
296
366
|
**Usage**
|
297
367
|
|
@@ -307,17 +377,21 @@ def evaluate_all(expression, arg: nil)
|
|
307
377
|
```
|
308
378
|
|
309
379
|
|
310
|
-
|
311
|
-
|
380
|
+
Execute JavaScript code in the page, taking all matching elements as an argument.
|
381
|
+
|
382
|
+
**Details**
|
312
383
|
|
313
|
-
|
314
|
-
|
384
|
+
Returns the return value of `expression`, called with an array of all matching elements as a first argument, and `arg` as a second argument.
|
385
|
+
|
386
|
+
If `expression` returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), this method will wait for the promise to resolve and return its value.
|
387
|
+
|
388
|
+
If `expression` throws or rejects, this method throws.
|
315
389
|
|
316
390
|
**Usage**
|
317
391
|
|
318
392
|
```ruby
|
319
|
-
|
320
|
-
|
393
|
+
locator = page.locator("div")
|
394
|
+
more_than_ten = locator.evaluate_all("(divs, min) => divs.length >= min", arg: 10)
|
321
395
|
```
|
322
396
|
|
323
397
|
## evaluate_handle
|
@@ -327,14 +401,17 @@ def evaluate_handle(expression, arg: nil, timeout: nil)
|
|
327
401
|
```
|
328
402
|
|
329
403
|
|
330
|
-
|
404
|
+
Execute JavaScript code in the page, taking the matching element as an argument, and return a [JSHandle](./js_handle) with the result.
|
405
|
+
|
406
|
+
**Details**
|
331
407
|
|
332
|
-
|
408
|
+
Returns the return value of `expression` as a[JSHandle](./js_handle), called with the matching element as a first argument, and `arg` as a second argument.
|
333
409
|
|
334
410
|
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).
|
335
411
|
|
336
|
-
If
|
337
|
-
|
412
|
+
If `expression` returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), this method will wait for the promise to resolve and return its value.
|
413
|
+
|
414
|
+
If `expression` throws or rejects, this method throws.
|
338
415
|
|
339
416
|
See [Page#evaluate_handle](./page#evaluate_handle) for more details.
|
340
417
|
|
@@ -345,6 +422,16 @@ def fill(value, force: nil, noWaitAfter: nil, timeout: nil)
|
|
345
422
|
```
|
346
423
|
|
347
424
|
|
425
|
+
Set a value to the input field.
|
426
|
+
|
427
|
+
**Usage**
|
428
|
+
|
429
|
+
```ruby
|
430
|
+
page.get_by_role("textbox").fill("example value")
|
431
|
+
```
|
432
|
+
|
433
|
+
**Details**
|
434
|
+
|
348
435
|
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
436
|
|
350
437
|
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.
|
@@ -388,7 +475,7 @@ def focus(timeout: nil)
|
|
388
475
|
```
|
389
476
|
|
390
477
|
|
391
|
-
Calls [focus](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the element.
|
478
|
+
Calls [focus](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the matching element.
|
392
479
|
|
393
480
|
## frame_locator
|
394
481
|
|
@@ -397,11 +484,11 @@ def frame_locator(selector)
|
|
397
484
|
```
|
398
485
|
|
399
486
|
|
400
|
-
|
401
|
-
|
402
|
-
When working with iframes, you can create a frame locator that will enter the iframe and allow selecting elements
|
487
|
+
When working with iframes, you can create a frame locator that will enter the iframe and allow locating elements
|
403
488
|
in that iframe:
|
404
489
|
|
490
|
+
**Usage**
|
491
|
+
|
405
492
|
```ruby
|
406
493
|
locator = page.frame_locator("iframe").get_by_text("Submit")
|
407
494
|
locator.click
|
@@ -415,7 +502,7 @@ def get_attribute(name, timeout: nil)
|
|
415
502
|
alias: `[]`
|
416
503
|
|
417
504
|
|
418
|
-
Returns element attribute value.
|
505
|
+
Returns the matching element's attribute value.
|
419
506
|
|
420
507
|
## get_by_alt_text
|
421
508
|
|
@@ -424,10 +511,18 @@ def get_by_alt_text(text, exact: nil)
|
|
424
511
|
```
|
425
512
|
|
426
513
|
|
427
|
-
Allows locating elements by their alt text.
|
514
|
+
Allows locating elements by their alt text.
|
515
|
+
|
516
|
+
**Usage**
|
517
|
+
|
518
|
+
For example, this method will find the image by alt text "Playwright logo":
|
428
519
|
|
429
520
|
```html
|
430
|
-
<img alt='
|
521
|
+
<img alt='Playwright logo'>
|
522
|
+
```
|
523
|
+
|
524
|
+
```ruby
|
525
|
+
page.get_by_alt_text("Playwright logo").click
|
431
526
|
```
|
432
527
|
|
433
528
|
## get_by_label
|
@@ -437,13 +532,21 @@ def get_by_label(text, exact: nil)
|
|
437
532
|
```
|
438
533
|
|
439
534
|
|
440
|
-
Allows locating input elements by the text of the associated label.
|
535
|
+
Allows locating input elements by the text of the associated label.
|
536
|
+
|
537
|
+
**Usage**
|
538
|
+
|
539
|
+
For example, this method will find the input by label text "Password" in the following DOM:
|
441
540
|
|
442
541
|
```html
|
443
542
|
<label for="password-input">Password:</label>
|
444
543
|
<input id="password-input">
|
445
544
|
```
|
446
545
|
|
546
|
+
```ruby
|
547
|
+
page.get_by_label("Password").fill("secret")
|
548
|
+
```
|
549
|
+
|
447
550
|
## get_by_placeholder
|
448
551
|
|
449
552
|
```
|
@@ -451,10 +554,20 @@ def get_by_placeholder(text, exact: nil)
|
|
451
554
|
```
|
452
555
|
|
453
556
|
|
454
|
-
Allows locating input elements by the placeholder text.
|
557
|
+
Allows locating input elements by the placeholder text.
|
558
|
+
|
559
|
+
**Usage**
|
560
|
+
|
561
|
+
For example, consider the following DOM structure.
|
455
562
|
|
456
563
|
```html
|
457
|
-
<input placeholder="
|
564
|
+
<input type="email" placeholder="name@example.com" />
|
565
|
+
```
|
566
|
+
|
567
|
+
You can fill the input after locating it by the placeholder text:
|
568
|
+
|
569
|
+
```ruby
|
570
|
+
page.get_by_placeholder("name@example.com").fill("playwright@microsoft.com")
|
458
571
|
```
|
459
572
|
|
460
573
|
## get_by_role
|
@@ -474,9 +587,34 @@ def get_by_role(
|
|
474
587
|
```
|
475
588
|
|
476
589
|
|
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).
|
590
|
+
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).
|
591
|
+
|
592
|
+
**Usage**
|
593
|
+
|
594
|
+
Consider the following DOM structure.
|
595
|
+
|
596
|
+
```html
|
597
|
+
<h3>Sign up</h3>
|
598
|
+
<label>
|
599
|
+
<input type="checkbox" /> Subscribe
|
600
|
+
</label>
|
601
|
+
<br/>
|
602
|
+
<button>Submit</button>
|
603
|
+
```
|
604
|
+
|
605
|
+
You can locate each element by it's implicit role:
|
606
|
+
|
607
|
+
```ruby
|
608
|
+
page.get_by_role("heading", name: "Sign up").visible? # => true
|
609
|
+
page.get_by_role("checkbox", name: "Subscribe").check
|
610
|
+
page.get_by_role("button", name: /submit/i).click
|
611
|
+
```
|
612
|
+
|
613
|
+
**Details**
|
614
|
+
|
615
|
+
Role selector **does not replace** accessibility audits and conformance tests, but rather gives early feedback about the ARIA guidelines.
|
478
616
|
|
479
|
-
|
617
|
+
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.
|
480
618
|
|
481
619
|
## get_by_test_id
|
482
620
|
|
@@ -485,7 +623,25 @@ def get_by_test_id(testId)
|
|
485
623
|
```
|
486
624
|
|
487
625
|
|
488
|
-
Locate element by the test id.
|
626
|
+
Locate element by the test id.
|
627
|
+
|
628
|
+
**Usage**
|
629
|
+
|
630
|
+
Consider the following DOM structure.
|
631
|
+
|
632
|
+
```html
|
633
|
+
<button data-testid="directions">Itinéraire</button>
|
634
|
+
```
|
635
|
+
|
636
|
+
You can locate the element by it's test id:
|
637
|
+
|
638
|
+
```ruby
|
639
|
+
page.get_by_test_id("directions").click
|
640
|
+
```
|
641
|
+
|
642
|
+
**Details**
|
643
|
+
|
644
|
+
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.
|
489
645
|
|
490
646
|
## get_by_text
|
491
647
|
|
@@ -494,7 +650,13 @@ def get_by_text(text, exact: nil)
|
|
494
650
|
```
|
495
651
|
|
496
652
|
|
497
|
-
Allows locating elements that contain given text.
|
653
|
+
Allows locating elements that contain given text.
|
654
|
+
|
655
|
+
See also [Locator#filter](./locator#filter) that allows to match by another criteria, like an accessible role, and then filter by the text content.
|
656
|
+
|
657
|
+
**Usage**
|
658
|
+
|
659
|
+
Consider the following DOM structure:
|
498
660
|
|
499
661
|
```html
|
500
662
|
<div>Hello <span>world</span></div>
|
@@ -532,11 +694,11 @@ locator = page.get_by_text(/^hello$/i)
|
|
532
694
|
expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
|
533
695
|
```
|
534
696
|
|
535
|
-
|
697
|
+
**Details**
|
536
698
|
|
537
|
-
|
699
|
+
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
700
|
|
539
|
-
|
701
|
+
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">`.
|
540
702
|
|
541
703
|
## get_by_title
|
542
704
|
|
@@ -545,10 +707,20 @@ def get_by_title(text, exact: nil)
|
|
545
707
|
```
|
546
708
|
|
547
709
|
|
548
|
-
Allows locating elements by their title.
|
710
|
+
Allows locating elements by their title attribute.
|
711
|
+
|
712
|
+
**Usage**
|
713
|
+
|
714
|
+
Consider the following DOM structure.
|
549
715
|
|
550
716
|
```html
|
551
|
-
<
|
717
|
+
<span title='Issues count'>25 issues</span>
|
718
|
+
```
|
719
|
+
|
720
|
+
You can check the issues count after locating it by the title text:
|
721
|
+
|
722
|
+
```ruby
|
723
|
+
page.get_by_title("Issues count").text_content # => "25 issues"
|
552
724
|
```
|
553
725
|
|
554
726
|
## highlight
|
@@ -573,6 +745,16 @@ def hover(
|
|
573
745
|
```
|
574
746
|
|
575
747
|
|
748
|
+
Hover over the matching element.
|
749
|
+
|
750
|
+
**Usage**
|
751
|
+
|
752
|
+
```ruby
|
753
|
+
page.get_by_role("link").hover
|
754
|
+
```
|
755
|
+
|
756
|
+
**Details**
|
757
|
+
|
576
758
|
This method hovers over the element by performing the following steps:
|
577
759
|
1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the element, unless `force` option is set.
|
578
760
|
1. Scroll the element into view if needed.
|
@@ -591,7 +773,7 @@ def inner_html(timeout: nil)
|
|
591
773
|
```
|
592
774
|
|
593
775
|
|
594
|
-
Returns the `element.innerHTML
|
776
|
+
Returns the [`element.innerHTML`](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML).
|
595
777
|
|
596
778
|
## inner_text
|
597
779
|
|
@@ -600,7 +782,7 @@ def inner_text(timeout: nil)
|
|
600
782
|
```
|
601
783
|
|
602
784
|
|
603
|
-
Returns the `element.innerText
|
785
|
+
Returns the [`element.innerText`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText).
|
604
786
|
|
605
787
|
## input_value
|
606
788
|
|
@@ -609,9 +791,17 @@ def input_value(timeout: nil)
|
|
609
791
|
```
|
610
792
|
|
611
793
|
|
612
|
-
Returns
|
794
|
+
Returns the value for the matching `<input>` or `<textarea>` or `<select>` element.
|
795
|
+
|
796
|
+
**Usage**
|
797
|
+
|
798
|
+
```ruby
|
799
|
+
value = page.get_by_role("textbox").input_value
|
800
|
+
```
|
801
|
+
|
802
|
+
**Details**
|
613
803
|
|
614
|
-
Throws
|
804
|
+
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.
|
615
805
|
|
616
806
|
## checked?
|
617
807
|
|
@@ -622,6 +812,12 @@ def checked?(timeout: nil)
|
|
622
812
|
|
623
813
|
Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
|
624
814
|
|
815
|
+
**Usage**
|
816
|
+
|
817
|
+
```ruby
|
818
|
+
checked = page.get_by_role("checkbox").checked?
|
819
|
+
```
|
820
|
+
|
625
821
|
## disabled?
|
626
822
|
|
627
823
|
```
|
@@ -631,6 +827,12 @@ def disabled?(timeout: nil)
|
|
631
827
|
|
632
828
|
Returns whether the element is disabled, the opposite of [enabled](https://playwright.dev/python/docs/actionability#enabled).
|
633
829
|
|
830
|
+
**Usage**
|
831
|
+
|
832
|
+
```ruby
|
833
|
+
disabled = page.get_by_role("button").disabled?
|
834
|
+
```
|
835
|
+
|
634
836
|
## editable?
|
635
837
|
|
636
838
|
```
|
@@ -640,6 +842,12 @@ def editable?(timeout: nil)
|
|
640
842
|
|
641
843
|
Returns whether the element is [editable](https://playwright.dev/python/docs/actionability#editable).
|
642
844
|
|
845
|
+
**Usage**
|
846
|
+
|
847
|
+
```ruby
|
848
|
+
editable = page.get_by_role("textbox").editable?
|
849
|
+
```
|
850
|
+
|
643
851
|
## enabled?
|
644
852
|
|
645
853
|
```
|
@@ -649,6 +857,12 @@ def enabled?(timeout: nil)
|
|
649
857
|
|
650
858
|
Returns whether the element is [enabled](https://playwright.dev/python/docs/actionability#enabled).
|
651
859
|
|
860
|
+
**Usage**
|
861
|
+
|
862
|
+
```ruby
|
863
|
+
enabled = page.get_by_role("button").enabled?
|
864
|
+
```
|
865
|
+
|
652
866
|
## hidden?
|
653
867
|
|
654
868
|
```
|
@@ -658,6 +872,12 @@ def hidden?(timeout: nil)
|
|
658
872
|
|
659
873
|
Returns whether the element is hidden, the opposite of [visible](https://playwright.dev/python/docs/actionability#visible).
|
660
874
|
|
875
|
+
**Usage**
|
876
|
+
|
877
|
+
```ruby
|
878
|
+
hidden = page.get_by_role("button").hidden?
|
879
|
+
```
|
880
|
+
|
661
881
|
## visible?
|
662
882
|
|
663
883
|
```
|
@@ -667,6 +887,12 @@ def visible?(timeout: nil)
|
|
667
887
|
|
668
888
|
Returns whether the element is [visible](https://playwright.dev/python/docs/actionability#visible).
|
669
889
|
|
890
|
+
**Usage**
|
891
|
+
|
892
|
+
```ruby
|
893
|
+
visible = page.get_by_role("button").visible?
|
894
|
+
```
|
895
|
+
|
670
896
|
## last
|
671
897
|
|
672
898
|
```
|
@@ -676,6 +902,12 @@ def last
|
|
676
902
|
|
677
903
|
Returns locator to the last matching element.
|
678
904
|
|
905
|
+
**Usage**
|
906
|
+
|
907
|
+
```ruby
|
908
|
+
banana = page.get_by_role("listitem").last
|
909
|
+
```
|
910
|
+
|
679
911
|
## locator
|
680
912
|
|
681
913
|
```
|
@@ -696,6 +928,12 @@ def nth(index)
|
|
696
928
|
|
697
929
|
Returns locator to the n-th matching element. It's zero based, `nth(0)` selects the first element.
|
698
930
|
|
931
|
+
**Usage**
|
932
|
+
|
933
|
+
```ruby
|
934
|
+
banana = page.get_by_role("listitem").nth(2)
|
935
|
+
```
|
936
|
+
|
699
937
|
## page
|
700
938
|
|
701
939
|
```
|
@@ -712,6 +950,16 @@ def press(key, delay: nil, noWaitAfter: nil, timeout: nil)
|
|
712
950
|
```
|
713
951
|
|
714
952
|
|
953
|
+
Focuses the mathing element and presses a combintation of the keys.
|
954
|
+
|
955
|
+
**Usage**
|
956
|
+
|
957
|
+
```ruby
|
958
|
+
page.get_by_role("textbox").press("Backspace")
|
959
|
+
```
|
960
|
+
|
961
|
+
**Details**
|
962
|
+
|
715
963
|
Focuses the element, and then uses [Keyboard#down](./keyboard#down) and [Keyboard#up](./keyboard#up).
|
716
964
|
|
717
965
|
`key` can specify the intended
|
@@ -748,6 +996,22 @@ def screenshot(
|
|
748
996
|
```
|
749
997
|
|
750
998
|
|
999
|
+
Take a screenshot of the element matching the locator.
|
1000
|
+
|
1001
|
+
**Usage**
|
1002
|
+
|
1003
|
+
```ruby
|
1004
|
+
page.get_by_role("link").screenshot
|
1005
|
+
```
|
1006
|
+
|
1007
|
+
Disable animations and save screenshot to a file:
|
1008
|
+
|
1009
|
+
```ruby
|
1010
|
+
page.get_by_role("link").screenshot(animations="disabled", path="link.png")
|
1011
|
+
```
|
1012
|
+
|
1013
|
+
**Details**
|
1014
|
+
|
751
1015
|
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.
|
752
1016
|
|
753
1017
|
This method waits for the [actionability](https://playwright.dev/python/docs/actionability) checks, then scrolls element into view before taking a
|
@@ -837,6 +1101,17 @@ def set_checked(
|
|
837
1101
|
alias: `checked=`
|
838
1102
|
|
839
1103
|
|
1104
|
+
Set the state of a checkbox or a radio element.
|
1105
|
+
|
1106
|
+
**Usage**
|
1107
|
+
|
1108
|
+
```ruby
|
1109
|
+
page.get_by_role("checkbox").checked = true
|
1110
|
+
page.get_by_role("checkbox").set_checked(true)
|
1111
|
+
```
|
1112
|
+
|
1113
|
+
**Details**
|
1114
|
+
|
840
1115
|
This method checks or unchecks an element by performing the following steps:
|
841
1116
|
1. Ensure that matched element is a checkbox or a radio input. If not, this method throws.
|
842
1117
|
1. If the element already has the right checked state, this method returns immediately.
|
@@ -857,6 +1132,23 @@ def set_input_files(files, noWaitAfter: nil, timeout: nil)
|
|
857
1132
|
alias: `input_files=`
|
858
1133
|
|
859
1134
|
|
1135
|
+
Upload file or multiple files into `<input type=file>`.
|
1136
|
+
|
1137
|
+
**Usage**
|
1138
|
+
|
1139
|
+
```ruby
|
1140
|
+
# Select one file
|
1141
|
+
page.get_by_label("Upload file").set_input_files('myfile.pdf')
|
1142
|
+
|
1143
|
+
# Select multiple files
|
1144
|
+
page.get_by_label("Upload files").set_input_files(['file1.txt', 'file2.txt'])
|
1145
|
+
|
1146
|
+
# Remove all the selected files
|
1147
|
+
page.get_by_label("Upload file").set_input_files([])
|
1148
|
+
```
|
1149
|
+
|
1150
|
+
**Details**
|
1151
|
+
|
860
1152
|
Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
|
861
1153
|
are resolved relative to the current working directory. For empty array, clears the selected files.
|
862
1154
|
|
@@ -876,6 +1168,10 @@ def tap_point(
|
|
876
1168
|
```
|
877
1169
|
|
878
1170
|
|
1171
|
+
Perform a tap gesture on the element matching the locator.
|
1172
|
+
|
1173
|
+
**Details**
|
1174
|
+
|
879
1175
|
This method taps the element by performing the following steps:
|
880
1176
|
1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the element, unless `force` option is set.
|
881
1177
|
1. Scroll the element into view if needed.
|
@@ -896,7 +1192,7 @@ def text_content(timeout: nil)
|
|
896
1192
|
```
|
897
1193
|
|
898
1194
|
|
899
|
-
Returns the `node.textContent
|
1195
|
+
Returns the [`node.textContent`](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent).
|
900
1196
|
|
901
1197
|
## type
|
902
1198
|
|
@@ -936,7 +1232,17 @@ def uncheck(
|
|
936
1232
|
```
|
937
1233
|
|
938
1234
|
|
939
|
-
|
1235
|
+
Ensure that checkbox or radio element is unchecked.
|
1236
|
+
|
1237
|
+
**Usage**
|
1238
|
+
|
1239
|
+
```ruby
|
1240
|
+
page.get_by_role("checkbox").uncheck
|
1241
|
+
```
|
1242
|
+
|
1243
|
+
**Details**
|
1244
|
+
|
1245
|
+
This method unchecks the element by performing the following steps:
|
940
1246
|
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.
|
941
1247
|
1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the element, unless `force` option is set.
|
942
1248
|
1. Scroll the element into view if needed.
|