playwright-ruby-client 1.18.0 → 1.19.0
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 +167 -45
- data/documentation/docs/api/api_response.md +104 -0
- data/documentation/docs/api/browser_context.md +4 -0
- data/documentation/docs/api/frame.md +1 -1
- data/documentation/docs/api/frame_locator.md +1 -1
- data/documentation/docs/api/locator.md +10 -2
- data/documentation/docs/api/page.md +9 -1
- data/documentation/docs/api/route.md +1 -0
- data/documentation/docs/api/tracing.md +6 -1
- data/documentation/docs/include/api_coverage.md +32 -14
- data/lib/playwright/api_response_impl.rb +77 -0
- data/lib/playwright/channel_owner.rb +4 -0
- data/lib/playwright/channel_owners/api_request_context.rb +236 -0
- data/lib/playwright/channel_owners/browser_context.rb +13 -10
- data/lib/playwright/channel_owners/frame.rb +2 -2
- data/lib/playwright/channel_owners/page.rb +15 -5
- data/lib/playwright/channel_owners/route.rb +18 -4
- data/lib/playwright/{tracing_impl.rb → channel_owners/tracing.rb} +4 -8
- data/lib/playwright/frame_locator_impl.rb +2 -1
- data/lib/playwright/locator_impl.rb +42 -15
- data/lib/playwright/route_handler.rb +11 -8
- data/lib/playwright/transport.rb +1 -1
- data/lib/playwright/version.rb +2 -2
- data/lib/playwright_api/android.rb +6 -6
- data/lib/playwright_api/android_device.rb +6 -6
- data/lib/playwright_api/api_request.rb +20 -0
- data/lib/playwright_api/api_request_context.rb +16 -16
- data/lib/playwright_api/api_response.rb +81 -0
- data/lib/playwright_api/browser.rb +6 -6
- data/lib/playwright_api/browser_context.rb +9 -9
- 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 +6 -6
- data/lib/playwright_api/frame.rb +8 -8
- data/lib/playwright_api/frame_locator.rb +2 -2
- data/lib/playwright_api/js_handle.rb +6 -6
- data/lib/playwright_api/locator.rb +8 -3
- data/lib/playwright_api/page.rb +18 -18
- data/lib/playwright_api/playwright.rb +8 -8
- data/lib/playwright_api/request.rb +6 -6
- data/lib/playwright_api/response.rb +6 -6
- data/lib/playwright_api/route.rb +8 -7
- data/lib/playwright_api/selectors.rb +6 -6
- data/lib/playwright_api/tracing.rb +29 -2
- data/lib/playwright_api/web_socket.rb +6 -6
- data/lib/playwright_api/worker.rb +6 -6
- metadata +10 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfbbc528927aa551597f30f0abb057a13609726f473cfd6c625a97d135d0b705
|
4
|
+
data.tar.gz: f3f8dda3439bfaa0d3a8796ee8ed6eb453ae9934e9bf0b1768a8a0c9a62d5e4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14e62113089e96e77fd11dabdda86582ac5c4004465a4007396b71a954927396e1a77c5abf2c10199e43b41b119a5879bbdf491400ec8de5d9f1bd2b3da19ef8
|
7
|
+
data.tar.gz: 6ee4b4854cf14ba4cd1cad9dd4c847cea5dea58c892298e15daecce174754b35beccfaff8386f9c97ca103d500aeea476f82c232fa88291741d075685d2fc789
|
@@ -9,51 +9,173 @@ environment or the service to your e2e test. When used on [Page](./page) or a [B
|
|
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
11
|
|
12
|
-
```
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
with sync_playwright() as p:
|
21
|
-
# This will launch a new browser, create a context and page. When making HTTP
|
22
|
-
# requests with the internal APIRequestContext (e.g. `context.request` or `page.request`)
|
23
|
-
# it will automatically set the cookies to the browser page and vise versa.
|
24
|
-
browser = playwright.chromium.launch()
|
25
|
-
context = browser.new_context(base_url="https://api.github.com")
|
26
|
-
api_request_context = context.request
|
27
|
-
page = context.new_page()
|
28
|
-
|
29
|
-
# Alternatively you can create a APIRequestContext manually without having a browser context attached:
|
30
|
-
# api_request_context = playwright.request.new_context(base_url="https://api.github.com")
|
31
|
-
|
32
|
-
|
33
|
-
# Create a repository.
|
34
|
-
response = api_request_context.post(
|
35
|
-
"/user/repos",
|
36
|
-
headers={
|
37
|
-
"Accept": "application/vnd.github.v3+json",
|
38
|
-
# Add GitHub personal access token.
|
39
|
-
"Authorization": f"token {API_TOKEN}",
|
40
|
-
},
|
41
|
-
data={"name": REPO},
|
42
|
-
)
|
43
|
-
assert response.ok
|
44
|
-
assert response.json()["name"] == REPO
|
45
|
-
|
46
|
-
# Delete a repository.
|
47
|
-
response = api_request_context.delete(
|
48
|
-
f"/repos/{USER}/{REPO}",
|
49
|
-
headers={
|
50
|
-
"Accept": "application/vnd.github.v3+json",
|
51
|
-
# Add GitHub personal access token.
|
52
|
-
"Authorization": f"token {API_TOKEN}",
|
53
|
-
},
|
54
|
-
)
|
55
|
-
assert response.ok
|
56
|
-
assert await response.body() == '{"status": "ok"}'
|
12
|
+
```ruby
|
13
|
+
playwright.chromium.launch do |browser|
|
14
|
+
# This will launch a new browser, create a context and page. When making HTTP
|
15
|
+
# requests with the internal APIRequestContext (e.g. `context.request` or `page.request`)
|
16
|
+
# it will automatically set the cookies to the browser page and vise versa.
|
17
|
+
context = browser.new_context(base_url: 'https://api.github,com')
|
18
|
+
api_request_context = context.request
|
57
19
|
|
20
|
+
|
21
|
+
# Create a repository.
|
22
|
+
response = api_request_context.post(
|
23
|
+
"/user/repos",
|
24
|
+
headers: {
|
25
|
+
"Accept": "application/vnd.github.v3+json",
|
26
|
+
"Authorization": "Bearer #{API_TOKEN}",
|
27
|
+
},
|
28
|
+
data: { name: 'test-repo-1' },
|
29
|
+
)
|
30
|
+
response.ok? # => true
|
31
|
+
response.json['name'] # => "test-repo-1"
|
32
|
+
|
33
|
+
# Delete a repository.
|
34
|
+
response = api_request_context.delete(
|
35
|
+
"/repos/YourName/test-repo-1",
|
36
|
+
headers: {
|
37
|
+
"Accept": "application/vnd.github.v3+json",
|
38
|
+
"Authorization": "Bearer #{API_TOKEN}",
|
39
|
+
},
|
40
|
+
)
|
41
|
+
response.ok? # => true
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
45
|
+
|
46
|
+
## delete
|
47
|
+
|
48
|
+
```
|
49
|
+
def delete(
|
50
|
+
url,
|
51
|
+
data: nil,
|
52
|
+
failOnStatusCode: nil,
|
53
|
+
form: nil,
|
54
|
+
headers: nil,
|
55
|
+
ignoreHTTPSErrors: nil,
|
56
|
+
multipart: nil,
|
57
|
+
params: nil,
|
58
|
+
timeout: nil)
|
59
|
+
```
|
60
|
+
|
61
|
+
Sends HTTP(S) [DELETE](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE) request and returns its
|
62
|
+
response. The method will populate request cookies from the context and update context cookies from the response. The
|
63
|
+
method will automatically follow redirects.
|
64
|
+
|
65
|
+
## dispose
|
66
|
+
|
67
|
+
```
|
68
|
+
def dispose
|
69
|
+
```
|
70
|
+
|
71
|
+
All responses returned by [APIRequestContext#get](./api_request_context#get) and similar methods are stored in the memory, so that you
|
72
|
+
can later call [APIResponse#body](./api_response#body). This method discards all stored responses, and makes
|
73
|
+
[APIResponse#body](./api_response#body) throw "Response disposed" error.
|
74
|
+
|
75
|
+
## fetch
|
76
|
+
|
77
|
+
```
|
78
|
+
def fetch(
|
79
|
+
urlOrRequest,
|
80
|
+
data: nil,
|
81
|
+
failOnStatusCode: nil,
|
82
|
+
form: nil,
|
83
|
+
headers: nil,
|
84
|
+
ignoreHTTPSErrors: nil,
|
85
|
+
method: nil,
|
86
|
+
multipart: nil,
|
87
|
+
params: nil,
|
88
|
+
timeout: nil)
|
89
|
+
```
|
90
|
+
|
91
|
+
Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and update
|
92
|
+
context cookies from the response. The method will automatically follow redirects.
|
93
|
+
|
94
|
+
## get
|
95
|
+
|
96
|
+
```
|
97
|
+
def get(
|
98
|
+
url,
|
99
|
+
failOnStatusCode: nil,
|
100
|
+
headers: nil,
|
101
|
+
ignoreHTTPSErrors: nil,
|
102
|
+
params: nil,
|
103
|
+
timeout: nil)
|
104
|
+
```
|
105
|
+
|
106
|
+
Sends HTTP(S) [GET](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET) request and returns its response. The
|
107
|
+
method will populate request cookies from the context and update context cookies from the response. The method will
|
108
|
+
automatically follow redirects.
|
109
|
+
|
110
|
+
## head
|
111
|
+
|
112
|
+
```
|
113
|
+
def head(
|
114
|
+
url,
|
115
|
+
failOnStatusCode: nil,
|
116
|
+
headers: nil,
|
117
|
+
ignoreHTTPSErrors: nil,
|
118
|
+
params: nil,
|
119
|
+
timeout: nil)
|
120
|
+
```
|
121
|
+
|
122
|
+
Sends HTTP(S) [HEAD](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD) request and returns its response.
|
123
|
+
The method will populate request cookies from the context and update context cookies from the response. The method will
|
124
|
+
automatically follow redirects.
|
125
|
+
|
126
|
+
## patch
|
127
|
+
|
128
|
+
```
|
129
|
+
def patch(
|
130
|
+
url,
|
131
|
+
data: nil,
|
132
|
+
failOnStatusCode: nil,
|
133
|
+
form: nil,
|
134
|
+
headers: nil,
|
135
|
+
ignoreHTTPSErrors: nil,
|
136
|
+
multipart: nil,
|
137
|
+
params: nil,
|
138
|
+
timeout: nil)
|
139
|
+
```
|
140
|
+
|
141
|
+
Sends HTTP(S) [PATCH](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH) request and returns its response.
|
142
|
+
The method will populate request cookies from the context and update context cookies from the response. The method will
|
143
|
+
automatically follow redirects.
|
144
|
+
|
145
|
+
## post
|
146
|
+
|
147
|
+
```
|
148
|
+
def post(
|
149
|
+
url,
|
150
|
+
data: nil,
|
151
|
+
failOnStatusCode: nil,
|
152
|
+
form: nil,
|
153
|
+
headers: nil,
|
154
|
+
ignoreHTTPSErrors: nil,
|
155
|
+
multipart: nil,
|
156
|
+
params: nil,
|
157
|
+
timeout: nil)
|
158
|
+
```
|
159
|
+
|
160
|
+
Sends HTTP(S) [POST](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST) request and returns its response.
|
161
|
+
The method will populate request cookies from the context and update context cookies from the response. The method will
|
162
|
+
automatically follow redirects.
|
163
|
+
|
164
|
+
## put
|
165
|
+
|
166
|
+
```
|
167
|
+
def put(
|
168
|
+
url,
|
169
|
+
data: nil,
|
170
|
+
failOnStatusCode: nil,
|
171
|
+
form: nil,
|
172
|
+
headers: nil,
|
173
|
+
ignoreHTTPSErrors: nil,
|
174
|
+
multipart: nil,
|
175
|
+
params: nil,
|
176
|
+
timeout: nil)
|
58
177
|
```
|
59
178
|
|
179
|
+
Sends HTTP(S) [PUT](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT) request and returns its response. The
|
180
|
+
method will populate request cookies from the context and update context cookies from the response. The method will
|
181
|
+
automatically follow redirects.
|
@@ -0,0 +1,104 @@
|
|
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
|
+
```ruby
|
10
|
+
playwright.chromium.launch do |browser|
|
11
|
+
context = browser.new_context
|
12
|
+
response = context.request.get("https://example.com/user/repos")
|
13
|
+
|
14
|
+
response.ok? # => true
|
15
|
+
response.status # => 200
|
16
|
+
response.headers["content-type"] # => "application/json; charset=utf-8"
|
17
|
+
response.json # => { "name" => "Foo" }
|
18
|
+
response.body # => "{ \"name\" => \"Foo\" }"
|
19
|
+
end
|
20
|
+
```
|
21
|
+
|
22
|
+
|
23
|
+
## body
|
24
|
+
|
25
|
+
```
|
26
|
+
def body
|
27
|
+
```
|
28
|
+
|
29
|
+
Returns the buffer with response body.
|
30
|
+
|
31
|
+
## dispose
|
32
|
+
|
33
|
+
```
|
34
|
+
def dispose
|
35
|
+
```
|
36
|
+
|
37
|
+
Disposes the body of this response. If not called then the body will stay in memory until the context closes.
|
38
|
+
|
39
|
+
## headers
|
40
|
+
|
41
|
+
```
|
42
|
+
def headers
|
43
|
+
```
|
44
|
+
|
45
|
+
An object with all the response HTTP headers associated with this response.
|
46
|
+
|
47
|
+
## headers_array
|
48
|
+
|
49
|
+
```
|
50
|
+
def headers_array
|
51
|
+
```
|
52
|
+
|
53
|
+
An array with all the request HTTP headers associated with this response. Header names are not lower-cased. Headers with
|
54
|
+
multiple entries, such as `Set-Cookie`, appear in the array multiple times.
|
55
|
+
|
56
|
+
## json
|
57
|
+
|
58
|
+
```
|
59
|
+
def json
|
60
|
+
```
|
61
|
+
|
62
|
+
Returns the JSON representation of response body.
|
63
|
+
|
64
|
+
This method will throw if the response body is not parsable via `JSON.parse`.
|
65
|
+
|
66
|
+
## ok
|
67
|
+
|
68
|
+
```
|
69
|
+
def ok
|
70
|
+
```
|
71
|
+
|
72
|
+
Contains a boolean stating whether the response was successful (status in the range 200-299) or not.
|
73
|
+
|
74
|
+
## status
|
75
|
+
|
76
|
+
```
|
77
|
+
def status
|
78
|
+
```
|
79
|
+
|
80
|
+
Contains the status code of the response (e.g., 200 for a success).
|
81
|
+
|
82
|
+
## status_text
|
83
|
+
|
84
|
+
```
|
85
|
+
def status_text
|
86
|
+
```
|
87
|
+
|
88
|
+
Contains the status text of the response (e.g. usually an "OK" for a success).
|
89
|
+
|
90
|
+
## text
|
91
|
+
|
92
|
+
```
|
93
|
+
def text
|
94
|
+
```
|
95
|
+
|
96
|
+
Returns the text representation of response body.
|
97
|
+
|
98
|
+
## url
|
99
|
+
|
100
|
+
```
|
101
|
+
def url
|
102
|
+
```
|
103
|
+
|
104
|
+
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
|
@@ -549,7 +549,7 @@ considered not visible.
|
|
549
549
|
## locator
|
550
550
|
|
551
551
|
```
|
552
|
-
def locator(selector, hasText: nil)
|
552
|
+
def locator(selector, has: nil, hasText: nil)
|
553
553
|
```
|
554
554
|
|
555
555
|
The method returns an element locator that can be used to perform actions in the frame. Locator is resolved to the
|
@@ -311,7 +311,7 @@ When working with iframes, you can create a frame locator that will enter the if
|
|
311
311
|
that iframe:
|
312
312
|
|
313
313
|
```ruby
|
314
|
-
locator = page.frame_locator("
|
314
|
+
locator = page.frame_locator("iframe").locator("text=Submit")
|
315
315
|
locator.click
|
316
316
|
```
|
317
317
|
|
@@ -430,7 +430,7 @@ Returns locator to the last matching element.
|
|
430
430
|
## locator
|
431
431
|
|
432
432
|
```
|
433
|
-
def locator(selector, hasText: nil)
|
433
|
+
def locator(selector, has: nil, hasText: nil)
|
434
434
|
```
|
435
435
|
|
436
436
|
The method finds an element matching the specified selector in the [Locator](./locator)'s subtree.
|
@@ -443,6 +443,14 @@ def nth(index)
|
|
443
443
|
|
444
444
|
Returns locator to the n-th matching element.
|
445
445
|
|
446
|
+
## page
|
447
|
+
|
448
|
+
```
|
449
|
+
def page
|
450
|
+
```
|
451
|
+
|
452
|
+
A page this locator belongs to.
|
453
|
+
|
446
454
|
## press
|
447
455
|
|
448
456
|
```
|
@@ -774,7 +774,7 @@ considered not visible.
|
|
774
774
|
## locator
|
775
775
|
|
776
776
|
```
|
777
|
-
def locator(selector, hasText: nil)
|
777
|
+
def locator(selector, has: nil, hasText: nil)
|
778
778
|
```
|
779
779
|
|
780
780
|
The method returns an element locator that can be used to perform actions on the page. Locator is resolved to the
|
@@ -1491,6 +1491,9 @@ response = page.expect_response(/example.com\/resource/) do
|
|
1491
1491
|
page.click("input")
|
1492
1492
|
end
|
1493
1493
|
puts response.body
|
1494
|
+
puts response.ok?
|
1495
|
+
|
1496
|
+
page.wait_for_load_state # wait for request finished.
|
1494
1497
|
|
1495
1498
|
# or with a predicate
|
1496
1499
|
page.content = '<form action="https://example.com/resource"><input type="submit" /></form>'
|
@@ -1498,6 +1501,7 @@ response = page.expect_response(->(res) { res.url.start_with? 'https://example.c
|
|
1498
1501
|
page.click("input")
|
1499
1502
|
end
|
1500
1503
|
puts response.body
|
1504
|
+
puts response.ok?
|
1501
1505
|
```
|
1502
1506
|
|
1503
1507
|
|
@@ -1597,4 +1601,8 @@ associated with the page.
|
|
1597
1601
|
|
1598
1602
|
## mouse
|
1599
1603
|
|
1604
|
+
## request
|
1605
|
+
|
1606
|
+
API testing helper associated with this page. Requests made with this API will use page cookies.
|
1607
|
+
|
1600
1608
|
## touchscreen
|
@@ -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
|
@@ -331,7 +319,7 @@
|
|
331
319
|
* accessibility
|
332
320
|
* keyboard
|
333
321
|
* mouse
|
334
|
-
*
|
322
|
+
* request
|
335
323
|
* touchscreen
|
336
324
|
|
337
325
|
## BrowserContext
|
@@ -362,7 +350,7 @@
|
|
362
350
|
* expect_event
|
363
351
|
* expect_page
|
364
352
|
* ~~wait_for_event~~
|
365
|
-
*
|
353
|
+
* request
|
366
354
|
* tracing
|
367
355
|
|
368
356
|
## CDPSession
|
@@ -442,6 +430,7 @@
|
|
442
430
|
* last
|
443
431
|
* locator
|
444
432
|
* nth
|
433
|
+
* page
|
445
434
|
* press
|
446
435
|
* screenshot
|
447
436
|
* scroll_into_view_if_needed
|
@@ -466,6 +455,35 @@
|
|
466
455
|
## LocalUtils
|
467
456
|
|
468
457
|
|
458
|
+
## APIResponse
|
459
|
+
|
460
|
+
* body
|
461
|
+
* dispose
|
462
|
+
* headers
|
463
|
+
* headers_array
|
464
|
+
* json
|
465
|
+
* ok
|
466
|
+
* status
|
467
|
+
* status_text
|
468
|
+
* text
|
469
|
+
* url
|
470
|
+
|
471
|
+
## APIRequestContext
|
472
|
+
|
473
|
+
* delete
|
474
|
+
* dispose
|
475
|
+
* fetch
|
476
|
+
* get
|
477
|
+
* head
|
478
|
+
* patch
|
479
|
+
* post
|
480
|
+
* put
|
481
|
+
* ~~storage_state~~
|
482
|
+
|
483
|
+
## ~~APIRequest~~
|
484
|
+
|
485
|
+
* ~~new_context~~
|
486
|
+
|
469
487
|
## Android
|
470
488
|
|
471
489
|
* devices
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module Playwright
|
2
|
+
define_api_implementation :APIResponseImpl do
|
3
|
+
include Utils::Errors::SafeCloseError
|
4
|
+
|
5
|
+
# @params context [APIRequestContext]
|
6
|
+
# @params initializer [Hash]
|
7
|
+
def initialize(context, initializer)
|
8
|
+
@request = context
|
9
|
+
@initializer = initializer
|
10
|
+
@headers = RawHeaders.new(initializer['headers'])
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_s
|
14
|
+
"#<APIResponse url=#{url} status=#{status} status_text=#{status_text}>"
|
15
|
+
end
|
16
|
+
|
17
|
+
def url
|
18
|
+
@initializer['url']
|
19
|
+
end
|
20
|
+
|
21
|
+
def ok
|
22
|
+
(200...300).include?(status)
|
23
|
+
end
|
24
|
+
alias_method :ok?, :ok
|
25
|
+
|
26
|
+
def status
|
27
|
+
@initializer['status']
|
28
|
+
end
|
29
|
+
|
30
|
+
def status_text
|
31
|
+
@initializer['statusText']
|
32
|
+
end
|
33
|
+
|
34
|
+
def headers
|
35
|
+
@headers.headers
|
36
|
+
end
|
37
|
+
|
38
|
+
def headers_array
|
39
|
+
@headers.headers_array
|
40
|
+
end
|
41
|
+
|
42
|
+
class AlreadyDisposedError < StandardError
|
43
|
+
def initialize
|
44
|
+
super('Response has been disposed')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def body
|
49
|
+
binary = @request.channel.send_message_to_server("fetchResponseBody", fetchUid: fetch_uid)
|
50
|
+
raise AlreadyDisposedError.new unless binary
|
51
|
+
Base64.strict_decode64(binary)
|
52
|
+
rescue => err
|
53
|
+
if safe_close_error?(err)
|
54
|
+
raise AlreadyDisposedError.new
|
55
|
+
else
|
56
|
+
raise
|
57
|
+
end
|
58
|
+
end
|
59
|
+
alias_method :text, :body
|
60
|
+
|
61
|
+
def json
|
62
|
+
JSON.parse(text)
|
63
|
+
end
|
64
|
+
|
65
|
+
def dispose
|
66
|
+
@request.channel.send_message_to_server("disposeAPIResponse", fetchUid: fetch_uid)
|
67
|
+
end
|
68
|
+
|
69
|
+
private def _request
|
70
|
+
@request
|
71
|
+
end
|
72
|
+
|
73
|
+
private def fetch_uid
|
74
|
+
@initializer['fetchUid']
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -72,6 +72,10 @@ module Playwright
|
|
72
72
|
private def delete_object_from_child(guid)
|
73
73
|
@objects.delete(guid)
|
74
74
|
end
|
75
|
+
|
76
|
+
private def same_connection?(other)
|
77
|
+
@connection == other.instance_variable_get(:@connection)
|
78
|
+
end
|
75
79
|
end
|
76
80
|
|
77
81
|
class RootChannelOwner < ChannelOwner
|