playwright-ruby-client 1.28.1 → 1.29.1.alpha1
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/accessibility.md +9 -14
- data/documentation/docs/api/api_request_context.md +44 -41
- data/documentation/docs/api/api_response.md +13 -3
- data/documentation/docs/api/browser.md +24 -23
- data/documentation/docs/api/browser_context.md +71 -45
- data/documentation/docs/api/browser_type.md +21 -14
- data/documentation/docs/api/cdp_session.md +3 -5
- data/documentation/docs/api/console_message.md +7 -4
- data/documentation/docs/api/dialog.md +9 -5
- data/documentation/docs/api/download.md +19 -11
- data/documentation/docs/api/element_handle.md +125 -116
- data/documentation/docs/api/experimental/android.md +4 -5
- data/documentation/docs/api/experimental/android_device.md +11 -2
- data/documentation/docs/api/experimental/android_input.md +5 -0
- data/documentation/docs/api/file_chooser.md +6 -3
- data/documentation/docs/api/frame.md +182 -171
- data/documentation/docs/api/frame_locator.md +27 -38
- data/documentation/docs/api/js_handle.md +16 -10
- data/documentation/docs/api/keyboard.md +29 -16
- data/documentation/docs/api/locator.md +189 -140
- data/documentation/docs/api/mouse.md +9 -4
- data/documentation/docs/api/page.md +304 -289
- data/documentation/docs/api/playwright.md +8 -5
- data/documentation/docs/api/request.md +34 -15
- data/documentation/docs/api/response.md +27 -10
- data/documentation/docs/api/route.md +44 -12
- data/documentation/docs/api/selectors.md +5 -3
- data/documentation/docs/api/touchscreen.md +2 -0
- data/documentation/docs/api/tracing.md +11 -11
- data/documentation/docs/api/web_socket.md +9 -4
- data/documentation/docs/api/worker.md +12 -11
- data/documentation/docs/include/api_coverage.md +2 -0
- data/lib/playwright/channel_owners/api_request_context.rb +37 -2
- data/lib/playwright/channel_owners/browser_context.rb +22 -26
- data/lib/playwright/channel_owners/page.rb +35 -25
- data/lib/playwright/channel_owners/route.rb +28 -8
- data/lib/playwright/event_emitter.rb +6 -1
- data/lib/playwright/locator_impl.rb +8 -0
- data/lib/playwright/select_option_values.rb +2 -0
- data/lib/playwright/version.rb +2 -2
- data/lib/playwright_api/accessibility.rb +9 -13
- data/lib/playwright_api/android.rb +14 -12
- data/lib/playwright_api/android_device.rb +38 -13
- data/lib/playwright_api/android_input.rb +5 -0
- data/lib/playwright_api/android_socket.rb +4 -2
- data/lib/playwright_api/android_web_view.rb +5 -2
- data/lib/playwright_api/api_request.rb +6 -3
- data/lib/playwright_api/api_request_context.rb +52 -42
- data/lib/playwright_api/api_response.rb +13 -2
- data/lib/playwright_api/browser.rb +30 -22
- data/lib/playwright_api/browser_context.rb +82 -45
- data/lib/playwright_api/browser_type.rb +29 -19
- data/lib/playwright_api/cdp_session.rb +9 -10
- data/lib/playwright_api/console_message.rb +13 -8
- data/lib/playwright_api/dialog.rb +14 -10
- data/lib/playwright_api/download.rb +19 -9
- data/lib/playwright_api/element_handle.rb +122 -99
- data/lib/playwright_api/file_chooser.rb +6 -1
- data/lib/playwright_api/frame.rb +186 -141
- data/lib/playwright_api/frame_locator.rb +29 -32
- data/lib/playwright_api/js_handle.rb +22 -12
- data/lib/playwright_api/keyboard.rb +29 -14
- data/lib/playwright_api/locator.rb +183 -112
- data/lib/playwright_api/mouse.rb +9 -2
- data/lib/playwright_api/page.rb +307 -259
- data/lib/playwright_api/playwright.rb +17 -10
- data/lib/playwright_api/request.rb +40 -13
- data/lib/playwright_api/response.rb +33 -16
- data/lib/playwright_api/route.rb +50 -17
- data/lib/playwright_api/selectors.rb +12 -7
- data/lib/playwright_api/touchscreen.rb +2 -0
- data/lib/playwright_api/tracing.rb +17 -11
- data/lib/playwright_api/web_socket.rb +15 -10
- data/lib/playwright_api/worker.rb +20 -17
- data/playwright.gemspec +2 -2
- data/sig/playwright.rbs +559 -0
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 491e2aebdc4a8d9df333cc9e891d34e521227d7daad17179e94918e40e3ff57b
|
4
|
+
data.tar.gz: 3fd623b1194a788445eed01b72075ddb3061f1d72a9d50ae1585f767ec81716d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfa12c6fedc6fbf3137f4e38d424e17d4020df2c05f8545f16bcb303e6d31b681f3f3d134741f2e223c16b7b589d947f3c1f0735ff5ae2b298cf23fdce656ac9
|
7
|
+
data.tar.gz: f887741dc95b517b0697f17f1e4212b1f1024f2d8d69fe7ec9d5b8590780c2f45049256c26aa8dc547e0ab2f499f7c0aff76ba251b2003fdd0d8b6e5c6bc6219
|
@@ -4,9 +4,6 @@ sidebar_position: 10
|
|
4
4
|
|
5
5
|
# Accessibility
|
6
6
|
|
7
|
-
**DEPRECATED** This class is deprecated. Please use other libraries such as [Axe](https://www.deque.com/axe/) if you
|
8
|
-
need to test page accessibility. See our Node.js [guide](https://playwright.dev/docs/accessibility-testing) for
|
9
|
-
integration with Axe.
|
10
7
|
|
11
8
|
The Accessibility class provides methods for inspecting Chromium's accessibility tree. The accessibility tree is used by
|
12
9
|
assistive technology such as [screen readers](https://en.wikipedia.org/wiki/Screen_reader) or
|
@@ -15,12 +12,12 @@ assistive technology such as [screen readers](https://en.wikipedia.org/wiki/Scre
|
|
15
12
|
Accessibility is a very platform-specific thing. On different platforms, there are different screen readers that might
|
16
13
|
have wildly different output.
|
17
14
|
|
18
|
-
Rendering engines of Chromium, Firefox and WebKit have a concept of "accessibility tree", which is then translated into
|
19
|
-
|
15
|
+
Rendering engines of Chromium, Firefox and WebKit have a concept of "accessibility tree", which is then translated into different
|
16
|
+
platform-specific APIs. Accessibility namespace gives access to this Accessibility Tree.
|
20
17
|
|
21
|
-
Most of the accessibility tree gets filtered out when converting from internal browser AX Tree to Platform-specific
|
22
|
-
|
23
|
-
|
18
|
+
Most of the accessibility tree gets filtered out when converting from internal browser AX Tree to Platform-specific AX-Tree or by
|
19
|
+
assistive technologies themselves. By default, Playwright tries to approximate this filtering, exposing only the
|
20
|
+
"interesting" nodes of the tree.
|
24
21
|
|
25
22
|
## snapshot
|
26
23
|
|
@@ -28,15 +25,14 @@ only the "interesting" nodes of the tree.
|
|
28
25
|
def snapshot(interestingOnly: nil, root: nil)
|
29
26
|
```
|
30
27
|
|
31
|
-
**DEPRECATED** This method is deprecated. Please use other libraries such as [Axe](https://www.deque.com/axe/) if you
|
32
|
-
need to test page accessibility. See our Node.js [guide](https://playwright.dev/docs/accessibility-testing) for
|
33
|
-
integration with Axe.
|
34
28
|
|
35
29
|
Captures the current state of the accessibility tree. The returned object represents the root accessible node of the
|
36
30
|
page.
|
37
31
|
|
38
|
-
|
39
|
-
|
32
|
+
**NOTE**: The Chromium accessibility tree contains nodes that go unused on most platforms and by most screen readers. Playwright
|
33
|
+
will discard them as well for an easier to process tree, unless `interestingOnly` is set to `false`.
|
34
|
+
|
35
|
+
**Usage**
|
40
36
|
|
41
37
|
An example of dumping the entire accessibility tree:
|
42
38
|
|
@@ -62,4 +58,3 @@ snapshot = page.accessibility.snapshot
|
|
62
58
|
node = find_focused_node(snapshot)
|
63
59
|
puts node['name']
|
64
60
|
```
|
65
|
-
|
@@ -4,23 +4,25 @@ sidebar_position: 10
|
|
4
4
|
|
5
5
|
# APIRequestContext
|
6
6
|
|
7
|
+
|
7
8
|
This API is used for the Web API testing. You can use it to trigger API endpoints, configure micro-services, prepare
|
8
9
|
environment or the service to your e2e test.
|
9
10
|
|
10
|
-
Each Playwright browser context has associated with it [APIRequestContext](./api_request_context) instance which shares cookie storage with
|
11
|
-
browser context and can be accessed via [BrowserContext#request](./browser_context#request) or [Page#request](./page#request).
|
12
|
-
possible to create a new APIRequestContext instance manually by calling [APIRequest#new_context](./api_request#new_context).
|
11
|
+
Each Playwright browser context has associated with it [APIRequestContext](./api_request_context) instance which shares cookie storage with
|
12
|
+
the browser context and can be accessed via [BrowserContext#request](./browser_context#request) or [Page#request](./page#request).
|
13
|
+
It is also possible to create a new APIRequestContext instance manually by calling [APIRequest#new_context](./api_request#new_context).
|
13
14
|
|
14
15
|
**Cookie management**
|
15
16
|
|
16
17
|
[APIRequestContext](./api_request_context) returned by [BrowserContext#request](./browser_context#request) and [Page#request](./page#request) shares cookie
|
17
|
-
storage with the corresponding [BrowserContext](./browser_context). Each API request will have `Cookie` header populated with the
|
18
|
-
from the browser context. If the API response contains `Set-Cookie` header it will automatically update
|
19
|
-
cookies and requests made from the page will pick them up. This means that if you log in using
|
20
|
-
will be logged in and vice versa.
|
18
|
+
storage with the corresponding [BrowserContext](./browser_context). Each API request will have `Cookie` header populated with the
|
19
|
+
values from the browser context. If the API response contains `Set-Cookie` header it will automatically update
|
20
|
+
[BrowserContext](./browser_context) cookies and requests made from the page will pick them up. This means that if you log in using
|
21
|
+
this API, your e2e test will be logged in and vice versa.
|
21
22
|
|
22
23
|
If you want API requests to not interfere with the browser cookies you should create a new [APIRequestContext](./api_request_context) by
|
23
|
-
calling [APIRequest#new_context](./api_request#new_context). Such [APIRequestContext](./api_request_context) object will have its own isolated cookie
|
24
|
+
calling [APIRequest#new_context](./api_request#new_context). Such [APIRequestContext](./api_request_context) object will have its own isolated cookie
|
25
|
+
storage.
|
24
26
|
|
25
27
|
```ruby
|
26
28
|
playwright.chromium.launch do |browser|
|
@@ -55,7 +57,6 @@ playwright.chromium.launch do |browser|
|
|
55
57
|
end
|
56
58
|
```
|
57
59
|
|
58
|
-
|
59
60
|
## delete
|
60
61
|
|
61
62
|
```
|
@@ -72,9 +73,10 @@ def delete(
|
|
72
73
|
timeout: nil)
|
73
74
|
```
|
74
75
|
|
75
|
-
|
76
|
-
|
77
|
-
method will
|
76
|
+
|
77
|
+
Sends HTTP(S) [DELETE](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE) request and returns its response.
|
78
|
+
The method will populate request cookies from the context and update
|
79
|
+
context cookies from the response. The method will automatically follow redirects.
|
78
80
|
|
79
81
|
## dispose
|
80
82
|
|
@@ -82,9 +84,9 @@ method will automatically follow redirects.
|
|
82
84
|
def dispose
|
83
85
|
```
|
84
86
|
|
85
|
-
|
86
|
-
can later call [APIResponse#body](./api_response#body). This method
|
87
|
-
[APIResponse#body](./api_response#body) throw "Response disposed" error.
|
87
|
+
|
88
|
+
All responses returned by [APIRequestContext#get](./api_request_context#get) and similar methods are stored in the memory, so that you can later call [APIResponse#body](./api_response#body). This method
|
89
|
+
discards all stored responses, and makes [APIResponse#body](./api_response#body) throw "Response disposed" error.
|
88
90
|
|
89
91
|
## fetch
|
90
92
|
|
@@ -103,10 +105,11 @@ def fetch(
|
|
103
105
|
timeout: nil)
|
104
106
|
```
|
105
107
|
|
108
|
+
|
106
109
|
Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and update
|
107
|
-
context cookies from the response. The method will automatically follow redirects.
|
110
|
+
context cookies from the response. The method will automatically follow redirects. JSON objects can be passed directly to the request.
|
108
111
|
|
109
|
-
|
112
|
+
**Usage**
|
110
113
|
|
111
114
|
```ruby
|
112
115
|
data = {
|
@@ -116,8 +119,7 @@ data = {
|
|
116
119
|
api_request_context.fetch("https://example.com/api/create_book", method: 'post', data: data)
|
117
120
|
```
|
118
121
|
|
119
|
-
The common way to send file(s) in the body of a request is to encode it as form fields with `multipart/form-data`
|
120
|
-
encoding. You can achieve that with Playwright API like this:
|
122
|
+
The common way to send file(s) in the body of a request is to encode it as form fields with `multipart/form-data` encoding. You can achieve that with Playwright API like this:
|
121
123
|
|
122
124
|
```ruby
|
123
125
|
api_request_context.fetch(
|
@@ -133,8 +135,6 @@ api_request_context.fetch(
|
|
133
135
|
)
|
134
136
|
```
|
135
137
|
|
136
|
-
|
137
|
-
|
138
138
|
## get
|
139
139
|
|
140
140
|
```
|
@@ -151,9 +151,12 @@ def get(
|
|
151
151
|
timeout: nil)
|
152
152
|
```
|
153
153
|
|
154
|
-
|
155
|
-
|
156
|
-
|
154
|
+
|
155
|
+
Sends HTTP(S) [GET](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET) request and returns its response.
|
156
|
+
The method will populate request cookies from the context and update
|
157
|
+
context cookies from the response. The method will automatically follow redirects.
|
158
|
+
|
159
|
+
**Usage**
|
157
160
|
|
158
161
|
Request parameters can be configured with `params` option, they will be serialized into the URL search parameters:
|
159
162
|
|
@@ -165,8 +168,6 @@ query_params = {
|
|
165
168
|
api_request_context.get("https://example.com/api/get_text", params: query_params)
|
166
169
|
```
|
167
170
|
|
168
|
-
|
169
|
-
|
170
171
|
## head
|
171
172
|
|
172
173
|
```
|
@@ -183,9 +184,10 @@ def head(
|
|
183
184
|
timeout: nil)
|
184
185
|
```
|
185
186
|
|
187
|
+
|
186
188
|
Sends HTTP(S) [HEAD](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD) request and returns its response.
|
187
|
-
The method will populate request cookies from the context and update
|
188
|
-
automatically follow redirects.
|
189
|
+
The method will populate request cookies from the context and update
|
190
|
+
context cookies from the response. The method will automatically follow redirects.
|
189
191
|
|
190
192
|
## patch
|
191
193
|
|
@@ -203,9 +205,10 @@ def patch(
|
|
203
205
|
timeout: nil)
|
204
206
|
```
|
205
207
|
|
208
|
+
|
206
209
|
Sends HTTP(S) [PATCH](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH) request and returns its response.
|
207
|
-
The method will populate request cookies from the context and update
|
208
|
-
automatically follow redirects.
|
210
|
+
The method will populate request cookies from the context and update
|
211
|
+
context cookies from the response. The method will automatically follow redirects.
|
209
212
|
|
210
213
|
## post
|
211
214
|
|
@@ -223,9 +226,12 @@ def post(
|
|
223
226
|
timeout: nil)
|
224
227
|
```
|
225
228
|
|
229
|
+
|
226
230
|
Sends HTTP(S) [POST](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST) request and returns its response.
|
227
|
-
The method will populate request cookies from the context and update
|
228
|
-
automatically follow redirects.
|
231
|
+
The method will populate request cookies from the context and update
|
232
|
+
context cookies from the response. The method will automatically follow redirects.
|
233
|
+
|
234
|
+
**Usage**
|
229
235
|
|
230
236
|
JSON objects can be passed directly to the request:
|
231
237
|
|
@@ -237,8 +243,7 @@ data = {
|
|
237
243
|
api_request_context.post("https://example.com/api/create_book", data: data)
|
238
244
|
```
|
239
245
|
|
240
|
-
To send form data to the server use `form` option. Its value will be encoded into the request body with
|
241
|
-
`application/x-www-form-urlencoded` encoding (see below how to use `multipart/form-data` form encoding to send files):
|
246
|
+
To send form data to the server use `form` option. Its value will be encoded into the request body with `application/x-www-form-urlencoded` encoding (see below how to use `multipart/form-data` form encoding to send files):
|
242
247
|
|
243
248
|
```ruby
|
244
249
|
form_data = {
|
@@ -248,8 +253,7 @@ form_data = {
|
|
248
253
|
api_request_context.post("https://example.com/api/find_book", form: form_data)
|
249
254
|
```
|
250
255
|
|
251
|
-
The common way to send file(s) in the body of a request is to upload them as form fields with `multipart/form-data`
|
252
|
-
encoding. You can achieve that with Playwright API like this:
|
256
|
+
The common way to send file(s) in the body of a request is to upload them as form fields with `multipart/form-data` encoding. You can achieve that with Playwright API like this:
|
253
257
|
|
254
258
|
```ruby
|
255
259
|
api_request_context.post(
|
@@ -264,8 +268,6 @@ api_request_context.post(
|
|
264
268
|
)
|
265
269
|
```
|
266
270
|
|
267
|
-
|
268
|
-
|
269
271
|
## put
|
270
272
|
|
271
273
|
```
|
@@ -282,6 +284,7 @@ def put(
|
|
282
284
|
timeout: nil)
|
283
285
|
```
|
284
286
|
|
285
|
-
|
286
|
-
|
287
|
-
|
287
|
+
|
288
|
+
Sends HTTP(S) [PUT](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT) request and returns its response.
|
289
|
+
The method will populate request cookies from the context and update
|
290
|
+
context cookies from the response. The method will automatically follow redirects.
|
@@ -4,6 +4,7 @@ sidebar_position: 10
|
|
4
4
|
|
5
5
|
# APIResponse
|
6
6
|
|
7
|
+
|
7
8
|
[APIResponse](./api_response) class represents responses returned by [APIRequestContext#get](./api_request_context#get) and similar methods.
|
8
9
|
|
9
10
|
```ruby
|
@@ -19,13 +20,13 @@ playwright.chromium.launch do |browser|
|
|
19
20
|
end
|
20
21
|
```
|
21
22
|
|
22
|
-
|
23
23
|
## body
|
24
24
|
|
25
25
|
```
|
26
26
|
def body
|
27
27
|
```
|
28
28
|
|
29
|
+
|
29
30
|
Returns the buffer with response body.
|
30
31
|
|
31
32
|
## dispose
|
@@ -34,6 +35,7 @@ Returns the buffer with response body.
|
|
34
35
|
def dispose
|
35
36
|
```
|
36
37
|
|
38
|
+
|
37
39
|
Disposes the body of this response. If not called then the body will stay in memory until the context closes.
|
38
40
|
|
39
41
|
## headers
|
@@ -42,6 +44,7 @@ Disposes the body of this response. If not called then the body will stay in mem
|
|
42
44
|
def headers
|
43
45
|
```
|
44
46
|
|
47
|
+
|
45
48
|
An object with all the response HTTP headers associated with this response.
|
46
49
|
|
47
50
|
## headers_array
|
@@ -50,8 +53,9 @@ An object with all the response HTTP headers associated with this response.
|
|
50
53
|
def headers_array
|
51
54
|
```
|
52
55
|
|
53
|
-
|
54
|
-
|
56
|
+
|
57
|
+
An array with all the request HTTP headers associated with this response. Header names are not lower-cased.
|
58
|
+
Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times.
|
55
59
|
|
56
60
|
## json
|
57
61
|
|
@@ -59,6 +63,7 @@ multiple entries, such as `Set-Cookie`, appear in the array multiple times.
|
|
59
63
|
def json
|
60
64
|
```
|
61
65
|
|
66
|
+
|
62
67
|
Returns the JSON representation of response body.
|
63
68
|
|
64
69
|
This method will throw if the response body is not parsable via `JSON.parse`.
|
@@ -69,6 +74,7 @@ This method will throw if the response body is not parsable via `JSON.parse`.
|
|
69
74
|
def ok
|
70
75
|
```
|
71
76
|
|
77
|
+
|
72
78
|
Contains a boolean stating whether the response was successful (status in the range 200-299) or not.
|
73
79
|
|
74
80
|
## status
|
@@ -77,6 +83,7 @@ Contains a boolean stating whether the response was successful (status in the ra
|
|
77
83
|
def status
|
78
84
|
```
|
79
85
|
|
86
|
+
|
80
87
|
Contains the status code of the response (e.g., 200 for a success).
|
81
88
|
|
82
89
|
## status_text
|
@@ -85,6 +92,7 @@ Contains the status code of the response (e.g., 200 for a success).
|
|
85
92
|
def status_text
|
86
93
|
```
|
87
94
|
|
95
|
+
|
88
96
|
Contains the status text of the response (e.g. usually an "OK" for a success).
|
89
97
|
|
90
98
|
## text
|
@@ -93,6 +101,7 @@ Contains the status text of the response (e.g. usually an "OK" for a success).
|
|
93
101
|
def text
|
94
102
|
```
|
95
103
|
|
104
|
+
|
96
105
|
Returns the text representation of response body.
|
97
106
|
|
98
107
|
## url
|
@@ -101,4 +110,5 @@ Returns the text representation of response body.
|
|
101
110
|
def url
|
102
111
|
```
|
103
112
|
|
113
|
+
|
104
114
|
Contains the URL of the response.
|
@@ -19,14 +19,13 @@ ensure
|
|
19
19
|
end
|
20
20
|
```
|
21
21
|
|
22
|
-
|
23
|
-
|
24
22
|
## browser_type
|
25
23
|
|
26
24
|
```
|
27
25
|
def browser_type
|
28
26
|
```
|
29
27
|
|
28
|
+
|
30
29
|
Get the browser type (chromium, firefox or webkit) that the browser belongs to.
|
31
30
|
|
32
31
|
## close
|
@@ -35,15 +34,14 @@ Get the browser type (chromium, firefox or webkit) that the browser belongs to.
|
|
35
34
|
def close
|
36
35
|
```
|
37
36
|
|
37
|
+
|
38
38
|
In case this browser is obtained using [BrowserType#launch](./browser_type#launch), closes the browser and all of its pages (if any
|
39
39
|
were opened).
|
40
40
|
|
41
41
|
In case this browser is connected to, clears all created contexts belonging to this browser and disconnects from the
|
42
42
|
browser server.
|
43
43
|
|
44
|
-
|
45
|
-
any [BrowserContext](./browser_context)'s you explicitly created earlier with [Browser#new_context](./browser#new_context) **before** calling
|
46
|
-
[Browser#close](./browser#close).
|
44
|
+
**NOTE**: This is similar to force quitting the browser. Therefore, you should call [BrowserContext#close](./browser_context#close) on any [BrowserContext](./browser_context)'s you explicitly created earlier with [Browser#new_context](./browser#new_context) **before** calling [Browser#close](./browser#close).
|
47
45
|
|
48
46
|
The [Browser](./browser) object itself is considered to be disposed and cannot be used anymore.
|
49
47
|
|
@@ -53,8 +51,11 @@ The [Browser](./browser) object itself is considered to be disposed and cannot b
|
|
53
51
|
def contexts
|
54
52
|
```
|
55
53
|
|
54
|
+
|
56
55
|
Returns an array of all open browser contexts. In a newly created browser, this will return zero browser contexts.
|
57
56
|
|
57
|
+
**Usage**
|
58
|
+
|
58
59
|
```ruby
|
59
60
|
playwright.webkit.launch do |browser|
|
60
61
|
puts browser.contexts.count # => 0
|
@@ -63,14 +64,13 @@ playwright.webkit.launch do |browser|
|
|
63
64
|
end
|
64
65
|
```
|
65
66
|
|
66
|
-
|
67
|
-
|
68
67
|
## connected?
|
69
68
|
|
70
69
|
```
|
71
70
|
def connected?
|
72
71
|
```
|
73
72
|
|
73
|
+
|
74
74
|
Indicates that the browser is connected.
|
75
75
|
|
76
76
|
## new_browser_cdp_session
|
@@ -79,7 +79,8 @@ Indicates that the browser is connected.
|
|
79
79
|
def new_browser_cdp_session
|
80
80
|
```
|
81
81
|
|
82
|
-
|
82
|
+
|
83
|
+
**NOTE**: CDP Sessions are only supported on Chromium-based browsers.
|
83
84
|
|
84
85
|
Returns the newly created browser session.
|
85
86
|
|
@@ -123,12 +124,13 @@ def new_context(
|
|
123
124
|
&block)
|
124
125
|
```
|
125
126
|
|
127
|
+
|
126
128
|
Creates a new browser context. It won't share cookies/cache with other browser contexts.
|
127
129
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
130
|
+
**NOTE**: If directly using this method to create [BrowserContext](./browser_context)s, it is best practice to explicitly close the returned context via [BrowserContext#close](./browser_context#close) when your code is done with the [BrowserContext](./browser_context),
|
131
|
+
and before calling [Browser#close](./browser#close). This will ensure the `context` is closed gracefully and any artifacts—like HARs and videos—are fully flushed and saved.
|
132
|
+
|
133
|
+
**Usage**
|
132
134
|
|
133
135
|
```ruby
|
134
136
|
playwright.firefox.launch do |browser| # or "chromium.launch" or "webkit.launch".
|
@@ -141,8 +143,6 @@ playwright.firefox.launch do |browser| # or "chromium.launch" or "webkit.launch"
|
|
141
143
|
end
|
142
144
|
```
|
143
145
|
|
144
|
-
|
145
|
-
|
146
146
|
## new_page
|
147
147
|
|
148
148
|
```
|
@@ -183,6 +183,7 @@ def new_page(
|
|
183
183
|
&block)
|
184
184
|
```
|
185
185
|
|
186
|
+
|
186
187
|
Creates a new page in a new browser context. Closing this page will close the context as well.
|
187
188
|
|
188
189
|
This is a convenience API that should only be used for the single-page scenarios and short snippets. Production code and
|
@@ -195,12 +196,13 @@ testing frameworks should explicitly create [Browser#new_context](./browser#new_
|
|
195
196
|
def start_tracing(page: nil, categories: nil, path: nil, screenshots: nil)
|
196
197
|
```
|
197
198
|
|
198
|
-
> NOTE: This API controls [Chromium Tracing](https://www.chromium.org/developers/how-tos/trace-event-profiling-tool)
|
199
|
-
which is a low-level chromium-specific debugging tool. API to control [Playwright Tracing](https://playwright.dev/python/docs/trace-viewer) could be
|
200
|
-
found [here](./tracing).
|
201
199
|
|
202
|
-
|
203
|
-
|
200
|
+
**NOTE**: This API controls [Chromium Tracing](https://www.chromium.org/developers/how-tos/trace-event-profiling-tool) which is a low-level chromium-specific debugging tool. API to control [Playwright Tracing](https://playwright.dev/python/docs/trace-viewer) could be found [here](./tracing).
|
201
|
+
|
202
|
+
You can use [Browser#start_tracing](./browser#start_tracing) and [Browser#stop_tracing](./browser#stop_tracing) to create a trace file that can
|
203
|
+
be opened in Chrome DevTools performance panel.
|
204
|
+
|
205
|
+
**Usage**
|
204
206
|
|
205
207
|
```ruby
|
206
208
|
browser.start_tracing(page: page, path: "trace.json")
|
@@ -211,16 +213,14 @@ ensure
|
|
211
213
|
end
|
212
214
|
```
|
213
215
|
|
214
|
-
|
215
216
|
## stop_tracing
|
216
217
|
|
217
218
|
```
|
218
219
|
def stop_tracing
|
219
220
|
```
|
220
221
|
|
221
|
-
|
222
|
-
which is a low-level chromium-specific debugging tool. API to control [Playwright Tracing](https://playwright.dev/python/docs/trace-viewer) could be
|
223
|
-
found [here](./tracing).
|
222
|
+
|
223
|
+
**NOTE**: This API controls [Chromium Tracing](https://www.chromium.org/developers/how-tos/trace-event-profiling-tool) which is a low-level chromium-specific debugging tool. API to control [Playwright Tracing](https://playwright.dev/python/docs/trace-viewer) could be found [here](./tracing).
|
224
224
|
|
225
225
|
Returns the buffer with trace data.
|
226
226
|
|
@@ -230,4 +230,5 @@ Returns the buffer with trace data.
|
|
230
230
|
def version
|
231
231
|
```
|
232
232
|
|
233
|
+
|
233
234
|
Returns the browser version.
|