playwright-ruby-client 1.27.0 → 1.28.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/documentation/docs/api/element_handle.md +1 -0
- data/documentation/docs/api/frame.md +51 -3
- data/documentation/docs/api/frame_locator.md +50 -3
- data/documentation/docs/api/js_handle.md +5 -3
- data/documentation/docs/api/keyboard.md +1 -1
- data/documentation/docs/api/locator.md +73 -3
- data/documentation/docs/api/page.md +51 -3
- data/documentation/docs/api/request.md +1 -1
- data/documentation/docs/article/guides/rails_integration.md +1 -0
- data/documentation/docs/include/api_coverage.md +3 -0
- data/lib/playwright/channel_owner.rb +41 -0
- data/lib/playwright/channel_owners/android.rb +2 -2
- data/lib/playwright/channel_owners/android_device.rb +14 -55
- data/lib/playwright/channel_owners/browser_context.rb +6 -0
- data/lib/playwright/channel_owners/element_handle.rb +8 -1
- data/lib/playwright/channel_owners/frame.rb +2 -0
- data/lib/playwright/channel_owners/page.rb +23 -28
- data/lib/playwright/channel_owners/playwright.rb +7 -0
- data/lib/playwright/connection.rb +4 -1
- data/lib/playwright/input_files.rb +3 -1
- data/lib/playwright/locator_impl.rb +16 -2
- data/lib/playwright/locator_utils.rb +13 -19
- data/lib/playwright/utils.rb +6 -0
- data/lib/playwright/version.rb +2 -2
- data/lib/playwright/web_socket_transport.rb +1 -1
- data/lib/playwright.rb +55 -0
- data/lib/playwright_api/android.rb +12 -6
- data/lib/playwright_api/android_device.rb +10 -5
- data/lib/playwright_api/api_request_context.rb +6 -6
- data/lib/playwright_api/browser.rb +6 -6
- data/lib/playwright_api/browser_context.rb +6 -6
- data/lib/playwright_api/browser_type.rb +6 -6
- data/lib/playwright_api/cdp_session.rb +6 -6
- data/lib/playwright_api/console_message.rb +6 -6
- data/lib/playwright_api/dialog.rb +6 -6
- data/lib/playwright_api/element_handle.rb +8 -7
- data/lib/playwright_api/frame.rb +45 -11
- data/lib/playwright_api/frame_locator.rb +39 -6
- data/lib/playwright_api/js_handle.rb +7 -7
- data/lib/playwright_api/keyboard.rb +1 -1
- data/lib/playwright_api/locator.rb +55 -5
- data/lib/playwright_api/page.rb +45 -11
- data/lib/playwright_api/playwright.rb +6 -6
- data/lib/playwright_api/request.rb +7 -7
- data/lib/playwright_api/response.rb +6 -6
- data/lib/playwright_api/route.rb +6 -6
- data/lib/playwright_api/selectors.rb +6 -6
- data/lib/playwright_api/tracing.rb +6 -6
- data/lib/playwright_api/web_socket.rb +6 -6
- data/lib/playwright_api/worker.rb +6 -6
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6b579547c4cff2fbaf98b5c2796c8689f655f316b391b7127891fd03212cea4
|
4
|
+
data.tar.gz: c32a3787fa3f6c2e874844f94deef249c335cee4f6efcc8d23e8045bfd6346f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7481f324212879e913399614beab51affce2c8dc05040ac0d506d9b583fcf48c897bd1a1f3b7f332212497db2000e538a1cf1fd19c60d5ddf7c884e2e366d687
|
7
|
+
data.tar.gz: 58eb07d5abb6307bd15464b6f33d8c0d0cc4110cf80c26915cecc00be911fba8e6240687cb46698c81fda29651718b4039f8ca1530661e5ccd4a7d1632bd6ef3
|
@@ -435,7 +435,7 @@ def get_by_label(text, exact: nil)
|
|
435
435
|
```
|
436
436
|
|
437
437
|
Allows locating input elements by the text of the associated label. For example, this method will find the input by
|
438
|
-
label text Password in the following DOM:
|
438
|
+
label text "Password" in the following DOM:
|
439
439
|
|
440
440
|
```html
|
441
441
|
<label for="password-input">Password:</label>
|
@@ -464,6 +464,7 @@ def get_by_role(
|
|
464
464
|
role,
|
465
465
|
checked: nil,
|
466
466
|
disabled: nil,
|
467
|
+
exact: nil,
|
467
468
|
expanded: nil,
|
468
469
|
includeHidden: nil,
|
469
470
|
level: nil,
|
@@ -491,13 +492,59 @@ def get_by_test_id(testId)
|
|
491
492
|
Locate element by the test id. By default, the `data-testid` attribute is used as a test id. Use
|
492
493
|
[Selectors#set_test_id_attribute](./selectors#set_test_id_attribute) to configure a different test id attribute if necessary.
|
493
494
|
|
495
|
+
|
496
|
+
|
494
497
|
## get_by_text
|
495
498
|
|
496
499
|
```
|
497
500
|
def get_by_text(text, exact: nil)
|
498
501
|
```
|
499
502
|
|
500
|
-
Allows locating elements that contain given text.
|
503
|
+
Allows locating elements that contain given text. Consider the following DOM structure:
|
504
|
+
|
505
|
+
```html
|
506
|
+
<div>Hello <span>world</span></div>
|
507
|
+
<div>Hello</div>
|
508
|
+
```
|
509
|
+
|
510
|
+
You can locate by text substring, exact string, or a regular expression:
|
511
|
+
|
512
|
+
```ruby
|
513
|
+
page.content = <<~HTML
|
514
|
+
<div>Hello <span>world</span></div>
|
515
|
+
<div>Hello</div>
|
516
|
+
HTML
|
517
|
+
|
518
|
+
# Matches <span>
|
519
|
+
locator = page.get_by_text("world")
|
520
|
+
expect(locator.evaluate('e => e.outerHTML')).to eq('<span>world</span>')
|
521
|
+
|
522
|
+
# Matches first <div>
|
523
|
+
locator = page.get_by_text("Hello world")
|
524
|
+
expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello <span>world</span></div>')
|
525
|
+
|
526
|
+
# Matches second <div>
|
527
|
+
locator = page.get_by_text("Hello", exact: true)
|
528
|
+
expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
|
529
|
+
|
530
|
+
# Matches both <div>s
|
531
|
+
locator = page.get_by_text(/Hello/)
|
532
|
+
expect(locator.count).to eq(2)
|
533
|
+
expect(locator.first.evaluate('e => e.outerHTML')).to eq('<div>Hello <span>world</span></div>')
|
534
|
+
expect(locator.last.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
|
535
|
+
|
536
|
+
# Matches second <div>
|
537
|
+
locator = page.get_by_text(/^hello$/i)
|
538
|
+
expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
|
539
|
+
```
|
540
|
+
|
541
|
+
See also [Locator#filter](./locator#filter) that allows to match by another criteria, like an accessible role, and then filter
|
542
|
+
by the text content.
|
543
|
+
|
544
|
+
> NOTE: Matching by text always normalizes whitespace, even with exact match. For example, it turns multiple spaces into
|
545
|
+
one, turns line breaks into spaces and ignores leading and trailing whitespace.
|
546
|
+
> NOTE: Input elements of the type `button` and `submit` are matched by their `value` instead of the text content. For
|
547
|
+
example, locating by text `"Log in"` matches `<input type=button value="Log in">`.
|
501
548
|
|
502
549
|
## get_by_title
|
503
550
|
|
@@ -505,7 +552,7 @@ Allows locating elements that contain given text.
|
|
505
552
|
def get_by_title(text, exact: nil)
|
506
553
|
```
|
507
554
|
|
508
|
-
Allows locating elements by their title. For example, this method will find the button by its title "
|
555
|
+
Allows locating elements by their title. For example, this method will find the button by its title "Place the order":
|
509
556
|
|
510
557
|
```html
|
511
558
|
<button title='Place the order'>Order Now</button>
|
@@ -544,6 +591,7 @@ def hover(
|
|
544
591
|
selector,
|
545
592
|
force: nil,
|
546
593
|
modifiers: nil,
|
594
|
+
noWaitAfter: nil,
|
547
595
|
position: nil,
|
548
596
|
strict: nil,
|
549
597
|
timeout: nil,
|
@@ -74,7 +74,7 @@ def get_by_label(text, exact: nil)
|
|
74
74
|
```
|
75
75
|
|
76
76
|
Allows locating input elements by the text of the associated label. For example, this method will find the input by
|
77
|
-
label text Password in the following DOM:
|
77
|
+
label text "Password" in the following DOM:
|
78
78
|
|
79
79
|
```html
|
80
80
|
<label for="password-input">Password:</label>
|
@@ -103,6 +103,7 @@ def get_by_role(
|
|
103
103
|
role,
|
104
104
|
checked: nil,
|
105
105
|
disabled: nil,
|
106
|
+
exact: nil,
|
106
107
|
expanded: nil,
|
107
108
|
includeHidden: nil,
|
108
109
|
level: nil,
|
@@ -130,13 +131,59 @@ def get_by_test_id(testId)
|
|
130
131
|
Locate element by the test id. By default, the `data-testid` attribute is used as a test id. Use
|
131
132
|
[Selectors#set_test_id_attribute](./selectors#set_test_id_attribute) to configure a different test id attribute if necessary.
|
132
133
|
|
134
|
+
|
135
|
+
|
133
136
|
## get_by_text
|
134
137
|
|
135
138
|
```
|
136
139
|
def get_by_text(text, exact: nil)
|
137
140
|
```
|
138
141
|
|
139
|
-
Allows locating elements that contain given text.
|
142
|
+
Allows locating elements that contain given text. Consider the following DOM structure:
|
143
|
+
|
144
|
+
```html
|
145
|
+
<div>Hello <span>world</span></div>
|
146
|
+
<div>Hello</div>
|
147
|
+
```
|
148
|
+
|
149
|
+
You can locate by text substring, exact string, or a regular expression:
|
150
|
+
|
151
|
+
```ruby
|
152
|
+
page.content = <<~HTML
|
153
|
+
<div>Hello <span>world</span></div>
|
154
|
+
<div>Hello</div>
|
155
|
+
HTML
|
156
|
+
|
157
|
+
# Matches <span>
|
158
|
+
locator = page.get_by_text("world")
|
159
|
+
expect(locator.evaluate('e => e.outerHTML')).to eq('<span>world</span>')
|
160
|
+
|
161
|
+
# Matches first <div>
|
162
|
+
locator = page.get_by_text("Hello world")
|
163
|
+
expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello <span>world</span></div>')
|
164
|
+
|
165
|
+
# Matches second <div>
|
166
|
+
locator = page.get_by_text("Hello", exact: true)
|
167
|
+
expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
|
168
|
+
|
169
|
+
# Matches both <div>s
|
170
|
+
locator = page.get_by_text(/Hello/)
|
171
|
+
expect(locator.count).to eq(2)
|
172
|
+
expect(locator.first.evaluate('e => e.outerHTML')).to eq('<div>Hello <span>world</span></div>')
|
173
|
+
expect(locator.last.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
|
174
|
+
|
175
|
+
# Matches second <div>
|
176
|
+
locator = page.get_by_text(/^hello$/i)
|
177
|
+
expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
|
178
|
+
```
|
179
|
+
|
180
|
+
See also [Locator#filter](./locator#filter) that allows to match by another criteria, like an accessible role, and then filter
|
181
|
+
by the text content.
|
182
|
+
|
183
|
+
> NOTE: Matching by text always normalizes whitespace, even with exact match. For example, it turns multiple spaces into
|
184
|
+
one, turns line breaks into spaces and ignores leading and trailing whitespace.
|
185
|
+
> NOTE: Input elements of the type `button` and `submit` are matched by their `value` instead of the text content. For
|
186
|
+
example, locating by text `"Log in"` matches `<input type=button value="Log in">`.
|
140
187
|
|
141
188
|
## get_by_title
|
142
189
|
|
@@ -144,7 +191,7 @@ Allows locating elements that contain given text.
|
|
144
191
|
def get_by_title(text, exact: nil)
|
145
192
|
```
|
146
193
|
|
147
|
-
Allows locating elements by their title. For example, this method will find the button by its title "
|
194
|
+
Allows locating elements by their title. For example, this method will find the button by its title "Place the order":
|
148
195
|
|
149
196
|
```html
|
150
197
|
<button title='Place the order'>Order Now</button>
|
@@ -85,10 +85,12 @@ The method returns a map with **own property names** as keys and JSHandle instan
|
|
85
85
|
|
86
86
|
```ruby
|
87
87
|
page.goto('https://example.com/')
|
88
|
-
|
89
|
-
properties =
|
88
|
+
handle = page.evaluate_handle("({window, document})")
|
89
|
+
properties = handle.properties
|
90
90
|
puts properties
|
91
|
-
window_handle
|
91
|
+
window_handle = properties["window"]
|
92
|
+
document_handle = properties["document"]
|
93
|
+
handle.dispose
|
92
94
|
```
|
93
95
|
|
94
96
|
|
@@ -5,7 +5,7 @@ sidebar_position: 10
|
|
5
5
|
# Keyboard
|
6
6
|
|
7
7
|
Keyboard provides an api for managing a virtual keyboard. The high level api is [Keyboard#type](./keyboard#type), which takes
|
8
|
-
raw characters and generates proper keydown
|
8
|
+
raw characters and generates proper `keydown`, `keypress`/`input`, and `keyup` events on your page.
|
9
9
|
|
10
10
|
For finer control, you can use [Keyboard#down](./keyboard#down), [Keyboard#up](./keyboard#up), and [Keyboard#insert_text](./keyboard#insert_text)
|
11
11
|
to manually fire events as if they were generated from a real keyboard.
|
@@ -25,6 +25,14 @@ def all_text_contents
|
|
25
25
|
|
26
26
|
Returns an array of `node.textContent` values for all matching nodes.
|
27
27
|
|
28
|
+
## blur
|
29
|
+
|
30
|
+
```
|
31
|
+
def blur(timeout: nil)
|
32
|
+
```
|
33
|
+
|
34
|
+
Calls [blur](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/blur) on the element.
|
35
|
+
|
28
36
|
## bounding_box
|
29
37
|
|
30
38
|
```
|
@@ -79,6 +87,20 @@ If the element is detached from the DOM at any moment during the action, this me
|
|
79
87
|
When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
|
80
88
|
zero timeout disables this.
|
81
89
|
|
90
|
+
## clear
|
91
|
+
|
92
|
+
```
|
93
|
+
def clear(force: nil, noWaitAfter: nil, timeout: nil)
|
94
|
+
```
|
95
|
+
|
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
|
+
|
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.
|
103
|
+
|
82
104
|
## click
|
83
105
|
|
84
106
|
```
|
@@ -382,7 +404,7 @@ def get_by_label(text, exact: nil)
|
|
382
404
|
```
|
383
405
|
|
384
406
|
Allows locating input elements by the text of the associated label. For example, this method will find the input by
|
385
|
-
label text Password in the following DOM:
|
407
|
+
label text "Password" in the following DOM:
|
386
408
|
|
387
409
|
```html
|
388
410
|
<label for="password-input">Password:</label>
|
@@ -411,6 +433,7 @@ def get_by_role(
|
|
411
433
|
role,
|
412
434
|
checked: nil,
|
413
435
|
disabled: nil,
|
436
|
+
exact: nil,
|
414
437
|
expanded: nil,
|
415
438
|
includeHidden: nil,
|
416
439
|
level: nil,
|
@@ -438,13 +461,59 @@ def get_by_test_id(testId)
|
|
438
461
|
Locate element by the test id. By default, the `data-testid` attribute is used as a test id. Use
|
439
462
|
[Selectors#set_test_id_attribute](./selectors#set_test_id_attribute) to configure a different test id attribute if necessary.
|
440
463
|
|
464
|
+
|
465
|
+
|
441
466
|
## get_by_text
|
442
467
|
|
443
468
|
```
|
444
469
|
def get_by_text(text, exact: nil)
|
445
470
|
```
|
446
471
|
|
447
|
-
Allows locating elements that contain given text.
|
472
|
+
Allows locating elements that contain given text. Consider the following DOM structure:
|
473
|
+
|
474
|
+
```html
|
475
|
+
<div>Hello <span>world</span></div>
|
476
|
+
<div>Hello</div>
|
477
|
+
```
|
478
|
+
|
479
|
+
You can locate by text substring, exact string, or a regular expression:
|
480
|
+
|
481
|
+
```ruby
|
482
|
+
page.content = <<~HTML
|
483
|
+
<div>Hello <span>world</span></div>
|
484
|
+
<div>Hello</div>
|
485
|
+
HTML
|
486
|
+
|
487
|
+
# Matches <span>
|
488
|
+
locator = page.get_by_text("world")
|
489
|
+
expect(locator.evaluate('e => e.outerHTML')).to eq('<span>world</span>')
|
490
|
+
|
491
|
+
# Matches first <div>
|
492
|
+
locator = page.get_by_text("Hello world")
|
493
|
+
expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello <span>world</span></div>')
|
494
|
+
|
495
|
+
# Matches second <div>
|
496
|
+
locator = page.get_by_text("Hello", exact: true)
|
497
|
+
expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
|
498
|
+
|
499
|
+
# Matches both <div>s
|
500
|
+
locator = page.get_by_text(/Hello/)
|
501
|
+
expect(locator.count).to eq(2)
|
502
|
+
expect(locator.first.evaluate('e => e.outerHTML')).to eq('<div>Hello <span>world</span></div>')
|
503
|
+
expect(locator.last.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
|
504
|
+
|
505
|
+
# Matches second <div>
|
506
|
+
locator = page.get_by_text(/^hello$/i)
|
507
|
+
expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
|
508
|
+
```
|
509
|
+
|
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.
|
512
|
+
|
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">`.
|
448
517
|
|
449
518
|
## get_by_title
|
450
519
|
|
@@ -452,7 +521,7 @@ Allows locating elements that contain given text.
|
|
452
521
|
def get_by_title(text, exact: nil)
|
453
522
|
```
|
454
523
|
|
455
|
-
Allows locating elements by their title. For example, this method will find the button by its title "
|
524
|
+
Allows locating elements by their title. For example, this method will find the button by its title "Place the order":
|
456
525
|
|
457
526
|
```html
|
458
527
|
<button title='Place the order'>Order Now</button>
|
@@ -474,6 +543,7 @@ Highlight the corresponding element(s) on the screen. Useful for debugging, don'
|
|
474
543
|
def hover(
|
475
544
|
force: nil,
|
476
545
|
modifiers: nil,
|
546
|
+
noWaitAfter: nil,
|
477
547
|
position: nil,
|
478
548
|
timeout: nil,
|
479
549
|
trial: nil)
|
@@ -648,7 +648,7 @@ def get_by_label(text, exact: nil)
|
|
648
648
|
```
|
649
649
|
|
650
650
|
Allows locating input elements by the text of the associated label. For example, this method will find the input by
|
651
|
-
label text Password in the following DOM:
|
651
|
+
label text "Password" in the following DOM:
|
652
652
|
|
653
653
|
```html
|
654
654
|
<label for="password-input">Password:</label>
|
@@ -677,6 +677,7 @@ def get_by_role(
|
|
677
677
|
role,
|
678
678
|
checked: nil,
|
679
679
|
disabled: nil,
|
680
|
+
exact: nil,
|
680
681
|
expanded: nil,
|
681
682
|
includeHidden: nil,
|
682
683
|
level: nil,
|
@@ -704,13 +705,59 @@ def get_by_test_id(testId)
|
|
704
705
|
Locate element by the test id. By default, the `data-testid` attribute is used as a test id. Use
|
705
706
|
[Selectors#set_test_id_attribute](./selectors#set_test_id_attribute) to configure a different test id attribute if necessary.
|
706
707
|
|
708
|
+
|
709
|
+
|
707
710
|
## get_by_text
|
708
711
|
|
709
712
|
```
|
710
713
|
def get_by_text(text, exact: nil)
|
711
714
|
```
|
712
715
|
|
713
|
-
Allows locating elements that contain given text.
|
716
|
+
Allows locating elements that contain given text. Consider the following DOM structure:
|
717
|
+
|
718
|
+
```html
|
719
|
+
<div>Hello <span>world</span></div>
|
720
|
+
<div>Hello</div>
|
721
|
+
```
|
722
|
+
|
723
|
+
You can locate by text substring, exact string, or a regular expression:
|
724
|
+
|
725
|
+
```ruby
|
726
|
+
page.content = <<~HTML
|
727
|
+
<div>Hello <span>world</span></div>
|
728
|
+
<div>Hello</div>
|
729
|
+
HTML
|
730
|
+
|
731
|
+
# Matches <span>
|
732
|
+
locator = page.get_by_text("world")
|
733
|
+
expect(locator.evaluate('e => e.outerHTML')).to eq('<span>world</span>')
|
734
|
+
|
735
|
+
# Matches first <div>
|
736
|
+
locator = page.get_by_text("Hello world")
|
737
|
+
expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello <span>world</span></div>')
|
738
|
+
|
739
|
+
# Matches second <div>
|
740
|
+
locator = page.get_by_text("Hello", exact: true)
|
741
|
+
expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
|
742
|
+
|
743
|
+
# Matches both <div>s
|
744
|
+
locator = page.get_by_text(/Hello/)
|
745
|
+
expect(locator.count).to eq(2)
|
746
|
+
expect(locator.first.evaluate('e => e.outerHTML')).to eq('<div>Hello <span>world</span></div>')
|
747
|
+
expect(locator.last.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
|
748
|
+
|
749
|
+
# Matches second <div>
|
750
|
+
locator = page.get_by_text(/^hello$/i)
|
751
|
+
expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
|
752
|
+
```
|
753
|
+
|
754
|
+
See also [Locator#filter](./locator#filter) that allows to match by another criteria, like an accessible role, and then filter
|
755
|
+
by the text content.
|
756
|
+
|
757
|
+
> NOTE: Matching by text always normalizes whitespace, even with exact match. For example, it turns multiple spaces into
|
758
|
+
one, turns line breaks into spaces and ignores leading and trailing whitespace.
|
759
|
+
> NOTE: Input elements of the type `button` and `submit` are matched by their `value` instead of the text content. For
|
760
|
+
example, locating by text `"Log in"` matches `<input type=button value="Log in">`.
|
714
761
|
|
715
762
|
## get_by_title
|
716
763
|
|
@@ -718,7 +765,7 @@ Allows locating elements that contain given text.
|
|
718
765
|
def get_by_title(text, exact: nil)
|
719
766
|
```
|
720
767
|
|
721
|
-
Allows locating elements by their title. For example, this method will find the button by its title "
|
768
|
+
Allows locating elements by their title. For example, this method will find the button by its title "Place the order":
|
722
769
|
|
723
770
|
```html
|
724
771
|
<button title='Place the order'>Order Now</button>
|
@@ -781,6 +828,7 @@ def hover(
|
|
781
828
|
selector,
|
782
829
|
force: nil,
|
783
830
|
modifiers: nil,
|
831
|
+
noWaitAfter: nil,
|
784
832
|
position: nil,
|
785
833
|
strict: nil,
|
786
834
|
timeout: nil,
|
@@ -15,7 +15,7 @@ the [`event: Page.requestFailed`] event is emitted.
|
|
15
15
|
> NOTE: HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will
|
16
16
|
complete with `'requestfinished'` event.
|
17
17
|
|
18
|
-
If request gets a 'redirect' response, the request is successfully finished with the
|
18
|
+
If request gets a 'redirect' response, the request is successfully finished with the `requestfinished` event, and a new
|
19
19
|
request is issued to a redirected url.
|
20
20
|
|
21
21
|
## all_headers
|
@@ -420,8 +420,10 @@
|
|
420
420
|
|
421
421
|
* all_inner_texts
|
422
422
|
* all_text_contents
|
423
|
+
* blur
|
423
424
|
* bounding_box
|
424
425
|
* check
|
426
|
+
* clear
|
425
427
|
* click
|
426
428
|
* count
|
427
429
|
* dblclick
|
@@ -519,6 +521,7 @@
|
|
519
521
|
|
520
522
|
## Android
|
521
523
|
|
524
|
+
* ~~connect~~
|
522
525
|
* devices
|
523
526
|
* ~~set_default_timeout~~
|
524
527
|
|
@@ -36,6 +36,7 @@ module Playwright
|
|
36
36
|
@type = type
|
37
37
|
@guid = guid
|
38
38
|
@initializer = initializer
|
39
|
+
@event_to_subscription_mapping = {}
|
39
40
|
|
40
41
|
after_initialize
|
41
42
|
end
|
@@ -59,6 +60,46 @@ module Playwright
|
|
59
60
|
@objects.clear
|
60
61
|
end
|
61
62
|
|
63
|
+
private def set_event_to_subscription_mapping(event_to_subscription_mapping)
|
64
|
+
@event_to_subscription_mapping = event_to_subscription_mapping
|
65
|
+
end
|
66
|
+
|
67
|
+
private def update_subscription(event, enabled)
|
68
|
+
protocol_event = @event_to_subscription_mapping[event]
|
69
|
+
if protocol_event
|
70
|
+
payload = {
|
71
|
+
event: protocol_event,
|
72
|
+
enabled: enabled,
|
73
|
+
}
|
74
|
+
@channel.async_send_message_to_server('updateSubscription', payload)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# @override
|
79
|
+
def on(event, callback)
|
80
|
+
if listener_count(event) == 0
|
81
|
+
update_subscription(event, true)
|
82
|
+
end
|
83
|
+
super
|
84
|
+
end
|
85
|
+
|
86
|
+
# @override
|
87
|
+
def once(event, callback)
|
88
|
+
if listener_count(event) == 0
|
89
|
+
update_subscription(event, true)
|
90
|
+
end
|
91
|
+
super
|
92
|
+
end
|
93
|
+
|
94
|
+
# @override
|
95
|
+
def off(event, callback)
|
96
|
+
super
|
97
|
+
if listener_count(event) == 0
|
98
|
+
update_subscription(event, false)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
|
62
103
|
# Suppress long long inspect log and avoid RSpec from hanging up...
|
63
104
|
def inspect
|
64
105
|
to_s
|
@@ -4,8 +4,8 @@ module Playwright
|
|
4
4
|
@timeout_settings = TimeoutSettings.new
|
5
5
|
end
|
6
6
|
|
7
|
-
def devices(port: nil)
|
8
|
-
params = { port: port }.compact
|
7
|
+
def devices(host: nil, omitDriverInstall: nil, port: nil)
|
8
|
+
params = { host: host, port: port, omitDriverInstall: omitDriverInstall }.compact
|
9
9
|
resp = @channel.send_message_to_server('devices', params)
|
10
10
|
resp.map { |device| ChannelOwners::AndroidDevice.from(device) }
|
11
11
|
end
|
@@ -4,6 +4,11 @@ module Playwright
|
|
4
4
|
|
5
5
|
private def after_initialize
|
6
6
|
@input = AndroidInputImpl.new(@channel)
|
7
|
+
@should_close_connection_on_close = false
|
8
|
+
end
|
9
|
+
|
10
|
+
def should_close_connection_on_close!
|
11
|
+
@should_close_connection_on_close = true
|
7
12
|
end
|
8
13
|
|
9
14
|
attr_reader :input
|
@@ -77,8 +82,12 @@ module Playwright
|
|
77
82
|
end
|
78
83
|
|
79
84
|
def close
|
80
|
-
@channel.send_message_to_server('close')
|
81
85
|
emit(Events::AndroidDevice::Close)
|
86
|
+
if @should_close_connection_on_close
|
87
|
+
@connection.stop
|
88
|
+
else
|
89
|
+
@channel.send_message_to_server('close')
|
90
|
+
end
|
82
91
|
end
|
83
92
|
|
84
93
|
def shell(command)
|
@@ -86,60 +95,10 @@ module Playwright
|
|
86
95
|
Base64.strict_decode64(resp)
|
87
96
|
end
|
88
97
|
|
89
|
-
def launch_browser(
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
colorScheme: nil,
|
94
|
-
deviceScaleFactor: nil,
|
95
|
-
extraHTTPHeaders: nil,
|
96
|
-
geolocation: nil,
|
97
|
-
hasTouch: nil,
|
98
|
-
httpCredentials: nil,
|
99
|
-
ignoreHTTPSErrors: nil,
|
100
|
-
isMobile: nil,
|
101
|
-
javaScriptEnabled: nil,
|
102
|
-
locale: nil,
|
103
|
-
noViewport: nil,
|
104
|
-
offline: nil,
|
105
|
-
permissions: nil,
|
106
|
-
proxy: nil,
|
107
|
-
record_har_omit_content: nil,
|
108
|
-
record_har_path: nil,
|
109
|
-
record_video_dir: nil,
|
110
|
-
record_video_size: nil,
|
111
|
-
storageState: nil,
|
112
|
-
timezoneId: nil,
|
113
|
-
userAgent: nil,
|
114
|
-
viewport: nil,
|
115
|
-
&block)
|
116
|
-
params = {
|
117
|
-
pkg: pkg,
|
118
|
-
acceptDownloads: acceptDownloads,
|
119
|
-
bypassCSP: bypassCSP,
|
120
|
-
colorScheme: colorScheme,
|
121
|
-
deviceScaleFactor: deviceScaleFactor,
|
122
|
-
extraHTTPHeaders: extraHTTPHeaders,
|
123
|
-
geolocation: geolocation,
|
124
|
-
hasTouch: hasTouch,
|
125
|
-
httpCredentials: httpCredentials,
|
126
|
-
ignoreHTTPSErrors: ignoreHTTPSErrors,
|
127
|
-
isMobile: isMobile,
|
128
|
-
javaScriptEnabled: javaScriptEnabled,
|
129
|
-
locale: locale,
|
130
|
-
noViewport: noViewport,
|
131
|
-
offline: offline,
|
132
|
-
permissions: permissions,
|
133
|
-
proxy: proxy,
|
134
|
-
record_har_omit_content: record_har_omit_content,
|
135
|
-
record_har_path: record_har_path,
|
136
|
-
record_video_dir: record_video_dir,
|
137
|
-
record_video_size: record_video_size,
|
138
|
-
storageState: storageState,
|
139
|
-
timezoneId: timezoneId,
|
140
|
-
userAgent: userAgent,
|
141
|
-
viewport: viewport,
|
142
|
-
}.compact
|
98
|
+
def launch_browser(pkg: nil, **options, &block)
|
99
|
+
params = options.dup
|
100
|
+
params[:pkg] = pkg
|
101
|
+
params.compact!
|
143
102
|
prepare_browser_context_options(params)
|
144
103
|
|
145
104
|
resp = @channel.send_message_to_server('launchBrowser', params)
|
@@ -58,6 +58,12 @@ module Playwright
|
|
58
58
|
ChannelOwners::Page.from_nullable(params['page']),
|
59
59
|
)
|
60
60
|
})
|
61
|
+
set_event_to_subscription_mapping({
|
62
|
+
Events::BrowserContext::Request => "request",
|
63
|
+
Events::BrowserContext::Response => "response",
|
64
|
+
Events::BrowserContext::RequestFinished => "requestFinished",
|
65
|
+
Events::BrowserContext::RequestFailed => "requestFailed",
|
66
|
+
})
|
61
67
|
|
62
68
|
@closed_promise = Concurrent::Promises.resolvable_future
|
63
69
|
end
|
@@ -76,10 +76,17 @@ module Playwright
|
|
76
76
|
nil
|
77
77
|
end
|
78
78
|
|
79
|
-
def hover(
|
79
|
+
def hover(
|
80
|
+
force: nil,
|
81
|
+
modifiers: nil,
|
82
|
+
noWaitAfter: nil,
|
83
|
+
position: nil,
|
84
|
+
timeout: nil,
|
85
|
+
trial: nil)
|
80
86
|
params = {
|
81
87
|
force: force,
|
82
88
|
modifiers: modifiers,
|
89
|
+
noWaitAfter: noWaitAfter,
|
83
90
|
position: position,
|
84
91
|
timeout: timeout,
|
85
92
|
trial: trial,
|