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
@@ -630,10 +630,18 @@ def get_by_alt_text(text, exact: nil)
|
|
630
630
|
```
|
631
631
|
|
632
632
|
|
633
|
-
Allows locating elements by their alt text.
|
633
|
+
Allows locating elements by their alt text.
|
634
|
+
|
635
|
+
**Usage**
|
636
|
+
|
637
|
+
For example, this method will find the image by alt text "Playwright logo":
|
634
638
|
|
635
639
|
```html
|
636
|
-
<img alt='
|
640
|
+
<img alt='Playwright logo'>
|
641
|
+
```
|
642
|
+
|
643
|
+
```ruby
|
644
|
+
page.get_by_alt_text("Playwright logo").click
|
637
645
|
```
|
638
646
|
|
639
647
|
## get_by_label
|
@@ -643,13 +651,21 @@ def get_by_label(text, exact: nil)
|
|
643
651
|
```
|
644
652
|
|
645
653
|
|
646
|
-
Allows locating input elements by the text of the associated label.
|
654
|
+
Allows locating input elements by the text of the associated label.
|
655
|
+
|
656
|
+
**Usage**
|
657
|
+
|
658
|
+
For example, this method will find the input by label text "Password" in the following DOM:
|
647
659
|
|
648
660
|
```html
|
649
661
|
<label for="password-input">Password:</label>
|
650
662
|
<input id="password-input">
|
651
663
|
```
|
652
664
|
|
665
|
+
```ruby
|
666
|
+
page.get_by_label("Password").fill("secret")
|
667
|
+
```
|
668
|
+
|
653
669
|
## get_by_placeholder
|
654
670
|
|
655
671
|
```
|
@@ -657,10 +673,20 @@ def get_by_placeholder(text, exact: nil)
|
|
657
673
|
```
|
658
674
|
|
659
675
|
|
660
|
-
Allows locating input elements by the placeholder text.
|
676
|
+
Allows locating input elements by the placeholder text.
|
677
|
+
|
678
|
+
**Usage**
|
679
|
+
|
680
|
+
For example, consider the following DOM structure.
|
661
681
|
|
662
682
|
```html
|
663
|
-
<input placeholder="
|
683
|
+
<input type="email" placeholder="name@example.com" />
|
684
|
+
```
|
685
|
+
|
686
|
+
You can fill the input after locating it by the placeholder text:
|
687
|
+
|
688
|
+
```ruby
|
689
|
+
page.get_by_placeholder("name@example.com").fill("playwright@microsoft.com")
|
664
690
|
```
|
665
691
|
|
666
692
|
## get_by_role
|
@@ -680,9 +706,34 @@ def get_by_role(
|
|
680
706
|
```
|
681
707
|
|
682
708
|
|
683
|
-
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).
|
709
|
+
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).
|
710
|
+
|
711
|
+
**Usage**
|
712
|
+
|
713
|
+
Consider the following DOM structure.
|
714
|
+
|
715
|
+
```html
|
716
|
+
<h3>Sign up</h3>
|
717
|
+
<label>
|
718
|
+
<input type="checkbox" /> Subscribe
|
719
|
+
</label>
|
720
|
+
<br/>
|
721
|
+
<button>Submit</button>
|
722
|
+
```
|
723
|
+
|
724
|
+
You can locate each element by it's implicit role:
|
725
|
+
|
726
|
+
```ruby
|
727
|
+
page.get_by_role("heading", name: "Sign up").visible? # => true
|
728
|
+
page.get_by_role("checkbox", name: "Subscribe").check
|
729
|
+
page.get_by_role("button", name: /submit/i).click
|
730
|
+
```
|
731
|
+
|
732
|
+
**Details**
|
733
|
+
|
734
|
+
Role selector **does not replace** accessibility audits and conformance tests, but rather gives early feedback about the ARIA guidelines.
|
684
735
|
|
685
|
-
|
736
|
+
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.
|
686
737
|
|
687
738
|
## get_by_test_id
|
688
739
|
|
@@ -691,7 +742,25 @@ def get_by_test_id(testId)
|
|
691
742
|
```
|
692
743
|
|
693
744
|
|
694
|
-
Locate element by the test id.
|
745
|
+
Locate element by the test id.
|
746
|
+
|
747
|
+
**Usage**
|
748
|
+
|
749
|
+
Consider the following DOM structure.
|
750
|
+
|
751
|
+
```html
|
752
|
+
<button data-testid="directions">Itinéraire</button>
|
753
|
+
```
|
754
|
+
|
755
|
+
You can locate the element by it's test id:
|
756
|
+
|
757
|
+
```ruby
|
758
|
+
page.get_by_test_id("directions").click
|
759
|
+
```
|
760
|
+
|
761
|
+
**Details**
|
762
|
+
|
763
|
+
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.
|
695
764
|
|
696
765
|
## get_by_text
|
697
766
|
|
@@ -700,7 +769,13 @@ def get_by_text(text, exact: nil)
|
|
700
769
|
```
|
701
770
|
|
702
771
|
|
703
|
-
Allows locating elements that contain given text.
|
772
|
+
Allows locating elements that contain given text.
|
773
|
+
|
774
|
+
See also [Locator#filter](./locator#filter) that allows to match by another criteria, like an accessible role, and then filter by the text content.
|
775
|
+
|
776
|
+
**Usage**
|
777
|
+
|
778
|
+
Consider the following DOM structure:
|
704
779
|
|
705
780
|
```html
|
706
781
|
<div>Hello <span>world</span></div>
|
@@ -738,11 +813,11 @@ locator = page.get_by_text(/^hello$/i)
|
|
738
813
|
expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
|
739
814
|
```
|
740
815
|
|
741
|
-
|
816
|
+
**Details**
|
742
817
|
|
743
|
-
|
818
|
+
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.
|
744
819
|
|
745
|
-
|
820
|
+
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">`.
|
746
821
|
|
747
822
|
## get_by_title
|
748
823
|
|
@@ -751,10 +826,20 @@ def get_by_title(text, exact: nil)
|
|
751
826
|
```
|
752
827
|
|
753
828
|
|
754
|
-
Allows locating elements by their title.
|
829
|
+
Allows locating elements by their title attribute.
|
830
|
+
|
831
|
+
**Usage**
|
832
|
+
|
833
|
+
Consider the following DOM structure.
|
755
834
|
|
756
835
|
```html
|
757
|
-
<
|
836
|
+
<span title='Issues count'>25 issues</span>
|
837
|
+
```
|
838
|
+
|
839
|
+
You can check the issues count after locating it by the title text:
|
840
|
+
|
841
|
+
```ruby
|
842
|
+
page.get_by_title("Issues count").text_content # => "25 issues"
|
758
843
|
```
|
759
844
|
|
760
845
|
## go_back
|
data/lib/playwright/version.rb
CHANGED
data/lib/playwright_api/frame.rb
CHANGED
@@ -360,40 +360,93 @@ module Playwright
|
|
360
360
|
end
|
361
361
|
|
362
362
|
#
|
363
|
-
# Allows locating elements by their alt text.
|
363
|
+
# Allows locating elements by their alt text.
|
364
|
+
#
|
365
|
+
# **Usage**
|
366
|
+
#
|
367
|
+
# For example, this method will find the image by alt text "Playwright logo":
|
364
368
|
#
|
365
369
|
# ```html
|
366
|
-
# <img alt='
|
370
|
+
# <img alt='Playwright logo'>
|
371
|
+
# ```
|
372
|
+
#
|
373
|
+
# ```python sync
|
374
|
+
# page.get_by_alt_text("Playwright logo").click()
|
367
375
|
# ```
|
368
376
|
def get_by_alt_text(text, exact: nil)
|
369
377
|
wrap_impl(@impl.get_by_alt_text(unwrap_impl(text), exact: unwrap_impl(exact)))
|
370
378
|
end
|
371
379
|
|
372
380
|
#
|
373
|
-
# Allows locating input elements by the text of the associated label.
|
381
|
+
# Allows locating input elements by the text of the associated label.
|
382
|
+
#
|
383
|
+
# **Usage**
|
384
|
+
#
|
385
|
+
# For example, this method will find the input by label text "Password" in the following DOM:
|
374
386
|
#
|
375
387
|
# ```html
|
376
388
|
# <label for="password-input">Password:</label>
|
377
389
|
# <input id="password-input">
|
378
390
|
# ```
|
391
|
+
#
|
392
|
+
# ```python sync
|
393
|
+
# page.get_by_label("Password").fill("secret")
|
394
|
+
# ```
|
379
395
|
def get_by_label(text, exact: nil)
|
380
396
|
wrap_impl(@impl.get_by_label(unwrap_impl(text), exact: unwrap_impl(exact)))
|
381
397
|
end
|
382
398
|
|
383
399
|
#
|
384
|
-
# Allows locating input elements by the placeholder text.
|
400
|
+
# Allows locating input elements by the placeholder text.
|
401
|
+
#
|
402
|
+
# **Usage**
|
403
|
+
#
|
404
|
+
# For example, consider the following DOM structure.
|
385
405
|
#
|
386
406
|
# ```html
|
387
|
-
# <input placeholder="
|
407
|
+
# <input type="email" placeholder="name@example.com" />
|
408
|
+
# ```
|
409
|
+
#
|
410
|
+
# You can fill the input after locating it by the placeholder text:
|
411
|
+
#
|
412
|
+
# ```python sync
|
413
|
+
# page.get_by_placeholder("name@example.com").fill("playwright@microsoft.com")
|
388
414
|
# ```
|
389
415
|
def get_by_placeholder(text, exact: nil)
|
390
416
|
wrap_impl(@impl.get_by_placeholder(unwrap_impl(text), exact: unwrap_impl(exact)))
|
391
417
|
end
|
392
418
|
|
393
419
|
#
|
394
|
-
# 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).
|
420
|
+
# 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).
|
421
|
+
#
|
422
|
+
# **Usage**
|
423
|
+
#
|
424
|
+
# Consider the following DOM structure.
|
425
|
+
#
|
426
|
+
# ```html
|
427
|
+
# <h3>Sign up</h3>
|
428
|
+
# <label>
|
429
|
+
# <input type="checkbox" /> Subscribe
|
430
|
+
# </label>
|
431
|
+
# <br/>
|
432
|
+
# <button>Submit</button>
|
433
|
+
# ```
|
434
|
+
#
|
435
|
+
# You can locate each element by it's implicit role:
|
436
|
+
#
|
437
|
+
# ```python sync
|
438
|
+
# expect(page.get_by_role("heading", name="Sign up")).to_be_visible()
|
439
|
+
#
|
440
|
+
# page.get_by_role("checkbox", name="Subscribe").check()
|
395
441
|
#
|
396
|
-
#
|
442
|
+
# page.get_by_role("button", name=re.compile("submit", re.IGNORECASE)).click()
|
443
|
+
# ```
|
444
|
+
#
|
445
|
+
# **Details**
|
446
|
+
#
|
447
|
+
# Role selector **does not replace** accessibility audits and conformance tests, but rather gives early feedback about the ARIA guidelines.
|
448
|
+
#
|
449
|
+
# 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.
|
397
450
|
def get_by_role(
|
398
451
|
role,
|
399
452
|
checked: nil,
|
@@ -409,13 +462,37 @@ module Playwright
|
|
409
462
|
end
|
410
463
|
|
411
464
|
#
|
412
|
-
# Locate element by the test id.
|
465
|
+
# Locate element by the test id.
|
466
|
+
#
|
467
|
+
# **Usage**
|
468
|
+
#
|
469
|
+
# Consider the following DOM structure.
|
470
|
+
#
|
471
|
+
# ```html
|
472
|
+
# <button data-testid="directions">Itinéraire</button>
|
473
|
+
# ```
|
474
|
+
#
|
475
|
+
# You can locate the element by it's test id:
|
476
|
+
#
|
477
|
+
# ```python sync
|
478
|
+
# page.get_by_test_id("directions").click()
|
479
|
+
# ```
|
480
|
+
#
|
481
|
+
# **Details**
|
482
|
+
#
|
483
|
+
# 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.
|
413
484
|
def get_by_test_id(testId)
|
414
485
|
wrap_impl(@impl.get_by_test_id(unwrap_impl(testId)))
|
415
486
|
end
|
416
487
|
|
417
488
|
#
|
418
|
-
# Allows locating elements that contain given text.
|
489
|
+
# Allows locating elements that contain given text.
|
490
|
+
#
|
491
|
+
# See also [`method: Locator.filter`] that allows to match by another criteria, like an accessible role, and then filter by the text content.
|
492
|
+
#
|
493
|
+
# **Usage**
|
494
|
+
#
|
495
|
+
# Consider the following DOM structure:
|
419
496
|
#
|
420
497
|
# ```html
|
421
498
|
# <div>Hello <span>world</span></div>
|
@@ -441,20 +518,30 @@ module Playwright
|
|
441
518
|
# page.get_by_text(re.compile("^hello$", re.IGNORECASE))
|
442
519
|
# ```
|
443
520
|
#
|
444
|
-
#
|
521
|
+
# **Details**
|
445
522
|
#
|
446
|
-
#
|
523
|
+
# 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.
|
447
524
|
#
|
448
|
-
#
|
525
|
+
# 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">`.
|
449
526
|
def get_by_text(text, exact: nil)
|
450
527
|
wrap_impl(@impl.get_by_text(unwrap_impl(text), exact: unwrap_impl(exact)))
|
451
528
|
end
|
452
529
|
|
453
530
|
#
|
454
|
-
# Allows locating elements by their title.
|
531
|
+
# Allows locating elements by their title attribute.
|
532
|
+
#
|
533
|
+
# **Usage**
|
534
|
+
#
|
535
|
+
# Consider the following DOM structure.
|
455
536
|
#
|
456
537
|
# ```html
|
457
|
-
# <
|
538
|
+
# <span title='Issues count'>25 issues</span>
|
539
|
+
# ```
|
540
|
+
#
|
541
|
+
# You can check the issues count after locating it by the title text:
|
542
|
+
#
|
543
|
+
# ```python sync
|
544
|
+
# expect(page.get_by_title("Issues count")).to_have_text("25 issues")
|
458
545
|
# ```
|
459
546
|
def get_by_title(text, exact: nil)
|
460
547
|
wrap_impl(@impl.get_by_title(unwrap_impl(text), exact: unwrap_impl(exact)))
|
@@ -42,40 +42,93 @@ module Playwright
|
|
42
42
|
end
|
43
43
|
|
44
44
|
#
|
45
|
-
# Allows locating elements by their alt text.
|
45
|
+
# Allows locating elements by their alt text.
|
46
|
+
#
|
47
|
+
# **Usage**
|
48
|
+
#
|
49
|
+
# For example, this method will find the image by alt text "Playwright logo":
|
46
50
|
#
|
47
51
|
# ```html
|
48
|
-
# <img alt='
|
52
|
+
# <img alt='Playwright logo'>
|
53
|
+
# ```
|
54
|
+
#
|
55
|
+
# ```python sync
|
56
|
+
# page.get_by_alt_text("Playwright logo").click()
|
49
57
|
# ```
|
50
58
|
def get_by_alt_text(text, exact: nil)
|
51
59
|
wrap_impl(@impl.get_by_alt_text(unwrap_impl(text), exact: unwrap_impl(exact)))
|
52
60
|
end
|
53
61
|
|
54
62
|
#
|
55
|
-
# Allows locating input elements by the text of the associated label.
|
63
|
+
# Allows locating input elements by the text of the associated label.
|
64
|
+
#
|
65
|
+
# **Usage**
|
66
|
+
#
|
67
|
+
# For example, this method will find the input by label text "Password" in the following DOM:
|
56
68
|
#
|
57
69
|
# ```html
|
58
70
|
# <label for="password-input">Password:</label>
|
59
71
|
# <input id="password-input">
|
60
72
|
# ```
|
73
|
+
#
|
74
|
+
# ```python sync
|
75
|
+
# page.get_by_label("Password").fill("secret")
|
76
|
+
# ```
|
61
77
|
def get_by_label(text, exact: nil)
|
62
78
|
wrap_impl(@impl.get_by_label(unwrap_impl(text), exact: unwrap_impl(exact)))
|
63
79
|
end
|
64
80
|
|
65
81
|
#
|
66
|
-
# Allows locating input elements by the placeholder text.
|
82
|
+
# Allows locating input elements by the placeholder text.
|
83
|
+
#
|
84
|
+
# **Usage**
|
85
|
+
#
|
86
|
+
# For example, consider the following DOM structure.
|
67
87
|
#
|
68
88
|
# ```html
|
69
|
-
# <input placeholder="
|
89
|
+
# <input type="email" placeholder="name@example.com" />
|
90
|
+
# ```
|
91
|
+
#
|
92
|
+
# You can fill the input after locating it by the placeholder text:
|
93
|
+
#
|
94
|
+
# ```python sync
|
95
|
+
# page.get_by_placeholder("name@example.com").fill("playwright@microsoft.com")
|
70
96
|
# ```
|
71
97
|
def get_by_placeholder(text, exact: nil)
|
72
98
|
wrap_impl(@impl.get_by_placeholder(unwrap_impl(text), exact: unwrap_impl(exact)))
|
73
99
|
end
|
74
100
|
|
75
101
|
#
|
76
|
-
# 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).
|
102
|
+
# 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).
|
103
|
+
#
|
104
|
+
# **Usage**
|
77
105
|
#
|
78
|
-
#
|
106
|
+
# Consider the following DOM structure.
|
107
|
+
#
|
108
|
+
# ```html
|
109
|
+
# <h3>Sign up</h3>
|
110
|
+
# <label>
|
111
|
+
# <input type="checkbox" /> Subscribe
|
112
|
+
# </label>
|
113
|
+
# <br/>
|
114
|
+
# <button>Submit</button>
|
115
|
+
# ```
|
116
|
+
#
|
117
|
+
# You can locate each element by it's implicit role:
|
118
|
+
#
|
119
|
+
# ```python sync
|
120
|
+
# expect(page.get_by_role("heading", name="Sign up")).to_be_visible()
|
121
|
+
#
|
122
|
+
# page.get_by_role("checkbox", name="Subscribe").check()
|
123
|
+
#
|
124
|
+
# page.get_by_role("button", name=re.compile("submit", re.IGNORECASE)).click()
|
125
|
+
# ```
|
126
|
+
#
|
127
|
+
# **Details**
|
128
|
+
#
|
129
|
+
# Role selector **does not replace** accessibility audits and conformance tests, but rather gives early feedback about the ARIA guidelines.
|
130
|
+
#
|
131
|
+
# 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.
|
79
132
|
def get_by_role(
|
80
133
|
role,
|
81
134
|
checked: nil,
|
@@ -91,13 +144,37 @@ module Playwright
|
|
91
144
|
end
|
92
145
|
|
93
146
|
#
|
94
|
-
# Locate element by the test id.
|
147
|
+
# Locate element by the test id.
|
148
|
+
#
|
149
|
+
# **Usage**
|
150
|
+
#
|
151
|
+
# Consider the following DOM structure.
|
152
|
+
#
|
153
|
+
# ```html
|
154
|
+
# <button data-testid="directions">Itinéraire</button>
|
155
|
+
# ```
|
156
|
+
#
|
157
|
+
# You can locate the element by it's test id:
|
158
|
+
#
|
159
|
+
# ```python sync
|
160
|
+
# page.get_by_test_id("directions").click()
|
161
|
+
# ```
|
162
|
+
#
|
163
|
+
# **Details**
|
164
|
+
#
|
165
|
+
# 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.
|
95
166
|
def get_by_test_id(testId)
|
96
167
|
wrap_impl(@impl.get_by_test_id(unwrap_impl(testId)))
|
97
168
|
end
|
98
169
|
|
99
170
|
#
|
100
|
-
# Allows locating elements that contain given text.
|
171
|
+
# Allows locating elements that contain given text.
|
172
|
+
#
|
173
|
+
# See also [`method: Locator.filter`] that allows to match by another criteria, like an accessible role, and then filter by the text content.
|
174
|
+
#
|
175
|
+
# **Usage**
|
176
|
+
#
|
177
|
+
# Consider the following DOM structure:
|
101
178
|
#
|
102
179
|
# ```html
|
103
180
|
# <div>Hello <span>world</span></div>
|
@@ -123,20 +200,30 @@ module Playwright
|
|
123
200
|
# page.get_by_text(re.compile("^hello$", re.IGNORECASE))
|
124
201
|
# ```
|
125
202
|
#
|
126
|
-
#
|
203
|
+
# **Details**
|
127
204
|
#
|
128
|
-
#
|
205
|
+
# 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.
|
129
206
|
#
|
130
|
-
#
|
207
|
+
# 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">`.
|
131
208
|
def get_by_text(text, exact: nil)
|
132
209
|
wrap_impl(@impl.get_by_text(unwrap_impl(text), exact: unwrap_impl(exact)))
|
133
210
|
end
|
134
211
|
|
135
212
|
#
|
136
|
-
# Allows locating elements by their title.
|
213
|
+
# Allows locating elements by their title attribute.
|
214
|
+
#
|
215
|
+
# **Usage**
|
216
|
+
#
|
217
|
+
# Consider the following DOM structure.
|
137
218
|
#
|
138
219
|
# ```html
|
139
|
-
# <
|
220
|
+
# <span title='Issues count'>25 issues</span>
|
221
|
+
# ```
|
222
|
+
#
|
223
|
+
# You can check the issues count after locating it by the title text:
|
224
|
+
#
|
225
|
+
# ```python sync
|
226
|
+
# expect(page.get_by_title("Issues count")).to_have_text("25 issues")
|
140
227
|
# ```
|
141
228
|
def get_by_title(text, exact: nil)
|
142
229
|
wrap_impl(@impl.get_by_title(unwrap_impl(text), exact: unwrap_impl(exact)))
|