playwright-ruby-client 1.16.0 → 1.17.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/api_request.md +7 -0
- data/documentation/docs/api/api_request_context.md +137 -0
- data/documentation/docs/api/api_response.md +90 -0
- data/documentation/docs/api/browser_context.md +4 -0
- data/documentation/docs/api/element_handle.md +2 -3
- data/documentation/docs/api/frame.md +30 -0
- data/documentation/docs/api/frame_locator.md +70 -0
- data/documentation/docs/api/locator.md +17 -2
- data/documentation/docs/api/page.md +33 -3
- data/documentation/docs/api/request.md +3 -3
- data/documentation/docs/api/selectors.md +1 -1
- data/documentation/docs/api/tracing.md +2 -2
- data/documentation/docs/include/api_coverage.md +42 -12
- data/lib/playwright/api_response_impl.rb +73 -0
- data/lib/playwright/channel.rb +1 -1
- data/lib/playwright/channel_owners/api_request_context.rb +232 -0
- data/lib/playwright/channel_owners/artifact.rb +1 -6
- data/lib/playwright/channel_owners/browser.rb +6 -8
- data/lib/playwright/channel_owners/browser_context.rb +3 -4
- data/lib/playwright/channel_owners/browser_type.rb +0 -1
- data/lib/playwright/channel_owners/fetch_request.rb +2 -0
- data/lib/playwright/channel_owners/frame.rb +10 -6
- data/lib/playwright/channel_owners/page.rb +17 -10
- data/lib/playwright/connection.rb +9 -0
- data/lib/playwright/frame_locator_impl.rb +49 -0
- data/lib/playwright/locator_impl.rb +13 -5
- data/lib/playwright/tracing_impl.rb +6 -9
- data/lib/playwright/version.rb +2 -2
- data/lib/playwright/video.rb +3 -0
- data/lib/playwright.rb +2 -1
- data/lib/playwright_api/android_device.rb +4 -4
- data/lib/playwright_api/api_request.rb +18 -0
- data/lib/playwright_api/api_request_context.rb +11 -8
- data/lib/playwright_api/api_response.rb +68 -0
- data/lib/playwright_api/browser_context.rb +10 -5
- data/lib/playwright_api/element_handle.rb +2 -3
- data/lib/playwright_api/frame.rb +26 -1
- data/lib/playwright_api/frame_locator.rb +51 -0
- data/lib/playwright_api/locator.rb +12 -2
- data/lib/playwright_api/page.rb +34 -4
- data/lib/playwright_api/playwright.rb +9 -4
- data/lib/playwright_api/selectors.rb +2 -2
- data/lib/playwright_api/tracing.rb +4 -4
- data/playwright.gemspec +1 -1
- metadata +14 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9407fc7093bb4cdb7539eec09b879e4bfd665626801594c764798ae41d3c7823
|
4
|
+
data.tar.gz: e6047ebe532d15fa5600986ae3fc9f42a23ea670923e1ec8fac6f6ecbb7f01c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70b935777666f43236ec9df9b8462ebebf7fb883cde2d57e167d3342a18280a86e286e99e206f47e6ee2c739f23f6afe43daa2def9ea0a322b5e09f3b36bfc81
|
7
|
+
data.tar.gz: 3392ad01696c2c22ba411d7e4821e0bf0a2f641526481201927ff6510d7bb077c9fb6b20fcafabd55e5067ff7b1153b950d6b3c532c0bd14d77b9a0b3ac7c4c0
|
@@ -8,3 +8,140 @@ This API is used for the Web API testing. You can use it to trigger API endpoint
|
|
8
8
|
environment or the service to your e2e test. When used on [Page](./page) or a [BrowserContext](./browser_context), this API will automatically use
|
9
9
|
the cookies from the corresponding [BrowserContext](./browser_context). This means that if you log in using this API, your e2e test will be
|
10
10
|
logged in and vice versa.
|
11
|
+
|
12
|
+
## delete
|
13
|
+
|
14
|
+
```
|
15
|
+
def delete(
|
16
|
+
url,
|
17
|
+
data: nil,
|
18
|
+
failOnStatusCode: nil,
|
19
|
+
form: nil,
|
20
|
+
headers: nil,
|
21
|
+
ignoreHTTPSErrors: nil,
|
22
|
+
multipart: nil,
|
23
|
+
params: nil,
|
24
|
+
timeout: nil)
|
25
|
+
```
|
26
|
+
|
27
|
+
Sends HTTP(S) [DELETE](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE) request and returns its
|
28
|
+
response. The method will populate request cookies from the context and update context cookies from the response. The
|
29
|
+
method will automatically follow redirects.
|
30
|
+
|
31
|
+
## dispose
|
32
|
+
|
33
|
+
```
|
34
|
+
def dispose
|
35
|
+
```
|
36
|
+
|
37
|
+
All responses returned by [APIRequestContext#get](./api_request_context#get) and similar methods are stored in the memory, so that you
|
38
|
+
can later call [APIResponse#body](./api_response#body). This method discards all stored responses, and makes
|
39
|
+
[APIResponse#body](./api_response#body) throw "Response disposed" error.
|
40
|
+
|
41
|
+
## fetch
|
42
|
+
|
43
|
+
```
|
44
|
+
def fetch(
|
45
|
+
urlOrRequest,
|
46
|
+
data: nil,
|
47
|
+
failOnStatusCode: nil,
|
48
|
+
form: nil,
|
49
|
+
headers: nil,
|
50
|
+
ignoreHTTPSErrors: nil,
|
51
|
+
method: nil,
|
52
|
+
multipart: nil,
|
53
|
+
params: nil,
|
54
|
+
timeout: nil)
|
55
|
+
```
|
56
|
+
|
57
|
+
Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and update
|
58
|
+
context cookies from the response. The method will automatically follow redirects.
|
59
|
+
|
60
|
+
## get
|
61
|
+
|
62
|
+
```
|
63
|
+
def get(
|
64
|
+
url,
|
65
|
+
failOnStatusCode: nil,
|
66
|
+
headers: nil,
|
67
|
+
ignoreHTTPSErrors: nil,
|
68
|
+
params: nil,
|
69
|
+
timeout: nil)
|
70
|
+
```
|
71
|
+
|
72
|
+
Sends HTTP(S) [GET](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET) request and returns its response. The
|
73
|
+
method will populate request cookies from the context and update context cookies from the response. The method will
|
74
|
+
automatically follow redirects.
|
75
|
+
|
76
|
+
## head
|
77
|
+
|
78
|
+
```
|
79
|
+
def head(
|
80
|
+
url,
|
81
|
+
failOnStatusCode: nil,
|
82
|
+
headers: nil,
|
83
|
+
ignoreHTTPSErrors: nil,
|
84
|
+
params: nil,
|
85
|
+
timeout: nil)
|
86
|
+
```
|
87
|
+
|
88
|
+
Sends HTTP(S) [HEAD](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD) request and returns its response.
|
89
|
+
The method will populate request cookies from the context and update context cookies from the response. The method will
|
90
|
+
automatically follow redirects.
|
91
|
+
|
92
|
+
## patch
|
93
|
+
|
94
|
+
```
|
95
|
+
def patch(
|
96
|
+
url,
|
97
|
+
data: nil,
|
98
|
+
failOnStatusCode: nil,
|
99
|
+
form: nil,
|
100
|
+
headers: nil,
|
101
|
+
ignoreHTTPSErrors: nil,
|
102
|
+
multipart: nil,
|
103
|
+
params: nil,
|
104
|
+
timeout: nil)
|
105
|
+
```
|
106
|
+
|
107
|
+
Sends HTTP(S) [PATCH](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH) request and returns its response.
|
108
|
+
The method will populate request cookies from the context and update context cookies from the response. The method will
|
109
|
+
automatically follow redirects.
|
110
|
+
|
111
|
+
## post
|
112
|
+
|
113
|
+
```
|
114
|
+
def post(
|
115
|
+
url,
|
116
|
+
data: nil,
|
117
|
+
failOnStatusCode: nil,
|
118
|
+
form: nil,
|
119
|
+
headers: nil,
|
120
|
+
ignoreHTTPSErrors: nil,
|
121
|
+
multipart: nil,
|
122
|
+
params: nil,
|
123
|
+
timeout: nil)
|
124
|
+
```
|
125
|
+
|
126
|
+
Sends HTTP(S) [POST](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST) request and returns its response.
|
127
|
+
The method will populate request cookies from the context and update context cookies from the response. The method will
|
128
|
+
automatically follow redirects.
|
129
|
+
|
130
|
+
## put
|
131
|
+
|
132
|
+
```
|
133
|
+
def put(
|
134
|
+
url,
|
135
|
+
data: nil,
|
136
|
+
failOnStatusCode: nil,
|
137
|
+
form: nil,
|
138
|
+
headers: nil,
|
139
|
+
ignoreHTTPSErrors: nil,
|
140
|
+
multipart: nil,
|
141
|
+
params: nil,
|
142
|
+
timeout: nil)
|
143
|
+
```
|
144
|
+
|
145
|
+
Sends HTTP(S) [PUT](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT) request and returns its response. The
|
146
|
+
method will populate request cookies from the context and update context cookies from the response. The method will
|
147
|
+
automatically follow redirects.
|
@@ -0,0 +1,90 @@
|
|
1
|
+
---
|
2
|
+
sidebar_position: 10
|
3
|
+
---
|
4
|
+
|
5
|
+
# APIResponse
|
6
|
+
|
7
|
+
[APIResponse](./api_response) class represents responses returned by [APIRequestContext#get](./api_request_context#get) and similar methods.
|
8
|
+
|
9
|
+
## body
|
10
|
+
|
11
|
+
```
|
12
|
+
def body
|
13
|
+
```
|
14
|
+
|
15
|
+
Returns the buffer with response body.
|
16
|
+
|
17
|
+
## dispose
|
18
|
+
|
19
|
+
```
|
20
|
+
def dispose
|
21
|
+
```
|
22
|
+
|
23
|
+
Disposes the body of this response. If not called then the body will stay in memory until the context closes.
|
24
|
+
|
25
|
+
## headers
|
26
|
+
|
27
|
+
```
|
28
|
+
def headers
|
29
|
+
```
|
30
|
+
|
31
|
+
An object with all the response HTTP headers associated with this response.
|
32
|
+
|
33
|
+
## headers_array
|
34
|
+
|
35
|
+
```
|
36
|
+
def headers_array
|
37
|
+
```
|
38
|
+
|
39
|
+
An array with all the request HTTP headers associated with this response. Header names are not lower-cased. Headers with
|
40
|
+
multiple entries, such as `Set-Cookie`, appear in the array multiple times.
|
41
|
+
|
42
|
+
## json
|
43
|
+
|
44
|
+
```
|
45
|
+
def json
|
46
|
+
```
|
47
|
+
|
48
|
+
Returns the JSON representation of response body.
|
49
|
+
|
50
|
+
This method will throw if the response body is not parsable via `JSON.parse`.
|
51
|
+
|
52
|
+
## ok
|
53
|
+
|
54
|
+
```
|
55
|
+
def ok
|
56
|
+
```
|
57
|
+
|
58
|
+
Contains a boolean stating whether the response was successful (status in the range 200-299) or not.
|
59
|
+
|
60
|
+
## status
|
61
|
+
|
62
|
+
```
|
63
|
+
def status
|
64
|
+
```
|
65
|
+
|
66
|
+
Contains the status code of the response (e.g., 200 for a success).
|
67
|
+
|
68
|
+
## status_text
|
69
|
+
|
70
|
+
```
|
71
|
+
def status_text
|
72
|
+
```
|
73
|
+
|
74
|
+
Contains the status text of the response (e.g. usually an "OK" for a success).
|
75
|
+
|
76
|
+
## text
|
77
|
+
|
78
|
+
```
|
79
|
+
def text
|
80
|
+
```
|
81
|
+
|
82
|
+
Returns the text representation of response body.
|
83
|
+
|
84
|
+
## url
|
85
|
+
|
86
|
+
```
|
87
|
+
def url
|
88
|
+
```
|
89
|
+
|
90
|
+
Contains the URL of the response.
|
@@ -436,4 +436,8 @@ def expect_page(predicate: nil, timeout: nil)
|
|
436
436
|
Performs action and waits for a new [Page](./page) to be created in the context. If predicate is provided, it passes [Page](./page) value into the `predicate` and waits for `predicate.call(page)` to return a truthy value. Will throw an error if
|
437
437
|
the context closes before new [Page](./page) is created.
|
438
438
|
|
439
|
+
## request
|
440
|
+
|
441
|
+
API testing helper associated with this context. Requests made with this API will use context cookies.
|
442
|
+
|
439
443
|
## tracing
|
@@ -9,6 +9,8 @@ sidebar_position: 10
|
|
9
9
|
ElementHandle represents an in-page DOM element. ElementHandles can be created with the [Page#query_selector](./page#query_selector)
|
10
10
|
method.
|
11
11
|
|
12
|
+
> NOTE: The use of ElementHandle is discouraged, use [Locator](./locator) objects and web-first assertions instead.
|
13
|
+
|
12
14
|
```ruby
|
13
15
|
href_element = page.query_selector("a")
|
14
16
|
href_element.click
|
@@ -20,9 +22,6 @@ ElementHandle prevents DOM element from garbage collection unless the handle is
|
|
20
22
|
ElementHandle instances can be used as an argument in [Page#eval_on_selector](./page#eval_on_selector) and [Page#evaluate](./page#evaluate)
|
21
23
|
methods.
|
22
24
|
|
23
|
-
> NOTE: In most cases, you would want to use the [Locator](./locator) object instead. You should only use [ElementHandle](./element_handle) if you
|
24
|
-
want to retain a handle to a particular DOM Node that you intend to pass into [Page#evaluate](./page#evaluate) as an argument.
|
25
|
-
|
26
25
|
The difference between the [Locator](./locator) and ElementHandle is that the ElementHandle points to a particular element, while
|
27
26
|
[Locator](./locator) captures the logic of how to retrieve an element.
|
28
27
|
|
@@ -218,6 +218,9 @@ def eval_on_selector(selector, expression, arg: nil, strict: nil)
|
|
218
218
|
|
219
219
|
Returns the return value of `expression`.
|
220
220
|
|
221
|
+
> NOTE: This method does not wait for the element to pass actionability checks and therefore can lead to the flaky
|
222
|
+
tests. Use [Locator#evaluate](./locator#evaluate), other [Locator](./locator) helper methods or web-first assertions instead.
|
223
|
+
|
221
224
|
The method finds an element matching the specified selector within the frame and passes it as a first argument to
|
222
225
|
`expression`. See [Working with selectors](https://playwright.dev/python/docs/selectors) for more details. If no elements match the selector, the
|
223
226
|
method throws an error.
|
@@ -243,6 +246,9 @@ def eval_on_selector_all(selector, expression, arg: nil)
|
|
243
246
|
|
244
247
|
Returns the return value of `expression`.
|
245
248
|
|
249
|
+
> NOTE: In most cases, [Locator#evaluate_all](./locator#evaluate_all), other [Locator](./locator) helper methods and web-first assertions do a
|
250
|
+
better job.
|
251
|
+
|
246
252
|
The method finds all elements matching the specified selector within the frame and passes an array of matched elements
|
247
253
|
as a first argument to `expression`. See [Working with selectors](https://playwright.dev/python/docs/selectors) for more details.
|
248
254
|
|
@@ -384,6 +390,23 @@ puts frame == content_frame # => true
|
|
384
390
|
|
385
391
|
|
386
392
|
|
393
|
+
## frame_locator
|
394
|
+
|
395
|
+
```
|
396
|
+
def frame_locator(selector)
|
397
|
+
```
|
398
|
+
|
399
|
+
When working with iframes, you can create a frame locator that will enter the iframe and allow selecting elements in
|
400
|
+
that iframe. Following snippet locates element with text "Submit" in the iframe with id `my-frame`, like `<iframe
|
401
|
+
id="my-frame">`:
|
402
|
+
|
403
|
+
```ruby
|
404
|
+
locator = frame.frame_locator("#my-iframe").locator("text=Submit")
|
405
|
+
locator.click
|
406
|
+
```
|
407
|
+
|
408
|
+
|
409
|
+
|
387
410
|
## get_attribute
|
388
411
|
|
389
412
|
```
|
@@ -598,6 +621,8 @@ def query_selector(selector, strict: nil)
|
|
598
621
|
|
599
622
|
Returns the ElementHandle pointing to the frame element.
|
600
623
|
|
624
|
+
> NOTE: The use of [ElementHandle](./element_handle) is discouraged, use [Locator](./locator) objects and web-first assertions instead.
|
625
|
+
|
601
626
|
The method finds an element matching the specified selector within the frame. See
|
602
627
|
[Working with selectors](https://playwright.dev/python/docs/selectors) for more details. If no elements match the selector, returns `null`.
|
603
628
|
|
@@ -609,6 +634,8 @@ def query_selector_all(selector)
|
|
609
634
|
|
610
635
|
Returns the ElementHandles pointing to the frame elements.
|
611
636
|
|
637
|
+
> NOTE: The use of [ElementHandle](./element_handle) is discouraged, use [Locator](./locator) objects instead.
|
638
|
+
|
612
639
|
The method finds all elements matching the specified selector within the frame. See
|
613
640
|
[Working with selectors](https://playwright.dev/python/docs/selectors) for more details. If no elements match the selector, returns empty array.
|
614
641
|
|
@@ -878,6 +905,9 @@ def wait_for_selector(selector, state: nil, strict: nil, timeout: nil)
|
|
878
905
|
Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or
|
879
906
|
`detached`.
|
880
907
|
|
908
|
+
> NOTE: Playwright automatically waits for element to be ready before performing an action. Using [Locator](./locator) objects and
|
909
|
+
web-first assertions make the code wait-for-selector-free.
|
910
|
+
|
881
911
|
Wait for the `selector` to satisfy `state` option (either appear/disappear from dom, or become visible/hidden). If at
|
882
912
|
the moment of calling the method `selector` already satisfies the condition, the method will return immediately. If the
|
883
913
|
selector doesn't satisfy the condition for the `timeout` milliseconds, the function will throw.
|
@@ -0,0 +1,70 @@
|
|
1
|
+
---
|
2
|
+
sidebar_position: 10
|
3
|
+
---
|
4
|
+
|
5
|
+
# FrameLocator
|
6
|
+
|
7
|
+
FrameLocator represents a view to the `iframe` on the page. It captures the logic sufficient to retrieve the `iframe`
|
8
|
+
and locate elements in that iframe. FrameLocator can be created with either [Page#frame_locator](./page#frame_locator) or
|
9
|
+
[Locator#frame_locator](./locator#frame_locator) method.
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
locator = page.frame_locator("my-frame").locator("text=Submit")
|
13
|
+
locator.click
|
14
|
+
```
|
15
|
+
|
16
|
+
**Strictness**
|
17
|
+
|
18
|
+
Frame locators are strict. This means that all operations on frame locators will throw if more than one element matches
|
19
|
+
given selector.
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
# Throws if there are several frames in DOM:
|
23
|
+
page.frame_locator('.result-frame').locator('button').click
|
24
|
+
|
25
|
+
# Works because we explicitly tell locator to pick the first frame:
|
26
|
+
page.frame_locator('.result-frame').first.locator('button').click
|
27
|
+
```
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
## first
|
32
|
+
|
33
|
+
```
|
34
|
+
def first
|
35
|
+
```
|
36
|
+
|
37
|
+
Returns locator to the first matching frame.
|
38
|
+
|
39
|
+
## frame_locator
|
40
|
+
|
41
|
+
```
|
42
|
+
def frame_locator(selector)
|
43
|
+
```
|
44
|
+
|
45
|
+
When working with iframes, you can create a frame locator that will enter the iframe and allow selecting elements in
|
46
|
+
that iframe.
|
47
|
+
|
48
|
+
## last
|
49
|
+
|
50
|
+
```
|
51
|
+
def last
|
52
|
+
```
|
53
|
+
|
54
|
+
Returns locator to the last matching frame.
|
55
|
+
|
56
|
+
## locator
|
57
|
+
|
58
|
+
```
|
59
|
+
def locator(selector)
|
60
|
+
```
|
61
|
+
|
62
|
+
The method finds an element matching the specified selector in the FrameLocator's subtree.
|
63
|
+
|
64
|
+
## nth
|
65
|
+
|
66
|
+
```
|
67
|
+
def nth(index)
|
68
|
+
```
|
69
|
+
|
70
|
+
Returns locator to the n-th matching frame.
|
@@ -329,6 +329,22 @@ def focus(timeout: nil)
|
|
329
329
|
|
330
330
|
Calls [focus](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the element.
|
331
331
|
|
332
|
+
## frame_locator
|
333
|
+
|
334
|
+
```
|
335
|
+
def frame_locator(selector)
|
336
|
+
```
|
337
|
+
|
338
|
+
When working with iframes, you can create a frame locator that will enter the iframe and allow selecting elements in
|
339
|
+
that iframe:
|
340
|
+
|
341
|
+
```ruby
|
342
|
+
locator = page.frame_locator("text=Submit").locator("text=Submit")
|
343
|
+
locator.click
|
344
|
+
```
|
345
|
+
|
346
|
+
|
347
|
+
|
332
348
|
## get_attribute
|
333
349
|
|
334
350
|
```
|
@@ -445,8 +461,7 @@ Returns locator to the last matching element.
|
|
445
461
|
def locator(selector)
|
446
462
|
```
|
447
463
|
|
448
|
-
The method finds an element matching the specified selector in the [Locator](./locator)'s subtree.
|
449
|
-
[Working with selectors](https://playwright.dev/python/docs/selectors) for more details.
|
464
|
+
The method finds an element matching the specified selector in the [Locator](./locator)'s subtree.
|
450
465
|
|
451
466
|
## nth
|
452
467
|
|
@@ -315,6 +315,9 @@ page.evaluate("matchMedia('(prefers-color-scheme: no-preference)').matches") # =
|
|
315
315
|
def eval_on_selector(selector, expression, arg: nil, strict: nil)
|
316
316
|
```
|
317
317
|
|
318
|
+
> NOTE: This method does not wait for the element to pass actionability checks and therefore can lead to the flaky
|
319
|
+
tests. Use [Locator#evaluate](./locator#evaluate), other [Locator](./locator) helper methods or web-first assertions instead.
|
320
|
+
|
318
321
|
The method finds an element matching the specified selector within the page and passes it as a first argument to
|
319
322
|
`expression`. If no elements match the selector, the method throws an error. Returns the value of `expression`.
|
320
323
|
|
@@ -337,6 +340,9 @@ Shortcut for main frame's [Frame#eval_on_selector](./frame#eval_on_selector).
|
|
337
340
|
def eval_on_selector_all(selector, expression, arg: nil)
|
338
341
|
```
|
339
342
|
|
343
|
+
> NOTE: In most cases, [Locator#evaluate_all](./locator#evaluate_all), other [Locator](./locator) helper methods and web-first assertions do a
|
344
|
+
better job.
|
345
|
+
|
340
346
|
The method finds all elements matching the specified selector within the page and passes an array of matched elements as
|
341
347
|
a first argument to `expression`. Returns the result of `expression` invocation.
|
342
348
|
|
@@ -575,6 +581,23 @@ frame = page.frame(url: /.*domain.*/)
|
|
575
581
|
|
576
582
|
|
577
583
|
|
584
|
+
## frame_locator
|
585
|
+
|
586
|
+
```
|
587
|
+
def frame_locator(selector)
|
588
|
+
```
|
589
|
+
|
590
|
+
When working with iframes, you can create a frame locator that will enter the iframe and allow selecting elements in
|
591
|
+
that iframe. Following snippet locates element with text "Submit" in the iframe with id `my-frame`, like `<iframe
|
592
|
+
id="my-frame">`:
|
593
|
+
|
594
|
+
```ruby
|
595
|
+
locator = page.frame_locator("#my-iframe").locator("text=Submit")
|
596
|
+
locator.click
|
597
|
+
```
|
598
|
+
|
599
|
+
|
600
|
+
|
578
601
|
## frames
|
579
602
|
|
580
603
|
```
|
@@ -905,8 +928,10 @@ page.screenshot(path: "o.png")
|
|
905
928
|
def query_selector(selector, strict: nil)
|
906
929
|
```
|
907
930
|
|
931
|
+
> NOTE: The use of [ElementHandle](./element_handle) is discouraged, use [Locator](./locator) objects and web-first assertions instead.
|
932
|
+
|
908
933
|
The method finds an element matching the specified selector within the page. If no elements match the selector, the
|
909
|
-
return value resolves to `null`. To wait for an element on the page, use [
|
934
|
+
return value resolves to `null`. To wait for an element on the page, use [Locator#wait_for](./locator#wait_for).
|
910
935
|
|
911
936
|
Shortcut for main frame's [Frame#query_selector](./frame#query_selector).
|
912
937
|
|
@@ -916,6 +941,8 @@ Shortcut for main frame's [Frame#query_selector](./frame#query_selector).
|
|
916
941
|
def query_selector_all(selector)
|
917
942
|
```
|
918
943
|
|
944
|
+
> NOTE: The use of [ElementHandle](./element_handle) is discouraged, use [Locator](./locator) objects and web-first assertions instead.
|
945
|
+
|
919
946
|
The method finds all elements matching the specified selector within the page. If no elements match the selector, the
|
920
947
|
return value resolves to `[]`.
|
921
948
|
|
@@ -927,8 +954,8 @@ Shortcut for main frame's [Frame#query_selector_all](./frame#query_selector_all)
|
|
927
954
|
def reload(timeout: nil, waitUntil: nil)
|
928
955
|
```
|
929
956
|
|
930
|
-
|
931
|
-
last redirect.
|
957
|
+
This method reloads the current page, in the same way as if the user had triggered a browser refresh. Returns the main
|
958
|
+
resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect.
|
932
959
|
|
933
960
|
## route
|
934
961
|
|
@@ -1484,6 +1511,9 @@ def wait_for_selector(selector, state: nil, strict: nil, timeout: nil)
|
|
1484
1511
|
Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or
|
1485
1512
|
`detached`.
|
1486
1513
|
|
1514
|
+
> NOTE: Playwright automatically waits for element to be ready before performing an action. Using [Locator](./locator) objects and
|
1515
|
+
web-first assertions make the code wait-for-selector-free.
|
1516
|
+
|
1487
1517
|
Wait for the `selector` to satisfy `state` option (either appear/disappear from dom, or become visible/hidden). If at
|
1488
1518
|
the moment of calling the method `selector` already satisfies the condition, the method will return immediately. If the
|
1489
1519
|
selector doesn't satisfy the condition for the `timeout` milliseconds, the function will throw.
|
@@ -127,10 +127,10 @@ def redirected_from
|
|
127
127
|
Request that was redirected by the server to this one, if any.
|
128
128
|
|
129
129
|
When the server responds with a redirect, Playwright creates a new [Request](./request) object. The two requests are connected by
|
130
|
-
|
131
|
-
construct the whole redirect chain by repeatedly calling
|
130
|
+
[redirected_from](./request#redirected_from) and [redirected_to](./request#redirected_to) methods. When multiple server redirects has happened, it is possible to
|
131
|
+
construct the whole redirect chain by repeatedly calling [redirected_from](./request#redirected_from).
|
132
132
|
|
133
|
-
For example, if the website `http://
|
133
|
+
For example, if the website `http://github.com` redirects to `https://github.com`:
|
134
134
|
|
135
135
|
```ruby
|
136
136
|
response = page.goto("http://github.com")
|
@@ -41,7 +41,7 @@ playwright.chromium.launch do |browser|
|
|
41
41
|
page.click('tag=div >> text="Click me"')
|
42
42
|
|
43
43
|
# Can use it in any methods supporting selectors.
|
44
|
-
button_count = page.
|
44
|
+
button_count = page.locator('tag=button').count
|
45
45
|
button_count # => 1
|
46
46
|
end
|
47
47
|
```
|
@@ -23,7 +23,7 @@ end
|
|
23
23
|
## start
|
24
24
|
|
25
25
|
```
|
26
|
-
def start(name: nil, screenshots: nil, snapshots: nil)
|
26
|
+
def start(name: nil, screenshots: nil, snapshots: nil, title: nil)
|
27
27
|
```
|
28
28
|
|
29
29
|
Start tracing.
|
@@ -40,7 +40,7 @@ context.tracing.stop(path: 'trace.zip')
|
|
40
40
|
## start_chunk
|
41
41
|
|
42
42
|
```
|
43
|
-
def start_chunk
|
43
|
+
def start_chunk(title: nil)
|
44
44
|
```
|
45
45
|
|
46
46
|
Start a new trace chunk. If you'd like to record multiple traces on the same [BrowserContext](./browser_context), use
|
@@ -1,17 +1,5 @@
|
|
1
1
|
# API coverages
|
2
2
|
|
3
|
-
## APIRequestContext
|
4
|
-
|
5
|
-
* ~~delete~~
|
6
|
-
* ~~dispose~~
|
7
|
-
* ~~fetch~~
|
8
|
-
* ~~get~~
|
9
|
-
* ~~head~~
|
10
|
-
* ~~patch~~
|
11
|
-
* ~~post~~
|
12
|
-
* ~~put~~
|
13
|
-
* ~~storage_state~~
|
14
|
-
|
15
3
|
## Request
|
16
4
|
|
17
5
|
* all_headers
|
@@ -167,6 +155,7 @@
|
|
167
155
|
* fill
|
168
156
|
* focus
|
169
157
|
* frame_element
|
158
|
+
* frame_locator
|
170
159
|
* get_attribute
|
171
160
|
* goto
|
172
161
|
* hover
|
@@ -264,6 +253,7 @@
|
|
264
253
|
* fill
|
265
254
|
* focus
|
266
255
|
* frame
|
256
|
+
* frame_locator
|
267
257
|
* frames
|
268
258
|
* get_attribute
|
269
259
|
* go_back
|
@@ -359,6 +349,7 @@
|
|
359
349
|
* expect_event
|
360
350
|
* expect_page
|
361
351
|
* ~~wait_for_event~~
|
352
|
+
* request
|
362
353
|
* tracing
|
363
354
|
|
364
355
|
## CDPSession
|
@@ -393,6 +384,7 @@
|
|
393
384
|
* chromium
|
394
385
|
* devices
|
395
386
|
* firefox
|
387
|
+
* ~~request~~
|
396
388
|
* selectors
|
397
389
|
* webkit
|
398
390
|
|
@@ -421,6 +413,7 @@
|
|
421
413
|
* fill
|
422
414
|
* first
|
423
415
|
* focus
|
416
|
+
* frame_locator
|
424
417
|
* get_attribute
|
425
418
|
* hover
|
426
419
|
* inner_html
|
@@ -448,6 +441,43 @@
|
|
448
441
|
* uncheck
|
449
442
|
* wait_for
|
450
443
|
|
444
|
+
## FrameLocator
|
445
|
+
|
446
|
+
* first
|
447
|
+
* frame_locator
|
448
|
+
* last
|
449
|
+
* locator
|
450
|
+
* nth
|
451
|
+
|
452
|
+
## APIResponse
|
453
|
+
|
454
|
+
* body
|
455
|
+
* dispose
|
456
|
+
* headers
|
457
|
+
* headers_array
|
458
|
+
* json
|
459
|
+
* ok
|
460
|
+
* status
|
461
|
+
* status_text
|
462
|
+
* text
|
463
|
+
* url
|
464
|
+
|
465
|
+
## APIRequestContext
|
466
|
+
|
467
|
+
* delete
|
468
|
+
* dispose
|
469
|
+
* fetch
|
470
|
+
* get
|
471
|
+
* head
|
472
|
+
* patch
|
473
|
+
* post
|
474
|
+
* put
|
475
|
+
* ~~storage_state~~
|
476
|
+
|
477
|
+
## ~~APIRequest~~
|
478
|
+
|
479
|
+
* ~~new_context~~
|
480
|
+
|
451
481
|
## Android
|
452
482
|
|
453
483
|
* devices
|