playwright-ruby-client 1.20.2 → 1.23.0
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/api_request_context.md +15 -2
- data/documentation/docs/api/browser.md +16 -0
- data/documentation/docs/api/browser_context.md +15 -2
- data/documentation/docs/api/browser_type.md +5 -1
- data/documentation/docs/api/console_message.md +27 -1
- data/documentation/docs/api/element_handle.md +23 -13
- data/documentation/docs/api/experimental/android.md +1 -1
- data/documentation/docs/api/experimental/android_device.md +4 -0
- data/documentation/docs/api/file_chooser.md +1 -1
- data/documentation/docs/api/frame.md +12 -5
- data/documentation/docs/api/frame_locator.md +1 -1
- data/documentation/docs/api/locator.md +44 -13
- data/documentation/docs/api/page.md +32 -9
- data/documentation/docs/api/request.md +3 -1
- data/documentation/docs/api/response.md +12 -1
- data/documentation/docs/api/route.md +67 -0
- data/documentation/docs/include/api_coverage.md +6 -3
- data/documentation/package.json +6 -6
- data/documentation/yarn.lock +2931 -3220
- data/lib/playwright/channel.rb +1 -3
- data/lib/playwright/channel_owners/browser.rb +13 -0
- data/lib/playwright/channel_owners/browser_context.rb +89 -13
- data/lib/playwright/channel_owners/browser_type.rb +4 -0
- data/lib/playwright/channel_owners/element_handle.rb +12 -3
- data/lib/playwright/channel_owners/frame.rb +20 -7
- data/lib/playwright/channel_owners/local_utils.rb +29 -0
- data/lib/playwright/channel_owners/page.rb +54 -22
- data/lib/playwright/channel_owners/request.rb +31 -6
- data/lib/playwright/channel_owners/response.rb +6 -0
- data/lib/playwright/channel_owners/route.rb +104 -45
- data/lib/playwright/channel_owners/writable_stream.rb +14 -0
- data/lib/playwright/connection.rb +6 -1
- data/lib/playwright/har_router.rb +82 -0
- data/lib/playwright/http_headers.rb +1 -1
- data/lib/playwright/input_files.rb +60 -8
- data/lib/playwright/javascript/regex.rb +23 -0
- data/lib/playwright/javascript/value_parser.rb +17 -2
- data/lib/playwright/javascript/value_serializer.rb +16 -6
- data/lib/playwright/javascript/visitor_info.rb +26 -0
- data/lib/playwright/javascript.rb +1 -0
- data/lib/playwright/locator_impl.rb +18 -5
- data/lib/playwright/playwright_api.rb +26 -6
- data/lib/playwright/route_handler.rb +2 -6
- data/lib/playwright/transport.rb +12 -2
- data/lib/playwright/utils.rb +31 -6
- data/lib/playwright/version.rb +2 -2
- data/lib/playwright.rb +2 -0
- data/lib/playwright_api/accessibility.rb +2 -1
- data/lib/playwright_api/android.rb +2 -2
- data/lib/playwright_api/android_device.rb +5 -1
- data/lib/playwright_api/api_request.rb +3 -3
- data/lib/playwright_api/api_request_context.rb +15 -2
- data/lib/playwright_api/browser.rb +15 -2
- data/lib/playwright_api/browser_context.rb +17 -7
- data/lib/playwright_api/browser_type.rb +7 -3
- data/lib/playwright_api/console_message.rb +20 -1
- data/lib/playwright_api/element_handle.rb +53 -49
- data/lib/playwright_api/file_chooser.rb +1 -1
- data/lib/playwright_api/frame.rb +30 -23
- data/lib/playwright_api/frame_locator.rb +1 -1
- data/lib/playwright_api/locator.rb +58 -38
- data/lib/playwright_api/page.rb +52 -32
- data/lib/playwright_api/playwright.rb +1 -1
- data/lib/playwright_api/request.rb +8 -1
- data/lib/playwright_api/response.rb +14 -1
- data/lib/playwright_api/route.rb +63 -2
- data/lib/playwright_api/selectors.rb +1 -1
- data/lib/playwright_api/tracing.rb +1 -1
- metadata +7 -4
- data/lib/playwright_api/local_utils.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d8cc3ad6fb1bd9c8a42f249085e91f92dbed26ebcbbd310559810299b60ea31
|
4
|
+
data.tar.gz: 6fb3450345d6f7bcbcbb19e3206244739f8aecf0813a94216e58df03674fb8e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4e12e990b3a9df4532154ad62d6064c343664b75d8f29d088e6c28c00b5f22608d3de49c3568af2e2ac8689e9d9769e478e36571e7921d928c21eb3a18d9a56
|
7
|
+
data.tar.gz: 49f939af824f3affd9bbb011eb389238d5484a3f320fed6ad170bfb8c011ac351f6dba239f4e685d6b9058f4b72461fd5d1b5aee98835e34948eeef90b535dbc
|
@@ -5,10 +5,23 @@ sidebar_position: 10
|
|
5
5
|
# APIRequestContext
|
6
6
|
|
7
7
|
This API is used for the Web API testing. You can use it to trigger API endpoints, configure micro-services, prepare
|
8
|
-
environment or the service to your e2e test.
|
9
|
-
|
8
|
+
environment or the service to your e2e test.
|
9
|
+
|
10
|
+
Each Playwright browser context has associated with it [APIRequestContext](./api_request_context) instance which shares cookie storage with the
|
11
|
+
browser context and can be accessed via [BrowserContext#request](./browser_context#request) or [Page#request](./page#request). It is also
|
12
|
+
possible to create a new APIRequestContext instance manually by calling [APIRequest#new_context](./api_request#new_context).
|
13
|
+
|
14
|
+
**Cookie management**
|
15
|
+
|
16
|
+
[APIRequestContext](./api_request_context) retuned by [BrowserContext#request](./browser_context#request) and [Page#request](./page#request) shares cookie storage
|
17
|
+
with the corresponding [BrowserContext](./browser_context). Each API request will have `Cookie` header populated with the values from the
|
18
|
+
browser context. If the API response contains `Set-Cookie` header it will automatically update [BrowserContext](./browser_context) cookies
|
19
|
+
and requests made from the page will pick them up. This means that if you log in using this API, your e2e test will be
|
10
20
|
logged in and vice versa.
|
11
21
|
|
22
|
+
If you want API requests to not interfere with the browser cookies you shoud create a new [APIRequestContext](./api_request_context) by calling
|
23
|
+
[APIRequest#new_context](./api_request#new_context). Such [APIRequestContext](./api_request_context) object will have its own isolated cookie storage.
|
24
|
+
|
12
25
|
```ruby
|
13
26
|
playwright.chromium.launch do |browser|
|
14
27
|
# This will launch a new browser, create a context and page. When making HTTP
|
@@ -21,6 +21,14 @@ end
|
|
21
21
|
|
22
22
|
|
23
23
|
|
24
|
+
## browser_type
|
25
|
+
|
26
|
+
```
|
27
|
+
def browser_type
|
28
|
+
```
|
29
|
+
|
30
|
+
Get the browser type (chromium, firefox or webkit) that the browser belongs to.
|
31
|
+
|
24
32
|
## close
|
25
33
|
|
26
34
|
```
|
@@ -93,12 +101,16 @@ def new_context(
|
|
93
101
|
offline: nil,
|
94
102
|
permissions: nil,
|
95
103
|
proxy: nil,
|
104
|
+
record_har_content: nil,
|
105
|
+
record_har_mode: nil,
|
96
106
|
record_har_omit_content: nil,
|
97
107
|
record_har_path: nil,
|
108
|
+
record_har_url_filter: nil,
|
98
109
|
record_video_dir: nil,
|
99
110
|
record_video_size: nil,
|
100
111
|
reducedMotion: nil,
|
101
112
|
screen: nil,
|
113
|
+
serviceWorkers: nil,
|
102
114
|
storageState: nil,
|
103
115
|
strictSelectors: nil,
|
104
116
|
timezoneId: nil,
|
@@ -144,12 +156,16 @@ def new_page(
|
|
144
156
|
offline: nil,
|
145
157
|
permissions: nil,
|
146
158
|
proxy: nil,
|
159
|
+
record_har_content: nil,
|
160
|
+
record_har_mode: nil,
|
147
161
|
record_har_omit_content: nil,
|
148
162
|
record_har_path: nil,
|
163
|
+
record_har_url_filter: nil,
|
149
164
|
record_video_dir: nil,
|
150
165
|
record_video_size: nil,
|
151
166
|
reducedMotion: nil,
|
152
167
|
screen: nil,
|
168
|
+
serviceWorkers: nil,
|
153
169
|
storageState: nil,
|
154
170
|
strictSelectors: nil,
|
155
171
|
timezoneId: nil,
|
@@ -271,9 +271,9 @@ def route(url, handler, times: nil)
|
|
271
271
|
Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
|
272
272
|
is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
|
273
273
|
|
274
|
-
> NOTE: [
|
274
|
+
> NOTE: [BrowserContext#route](./browser_context#route) will not intercept requests intercepted by Service Worker. See
|
275
275
|
[this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using
|
276
|
-
request interception
|
276
|
+
request interception by setting `Browser.newContext.serviceWorkers` to `'block'`.
|
277
277
|
|
278
278
|
An example of a naive handler that aborts all image requests:
|
279
279
|
|
@@ -315,6 +315,19 @@ To remove a route with its handler you can use [BrowserContext#unroute](./browse
|
|
315
315
|
|
316
316
|
> NOTE: Enabling routing disables http cache.
|
317
317
|
|
318
|
+
## route_from_har
|
319
|
+
|
320
|
+
```
|
321
|
+
def route_from_har(har, notFound: nil, update: nil, url: nil)
|
322
|
+
```
|
323
|
+
|
324
|
+
If specified the network requests that are made in the context will be served from the HAR file. Read more about
|
325
|
+
[Replaying from HAR](https://playwright.dev/python/docs/network).
|
326
|
+
|
327
|
+
Playwright will not serve requests intercepted by Service Worker from the HAR file. See
|
328
|
+
[this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using
|
329
|
+
request interception by setting `Browser.newContext.serviceWorkers` to `'block'`.
|
330
|
+
|
318
331
|
## service_workers
|
319
332
|
|
320
333
|
```
|
@@ -31,7 +31,7 @@ def connect_over_cdp(
|
|
31
31
|
&block)
|
32
32
|
```
|
33
33
|
|
34
|
-
This
|
34
|
+
This method attaches Playwright to an existing browser instance using the Chrome DevTools Protocol.
|
35
35
|
|
36
36
|
The default browser context is accessible via [Browser#contexts](./browser#contexts).
|
37
37
|
|
@@ -131,12 +131,16 @@ def launch_persistent_context(
|
|
131
131
|
offline: nil,
|
132
132
|
permissions: nil,
|
133
133
|
proxy: nil,
|
134
|
+
record_har_content: nil,
|
135
|
+
record_har_mode: nil,
|
134
136
|
record_har_omit_content: nil,
|
135
137
|
record_har_path: nil,
|
138
|
+
record_har_url_filter: nil,
|
136
139
|
record_video_dir: nil,
|
137
140
|
record_video_size: nil,
|
138
141
|
reducedMotion: nil,
|
139
142
|
screen: nil,
|
143
|
+
serviceWorkers: nil,
|
140
144
|
slowMo: nil,
|
141
145
|
strictSelectors: nil,
|
142
146
|
timeout: nil,
|
@@ -4,7 +4,33 @@ sidebar_position: 10
|
|
4
4
|
|
5
5
|
# ConsoleMessage
|
6
6
|
|
7
|
-
[ConsoleMessage](./console_message) objects are dispatched by page via the [`event: Page.console`] event.
|
7
|
+
[ConsoleMessage](./console_message) objects are dispatched by page via the [`event: Page.console`] event. For each console messages logged
|
8
|
+
in the page there will be corresponding event in the Playwright context.
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
# Listen for all console logs
|
12
|
+
page.on("console", ->(msg) { puts msg.text })
|
13
|
+
|
14
|
+
# Listen for all console events and handle errors
|
15
|
+
page.on("console", ->(msg) {
|
16
|
+
if msg.type == 'error'
|
17
|
+
puts "error: #{msg.text}"
|
18
|
+
end
|
19
|
+
})
|
20
|
+
|
21
|
+
# Get the next console log
|
22
|
+
msg = page.expect_console_message do
|
23
|
+
# Issue console.log inside the page
|
24
|
+
page.evaluate("console.error('hello', 42, { foo: 'bar' })")
|
25
|
+
end
|
26
|
+
|
27
|
+
# Deconstruct print arguments
|
28
|
+
msg.args[0].json_value # => 'hello'
|
29
|
+
msg.args[1].json_value # => 42
|
30
|
+
msg.args[2].json_value # => { 'foo' => 'bar' }
|
31
|
+
```
|
32
|
+
|
33
|
+
|
8
34
|
|
9
35
|
## args
|
10
36
|
|
@@ -330,7 +330,10 @@ Returns the `element.innerText`.
|
|
330
330
|
def input_value(timeout: nil)
|
331
331
|
```
|
332
332
|
|
333
|
-
Returns `input.value` for `<input>` or `<textarea>` or `<select>` element.
|
333
|
+
Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element.
|
334
|
+
|
335
|
+
Throws for non-input elements. However, if the element is inside the `<label>` element that has an associated
|
336
|
+
[control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), returns the value of the control.
|
334
337
|
|
335
338
|
## checked?
|
336
339
|
|
@@ -436,19 +439,25 @@ The method finds all elements matching the specified selector in the [ElementHan
|
|
436
439
|
```
|
437
440
|
def screenshot(
|
438
441
|
animations: nil,
|
442
|
+
caret: nil,
|
439
443
|
mask: nil,
|
440
444
|
omitBackground: nil,
|
441
445
|
path: nil,
|
442
446
|
quality: nil,
|
447
|
+
scale: nil,
|
443
448
|
timeout: nil,
|
444
449
|
type: nil)
|
445
450
|
```
|
446
451
|
|
447
|
-
|
452
|
+
This method captures a screenshot of the page, clipped to the size and position of this particular element. If the
|
453
|
+
element is covered by other elements, it will not be actually visible on the screenshot. If the element is a scrollable
|
454
|
+
container, only the currently scrolled content will be visible on the screenshot.
|
448
455
|
|
449
456
|
This method waits for the [actionability](https://playwright.dev/python/docs/actionability) checks, then scrolls element into view before taking a
|
450
457
|
screenshot. If the element is detached from DOM, the method throws an error.
|
451
458
|
|
459
|
+
Returns the buffer with the captured screenshot.
|
460
|
+
|
452
461
|
## scroll_into_view_if_needed
|
453
462
|
|
454
463
|
```
|
@@ -495,11 +504,6 @@ element_handle.select_option(label: "blue")
|
|
495
504
|
element_handle.select_option(value: ["red", "green", "blue"])
|
496
505
|
```
|
497
506
|
|
498
|
-
```ruby
|
499
|
-
# multiple selection for blue, red and second option
|
500
|
-
element_handle.select_option(value: "blue", index: 2, label: "red")
|
501
|
-
```
|
502
|
-
|
503
507
|
|
504
508
|
|
505
509
|
## select_text
|
@@ -511,6 +515,10 @@ def select_text(force: nil, timeout: nil)
|
|
511
515
|
This method waits for [actionability](https://playwright.dev/python/docs/actionability) checks, then focuses the element and selects all its text
|
512
516
|
content.
|
513
517
|
|
518
|
+
If the element is inside the `<label>` element that has an associated
|
519
|
+
[control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), focuses and selects text in the
|
520
|
+
control instead.
|
521
|
+
|
514
522
|
## set_checked
|
515
523
|
|
516
524
|
```
|
@@ -544,11 +552,13 @@ def set_input_files(files, noWaitAfter: nil, timeout: nil)
|
|
544
552
|
```
|
545
553
|
alias: `input_files=`
|
546
554
|
|
547
|
-
This method expects `elementHandle` to point to an
|
548
|
-
[input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
|
549
|
-
|
550
555
|
Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
|
551
|
-
are resolved relative to the
|
556
|
+
are resolved relative to the current working directory. For empty array, clears the selected files.
|
557
|
+
|
558
|
+
This method expects [ElementHandle](./element_handle) to point to an
|
559
|
+
[input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). However, if the element is inside the
|
560
|
+
`<label>` element that has an associated
|
561
|
+
[control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), targets the control instead.
|
552
562
|
|
553
563
|
## tap_point
|
554
564
|
|
@@ -641,8 +651,8 @@ def wait_for_element_state(state, timeout: nil)
|
|
641
651
|
|
642
652
|
Returns when the element satisfies the `state`.
|
643
653
|
|
644
|
-
Depending on the `state` parameter, this method waits for one of the [actionability](https://playwright.dev/python/docs/actionability) checks to
|
645
|
-
This method throws when the element is detached while waiting, unless waiting for the `"hidden"` state.
|
654
|
+
Depending on the `state` parameter, this method waits for one of the [actionability](https://playwright.dev/python/docs/actionability) checks to
|
655
|
+
pass. This method throws when the element is detached while waiting, unless waiting for the `"hidden"` state.
|
646
656
|
- `"visible"` Wait until the element is [visible](https://playwright.dev/python/docs/actionability).
|
647
657
|
- `"hidden"` Wait until the element is [not visible](https://playwright.dev/python/docs/actionability) or
|
648
658
|
[not attached](https://playwright.dev/python/docs/actionability). Note that waiting for hidden does not throw when the element detaches.
|
@@ -45,12 +45,16 @@ def launch_browser(
|
|
45
45
|
noViewport: nil,
|
46
46
|
offline: nil,
|
47
47
|
permissions: nil,
|
48
|
+
record_har_content: nil,
|
49
|
+
record_har_mode: nil,
|
48
50
|
record_har_omit_content: nil,
|
49
51
|
record_har_path: nil,
|
52
|
+
record_har_url_filter: nil,
|
50
53
|
record_video_dir: nil,
|
51
54
|
record_video_size: nil,
|
52
55
|
reducedMotion: nil,
|
53
56
|
screen: nil,
|
57
|
+
serviceWorkers: nil,
|
54
58
|
strictSelectors: nil,
|
55
59
|
timezoneId: nil,
|
56
60
|
userAgent: nil,
|
@@ -47,4 +47,4 @@ def set_files(files, noWaitAfter: nil, timeout: nil)
|
|
47
47
|
alias: `files=`
|
48
48
|
|
49
49
|
Sets the value of the file input this chooser is associated with. If some of the `filePaths` are relative paths, then
|
50
|
-
they are resolved relative to the
|
50
|
+
they are resolved relative to the current working directory. For empty array, clears the selected files.
|
@@ -486,7 +486,10 @@ Returns `element.innerText`.
|
|
486
486
|
def input_value(selector, strict: nil, timeout: nil)
|
487
487
|
```
|
488
488
|
|
489
|
-
Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element.
|
489
|
+
Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element.
|
490
|
+
|
491
|
+
Throws for non-input elements. However, if the element is inside the `<label>` element that has an associated
|
492
|
+
[control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), returns the value of the control.
|
490
493
|
|
491
494
|
## checked?
|
492
495
|
|
@@ -556,6 +559,8 @@ The method returns an element locator that can be used to perform actions in the
|
|
556
559
|
element immediately before performing an action, so a series of actions on the same locator can in fact be performed on
|
557
560
|
different DOM elements. That would happen if the DOM structure between those actions has changed.
|
558
561
|
|
562
|
+
[Learn more about locators](https://playwright.dev/python/docs/locators).
|
563
|
+
|
559
564
|
## name
|
560
565
|
|
561
566
|
```
|
@@ -724,11 +729,13 @@ def set_input_files(
|
|
724
729
|
timeout: nil)
|
725
730
|
```
|
726
731
|
|
727
|
-
This method expects `selector` to point to an
|
728
|
-
[input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
|
729
|
-
|
730
732
|
Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
|
731
|
-
are resolved relative to the
|
733
|
+
are resolved relative to the current working directory. For empty array, clears the selected files.
|
734
|
+
|
735
|
+
This method expects `selector` to point to an
|
736
|
+
[input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). However, if the element is inside the
|
737
|
+
`<label>` element that has an associated
|
738
|
+
[control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), targets the control instead.
|
732
739
|
|
733
740
|
## tap_point
|
734
741
|
|
@@ -285,6 +285,26 @@ instead.
|
|
285
285
|
|
286
286
|
To send fine-grained keyboard events, use [Locator#type](./locator#type).
|
287
287
|
|
288
|
+
## filter
|
289
|
+
|
290
|
+
```
|
291
|
+
def filter(has: nil, hasText: nil)
|
292
|
+
```
|
293
|
+
|
294
|
+
This method narrows existing locator according to the options, for example filters by text. It can be chained to filter
|
295
|
+
multiple times.
|
296
|
+
|
297
|
+
```ruby
|
298
|
+
row_locator = page.locator("tr")
|
299
|
+
# ...
|
300
|
+
row_locator.
|
301
|
+
filter(has_text="text in column 1").
|
302
|
+
filter(has=page.locator("tr", has_text="column 2 button")).
|
303
|
+
screenshot
|
304
|
+
```
|
305
|
+
|
306
|
+
|
307
|
+
|
288
308
|
## first
|
289
309
|
|
290
310
|
```
|
@@ -378,7 +398,10 @@ Returns the `element.innerText`.
|
|
378
398
|
def input_value(timeout: nil)
|
379
399
|
```
|
380
400
|
|
381
|
-
Returns `input.value` for `<input>` or `<textarea>` or `<select>` element.
|
401
|
+
Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element.
|
402
|
+
|
403
|
+
Throws for non-input elements. However, if the element is inside the `<label>` element that has an associated
|
404
|
+
[control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), returns the value of the control.
|
382
405
|
|
383
406
|
## checked?
|
384
407
|
|
@@ -442,7 +465,8 @@ Returns locator to the last matching element.
|
|
442
465
|
def locator(selector, has: nil, hasText: nil)
|
443
466
|
```
|
444
467
|
|
445
|
-
The method finds an element matching the specified selector in the [Locator](./locator)'s subtree.
|
468
|
+
The method finds an element matching the specified selector in the [Locator](./locator)'s subtree. It also accepts filter options,
|
469
|
+
similar to [Locator#filter](./locator#filter) method.
|
446
470
|
|
447
471
|
## nth
|
448
472
|
|
@@ -450,7 +474,7 @@ The method finds an element matching the specified selector in the [Locator](./l
|
|
450
474
|
def nth(index)
|
451
475
|
```
|
452
476
|
|
453
|
-
Returns locator to the n-th matching element.
|
477
|
+
Returns locator to the n-th matching element. It's zero based, `nth(0)` selects the first element.
|
454
478
|
|
455
479
|
## page
|
456
480
|
|
@@ -490,19 +514,25 @@ modifier, modifier is pressed and being held while the subsequent key is being p
|
|
490
514
|
```
|
491
515
|
def screenshot(
|
492
516
|
animations: nil,
|
517
|
+
caret: nil,
|
493
518
|
mask: nil,
|
494
519
|
omitBackground: nil,
|
495
520
|
path: nil,
|
496
521
|
quality: nil,
|
522
|
+
scale: nil,
|
497
523
|
timeout: nil,
|
498
524
|
type: nil)
|
499
525
|
```
|
500
526
|
|
501
|
-
|
527
|
+
This method captures a screenshot of the page, clipped to the size and position of a particular element matching the
|
528
|
+
locator. If the element is covered by other elements, it will not be actually visible on the screenshot. If the element
|
529
|
+
is a scrollable container, only the currently scrolled content will be visible on the screenshot.
|
502
530
|
|
503
531
|
This method waits for the [actionability](https://playwright.dev/python/docs/actionability) checks, then scrolls element into view before taking a
|
504
532
|
screenshot. If the element is detached from DOM, the method throws an error.
|
505
533
|
|
534
|
+
Returns the buffer with the captured screenshot.
|
535
|
+
|
506
536
|
## scroll_into_view_if_needed
|
507
537
|
|
508
538
|
```
|
@@ -546,11 +576,6 @@ element.select_option(label: "blue")
|
|
546
576
|
element.select_option(value: ["red", "green", "blue"])
|
547
577
|
```
|
548
578
|
|
549
|
-
```ruby
|
550
|
-
# multiple selection for blue, red and second option
|
551
|
-
element.select_option(value: "blue", index: 2, label: "red")
|
552
|
-
```
|
553
|
-
|
554
579
|
|
555
580
|
|
556
581
|
## select_text
|
@@ -562,6 +587,10 @@ def select_text(force: nil, timeout: nil)
|
|
562
587
|
This method waits for [actionability](https://playwright.dev/python/docs/actionability) checks, then focuses the element and selects all its text
|
563
588
|
content.
|
564
589
|
|
590
|
+
If the element is inside the `<label>` element that has an associated
|
591
|
+
[control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), focuses and selects text in the
|
592
|
+
control instead.
|
593
|
+
|
565
594
|
## set_checked
|
566
595
|
|
567
596
|
```
|
@@ -595,11 +624,13 @@ def set_input_files(files, noWaitAfter: nil, timeout: nil)
|
|
595
624
|
```
|
596
625
|
alias: `input_files=`
|
597
626
|
|
598
|
-
This method expects `element` to point to an
|
599
|
-
[input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
|
600
|
-
|
601
627
|
Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
|
602
|
-
are resolved relative to the
|
628
|
+
are resolved relative to the current working directory. For empty array, clears the selected files.
|
629
|
+
|
630
|
+
This method expects [Locator](./locator) to point to an
|
631
|
+
[input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). However, if the element is inside the
|
632
|
+
`<label>` element that has an associated
|
633
|
+
[control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), targets the control instead.
|
603
634
|
|
604
635
|
## tap_point
|
605
636
|
|
@@ -642,8 +642,8 @@ Navigate to the next page in history.
|
|
642
642
|
def goto(url, referer: nil, timeout: nil, waitUntil: nil)
|
643
643
|
```
|
644
644
|
|
645
|
-
Returns the main resource response. In case of multiple redirects, the navigation will resolve with the
|
646
|
-
|
645
|
+
Returns the main resource response. In case of multiple redirects, the navigation will resolve with the first
|
646
|
+
non-redirect response.
|
647
647
|
|
648
648
|
The method will throw an error if:
|
649
649
|
- there's an SSL error (e.g. in case of self-signed certificates).
|
@@ -711,7 +711,10 @@ Returns `element.innerText`.
|
|
711
711
|
def input_value(selector, strict: nil, timeout: nil)
|
712
712
|
```
|
713
713
|
|
714
|
-
Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element.
|
714
|
+
Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element.
|
715
|
+
|
716
|
+
Throws for non-input elements. However, if the element is inside the `<label>` element that has an associated
|
717
|
+
[control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), returns the value of the control.
|
715
718
|
|
716
719
|
## checked?
|
717
720
|
|
@@ -781,6 +784,8 @@ The method returns an element locator that can be used to perform actions on the
|
|
781
784
|
element immediately before performing an action, so a series of actions on the same locator can in fact be performed on
|
782
785
|
different DOM elements. That would happen if the DOM structure between those actions has changed.
|
783
786
|
|
787
|
+
[Learn more about locators](https://playwright.dev/python/docs/locators).
|
788
|
+
|
784
789
|
Shortcut for main frame's [Frame#locator](./frame#locator).
|
785
790
|
|
786
791
|
## main_frame
|
@@ -970,7 +975,7 @@ Once routing is enabled, every request matching the url pattern will stall unles
|
|
970
975
|
> NOTE: The handler will only be called for the first url if the response is a redirect.
|
971
976
|
> NOTE: [Page#route](./page#route) will not intercept requests intercepted by Service Worker. See
|
972
977
|
[this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using
|
973
|
-
request interception
|
978
|
+
request interception by setting `Browser.newContext.serviceWorkers` to `'block'`.
|
974
979
|
|
975
980
|
An example of a naive handler that aborts all image requests:
|
976
981
|
|
@@ -1008,17 +1013,32 @@ To remove a route with its handler you can use [Page#unroute](./page#unroute).
|
|
1008
1013
|
|
1009
1014
|
> NOTE: Enabling routing disables http cache.
|
1010
1015
|
|
1016
|
+
## route_from_har
|
1017
|
+
|
1018
|
+
```
|
1019
|
+
def route_from_har(har, notFound: nil, update: nil, url: nil)
|
1020
|
+
```
|
1021
|
+
|
1022
|
+
If specified the network requests that are made in the page will be served from the HAR file. Read more about
|
1023
|
+
[Replaying from HAR](https://playwright.dev/python/docs/network).
|
1024
|
+
|
1025
|
+
Playwright will not serve requests intercepted by Service Worker from the HAR file. See
|
1026
|
+
[this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using
|
1027
|
+
request interception by setting `Browser.newContext.serviceWorkers` to `'block'`.
|
1028
|
+
|
1011
1029
|
## screenshot
|
1012
1030
|
|
1013
1031
|
```
|
1014
1032
|
def screenshot(
|
1015
1033
|
animations: nil,
|
1034
|
+
caret: nil,
|
1016
1035
|
clip: nil,
|
1017
1036
|
fullPage: nil,
|
1018
1037
|
mask: nil,
|
1019
1038
|
omitBackground: nil,
|
1020
1039
|
path: nil,
|
1021
1040
|
quality: nil,
|
1041
|
+
scale: nil,
|
1022
1042
|
timeout: nil,
|
1023
1043
|
type: nil)
|
1024
1044
|
```
|
@@ -1153,11 +1173,13 @@ def set_input_files(
|
|
1153
1173
|
timeout: nil)
|
1154
1174
|
```
|
1155
1175
|
|
1156
|
-
This method expects `selector` to point to an
|
1157
|
-
[input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
|
1158
|
-
|
1159
1176
|
Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
|
1160
|
-
are resolved relative to the
|
1177
|
+
are resolved relative to the current working directory. For empty array, clears the selected files.
|
1178
|
+
|
1179
|
+
This method expects `selector` to point to an
|
1180
|
+
[input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). However, if the element is inside the
|
1181
|
+
`<label>` element that has an associated
|
1182
|
+
[control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), targets the control instead.
|
1161
1183
|
|
1162
1184
|
## set_viewport_size
|
1163
1185
|
|
@@ -1606,6 +1628,7 @@ associated with the page.
|
|
1606
1628
|
|
1607
1629
|
## request
|
1608
1630
|
|
1609
|
-
API testing helper associated with this page.
|
1631
|
+
API testing helper associated with this page. This method returns the same instance as
|
1632
|
+
[BrowserContext#request](./browser_context#request) on the page's context. See [BrowserContext#request](./browser_context#request) for more details.
|
1610
1633
|
|
1611
1634
|
## touchscreen
|
@@ -56,7 +56,9 @@ Returns the [Frame](./frame) that initiated this request.
|
|
56
56
|
def headers
|
57
57
|
```
|
58
58
|
|
59
|
-
|
59
|
+
An object with the request HTTP headers. The header names are lower-cased. Note that this method does not return
|
60
|
+
security-related headers, including cookie-related ones. You can use [Request#all_headers](./request#all_headers) for complete list of
|
61
|
+
headers that include `cookie` information.
|
60
62
|
|
61
63
|
## headers_array
|
62
64
|
|
@@ -38,13 +38,24 @@ def frame
|
|
38
38
|
|
39
39
|
Returns the [Frame](./frame) that initiated this response.
|
40
40
|
|
41
|
+
## from_service_worker
|
42
|
+
|
43
|
+
```
|
44
|
+
def from_service_worker
|
45
|
+
```
|
46
|
+
|
47
|
+
Indicates whether this Response was fullfilled by a Service Worker's Fetch Handler (i.e. via
|
48
|
+
[FetchEvent.respondWith](https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent/respondWith)).
|
49
|
+
|
41
50
|
## headers
|
42
51
|
|
43
52
|
```
|
44
53
|
def headers
|
45
54
|
```
|
46
55
|
|
47
|
-
|
56
|
+
An object with the response HTTP headers. The header names are lower-cased. Note that this method does not return
|
57
|
+
security-related headers, including cookie-related ones. You can use [Response#all_headers](./response#all_headers) for complete list
|
58
|
+
of headers that include `cookie` information.
|
48
59
|
|
49
60
|
## headers_array
|
50
61
|
|