playwright-ruby-client 1.21.0 → 1.24.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/browser.md +30 -5
- data/documentation/docs/api/browser_context.md +20 -7
- data/documentation/docs/api/browser_type.md +4 -0
- data/documentation/docs/api/download.md +1 -1
- data/documentation/docs/api/element_handle.md +20 -12
- 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 +2 -2
- data/documentation/docs/api/frame.md +12 -5
- data/documentation/docs/api/locator.md +43 -13
- data/documentation/docs/api/page.md +31 -11
- 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/api/selectors.md +2 -2
- data/documentation/docs/api/tracing.md +1 -1
- data/documentation/docs/include/api_coverage.md +6 -3
- data/documentation/package.json +4 -4
- data/documentation/yarn.lock +1876 -1304
- data/lib/playwright/channel.rb +1 -3
- data/lib/playwright/channel_owners/browser.rb +13 -0
- data/lib/playwright/channel_owners/browser_context.rb +81 -13
- data/lib/playwright/channel_owners/browser_type.rb +4 -0
- data/lib/playwright/channel_owners/frame.rb +16 -2
- data/lib/playwright/channel_owners/local_utils.rb +29 -0
- data/lib/playwright/channel_owners/page.rb +43 -15
- 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/connection.rb +6 -1
- data/lib/playwright/har_router.rb +82 -0
- data/lib/playwright/http_headers.rb +1 -1
- data/lib/playwright/javascript/regex.rb +23 -0
- data/lib/playwright/javascript/value_parser.rb +21 -2
- data/lib/playwright/javascript/value_serializer.rb +18 -6
- data/lib/playwright/javascript/visitor_info.rb +26 -0
- data/lib/playwright/javascript.rb +1 -0
- data/lib/playwright/locator_impl.rb +13 -5
- data/lib/playwright/playwright_api.rb +26 -6
- data/lib/playwright/route_handler.rb +2 -6
- data/lib/playwright/utils.rb +31 -6
- data/lib/playwright/version.rb +2 -2
- data/lib/playwright.rb +2 -0
- data/lib/playwright_api/android.rb +8 -8
- data/lib/playwright_api/android_device.rb +11 -7
- data/lib/playwright_api/api_request_context.rb +6 -6
- data/lib/playwright_api/browser.rb +34 -8
- data/lib/playwright_api/browser_context.rb +21 -11
- data/lib/playwright_api/browser_type.rb +11 -7
- 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/download.rb +1 -1
- data/lib/playwright_api/element_handle.rb +26 -24
- data/lib/playwright_api/file_chooser.rb +2 -2
- data/lib/playwright_api/frame.rb +18 -11
- data/lib/playwright_api/js_handle.rb +6 -6
- data/lib/playwright_api/locator.rb +38 -19
- data/lib/playwright_api/page.rb +33 -16
- data/lib/playwright_api/playwright.rb +8 -8
- data/lib/playwright_api/request.rb +14 -7
- data/lib/playwright_api/response.rb +20 -7
- data/lib/playwright_api/route.rb +69 -8
- data/lib/playwright_api/selectors.rb +7 -7
- data/lib/playwright_api/tracing.rb +7 -7
- data/lib/playwright_api/web_socket.rb +6 -6
- data/lib/playwright_api/worker.rb +8 -8
- metadata +6 -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: 4e87b002bd3cd1dfaf592f6be37902b0a0604553d419b8b7516e0e887584125a
|
|
4
|
+
data.tar.gz: 5b956c57000f12dc8399df4382dd301a7ef1d47551782afff0fae0871892c630
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e3a418d6d40392a157016b164455e8cdc83bffb696c182d68d2ce10cb1e7315be151fb4be78e5b985871ba75ef1882be262d05c93a0b3a65a3c3b8b9c7373fb2
|
|
7
|
+
data.tar.gz: db086e5ff1cdbc8cee9d1aea80601e2f9664c4806478aa556fd91e6b647bc71d23b9f0862ed60711365e06e67d513717c5e01b3d7b60c1a5b9438535ef8394e5
|
|
@@ -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
|
```
|
|
@@ -33,6 +41,10 @@ were opened).
|
|
|
33
41
|
In case this browser is connected to, clears all created contexts belonging to this browser and disconnects from the
|
|
34
42
|
browser server.
|
|
35
43
|
|
|
44
|
+
> NOTE: This is similar to force quitting the browser. Therefore, you should call [BrowserContext#close](./browser_context#close) on
|
|
45
|
+
any [BrowserContext](./browser_context)'s you explicitly created earlier with [Browser#new_context](./browser#new_context) **before** calling
|
|
46
|
+
[Browser#close](./browser#close).
|
|
47
|
+
|
|
36
48
|
The [Browser](./browser) object itself is considered to be disposed and cannot be used anymore.
|
|
37
49
|
|
|
38
50
|
## contexts
|
|
@@ -93,12 +105,16 @@ def new_context(
|
|
|
93
105
|
offline: nil,
|
|
94
106
|
permissions: nil,
|
|
95
107
|
proxy: nil,
|
|
108
|
+
record_har_content: nil,
|
|
109
|
+
record_har_mode: nil,
|
|
96
110
|
record_har_omit_content: nil,
|
|
97
111
|
record_har_path: nil,
|
|
112
|
+
record_har_url_filter: nil,
|
|
98
113
|
record_video_dir: nil,
|
|
99
114
|
record_video_size: nil,
|
|
100
115
|
reducedMotion: nil,
|
|
101
116
|
screen: nil,
|
|
117
|
+
serviceWorkers: nil,
|
|
102
118
|
storageState: nil,
|
|
103
119
|
strictSelectors: nil,
|
|
104
120
|
timezoneId: nil,
|
|
@@ -109,14 +125,19 @@ def new_context(
|
|
|
109
125
|
|
|
110
126
|
Creates a new browser context. It won't share cookies/cache with other browser contexts.
|
|
111
127
|
|
|
128
|
+
> NOTE: If directly using this method to create [BrowserContext](./browser_context)s, it is best practice to explicilty close the returned
|
|
129
|
+
context via [BrowserContext#close](./browser_context#close) when your code is done with the [BrowserContext](./browser_context), and before calling
|
|
130
|
+
[Browser#close](./browser#close). This will ensure the `context` is closed gracefully and any artifacts—like HARs and
|
|
131
|
+
videos—are fully flushed and saved.
|
|
132
|
+
|
|
112
133
|
```ruby
|
|
113
134
|
playwright.firefox.launch do |browser| # or "chromium.launch" or "webkit.launch".
|
|
114
135
|
# create a new incognito browser context.
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
136
|
+
browser.new_context do |context|
|
|
137
|
+
# create a new page in a pristine context.
|
|
138
|
+
page = context.new_page
|
|
139
|
+
page.goto("https://example.com")
|
|
140
|
+
end
|
|
120
141
|
end
|
|
121
142
|
```
|
|
122
143
|
|
|
@@ -144,12 +165,16 @@ def new_page(
|
|
|
144
165
|
offline: nil,
|
|
145
166
|
permissions: nil,
|
|
146
167
|
proxy: nil,
|
|
168
|
+
record_har_content: nil,
|
|
169
|
+
record_har_mode: nil,
|
|
147
170
|
record_har_omit_content: nil,
|
|
148
171
|
record_har_path: nil,
|
|
172
|
+
record_har_url_filter: nil,
|
|
149
173
|
record_video_dir: nil,
|
|
150
174
|
record_video_size: nil,
|
|
151
175
|
reducedMotion: nil,
|
|
152
176
|
screen: nil,
|
|
177
|
+
serviceWorkers: nil,
|
|
153
178
|
storageState: nil,
|
|
154
179
|
strictSelectors: nil,
|
|
155
180
|
timezoneId: nil,
|
|
@@ -23,7 +23,7 @@ page = context.new_page
|
|
|
23
23
|
page.goto("https://example.com")
|
|
24
24
|
|
|
25
25
|
# dispose context once it is no longer needed.
|
|
26
|
-
context.close
|
|
26
|
+
context.close
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
|
|
@@ -161,7 +161,7 @@ page.content = <<~HTML
|
|
|
161
161
|
<div></div>
|
|
162
162
|
HTML
|
|
163
163
|
|
|
164
|
-
page.
|
|
164
|
+
page.locator("button").click
|
|
165
165
|
```
|
|
166
166
|
|
|
167
167
|
An example of passing an element handle:
|
|
@@ -184,7 +184,7 @@ page.content = <<~HTML
|
|
|
184
184
|
<div>Or click me</div>
|
|
185
185
|
HTML
|
|
186
186
|
|
|
187
|
-
page.
|
|
187
|
+
page.locator('div').first.click
|
|
188
188
|
```
|
|
189
189
|
|
|
190
190
|
|
|
@@ -222,7 +222,7 @@ page.content = <<~HTML
|
|
|
222
222
|
<button onclick="onClick()">Click me</button>
|
|
223
223
|
<div></div>
|
|
224
224
|
HTML
|
|
225
|
-
page.
|
|
225
|
+
page.locator("button").click
|
|
226
226
|
```
|
|
227
227
|
|
|
228
228
|
|
|
@@ -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
|
```
|
|
@@ -421,7 +434,7 @@ value. Will throw an error if the context closes before the event is fired. Retu
|
|
|
421
434
|
|
|
422
435
|
```ruby
|
|
423
436
|
new_page = browser_context.expect_event('page') do
|
|
424
|
-
page.
|
|
437
|
+
page.locator('button').click
|
|
425
438
|
end
|
|
426
439
|
```
|
|
427
440
|
|
|
@@ -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,
|
|
@@ -55,7 +55,7 @@ def bounding_box
|
|
|
55
55
|
This method returns the bounding box of the element, or `null` if the element is not visible. The bounding box is
|
|
56
56
|
calculated relative to the main frame viewport - which is usually the same as the browser window.
|
|
57
57
|
|
|
58
|
-
Scrolling affects the returned
|
|
58
|
+
Scrolling affects the returned bounding box, similarly to
|
|
59
59
|
[Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect). That
|
|
60
60
|
means `x` and/or `y` may be negative.
|
|
61
61
|
|
|
@@ -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
|
|
|
@@ -446,11 +449,15 @@ def screenshot(
|
|
|
446
449
|
type: nil)
|
|
447
450
|
```
|
|
448
451
|
|
|
449
|
-
|
|
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.
|
|
450
455
|
|
|
451
456
|
This method waits for the [actionability](https://playwright.dev/python/docs/actionability) checks, then scrolls element into view before taking a
|
|
452
457
|
screenshot. If the element is detached from DOM, the method throws an error.
|
|
453
458
|
|
|
459
|
+
Returns the buffer with the captured screenshot.
|
|
460
|
+
|
|
454
461
|
## scroll_into_view_if_needed
|
|
455
462
|
|
|
456
463
|
```
|
|
@@ -497,11 +504,6 @@ element_handle.select_option(label: "blue")
|
|
|
497
504
|
element_handle.select_option(value: ["red", "green", "blue"])
|
|
498
505
|
```
|
|
499
506
|
|
|
500
|
-
```ruby
|
|
501
|
-
# multiple selection for blue, red and second option
|
|
502
|
-
element_handle.select_option(value: "blue", index: 2, label: "red")
|
|
503
|
-
```
|
|
504
|
-
|
|
505
507
|
|
|
506
508
|
|
|
507
509
|
## select_text
|
|
@@ -513,6 +515,10 @@ def select_text(force: nil, timeout: nil)
|
|
|
513
515
|
This method waits for [actionability](https://playwright.dev/python/docs/actionability) checks, then focuses the element and selects all its text
|
|
514
516
|
content.
|
|
515
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
|
+
|
|
516
522
|
## set_checked
|
|
517
523
|
|
|
518
524
|
```
|
|
@@ -546,11 +552,13 @@ def set_input_files(files, noWaitAfter: nil, timeout: nil)
|
|
|
546
552
|
```
|
|
547
553
|
alias: `input_files=`
|
|
548
554
|
|
|
549
|
-
This method expects `elementHandle` to point to an
|
|
550
|
-
[input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
|
|
551
|
-
|
|
552
555
|
Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
|
|
553
|
-
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.
|
|
554
562
|
|
|
555
563
|
## tap_point
|
|
556
564
|
|
|
@@ -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,
|
|
@@ -8,7 +8,7 @@ sidebar_position: 10
|
|
|
8
8
|
|
|
9
9
|
```ruby
|
|
10
10
|
file_chooser = page.expect_file_chooser do
|
|
11
|
-
page.
|
|
11
|
+
page.locator("upload").click # action to trigger file uploading
|
|
12
12
|
end
|
|
13
13
|
file_chooser.set_files("myfile.pdf")
|
|
14
14
|
```
|
|
@@ -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
|
|
|
@@ -34,7 +34,7 @@ def bounding_box(timeout: nil)
|
|
|
34
34
|
This method returns the bounding box of the element, or `null` if the element is not visible. The bounding box is
|
|
35
35
|
calculated relative to the main frame viewport - which is usually the same as the browser window.
|
|
36
36
|
|
|
37
|
-
Scrolling affects the returned
|
|
37
|
+
Scrolling affects the returned bounding box, similarly to
|
|
38
38
|
[Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect). That
|
|
39
39
|
means `x` and/or `y` may be negative.
|
|
40
40
|
|
|
@@ -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
|
```
|
|
@@ -322,6 +342,7 @@ locator.click
|
|
|
322
342
|
```
|
|
323
343
|
def get_attribute(name, timeout: nil)
|
|
324
344
|
```
|
|
345
|
+
alias: `[]`
|
|
325
346
|
|
|
326
347
|
Returns element attribute value.
|
|
327
348
|
|
|
@@ -378,7 +399,10 @@ Returns the `element.innerText`.
|
|
|
378
399
|
def input_value(timeout: nil)
|
|
379
400
|
```
|
|
380
401
|
|
|
381
|
-
Returns `input.value` for `<input>` or `<textarea>` or `<select>` element.
|
|
402
|
+
Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element.
|
|
403
|
+
|
|
404
|
+
Throws for non-input elements. However, if the element is inside the `<label>` element that has an associated
|
|
405
|
+
[control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), returns the value of the control.
|
|
382
406
|
|
|
383
407
|
## checked?
|
|
384
408
|
|
|
@@ -442,7 +466,8 @@ Returns locator to the last matching element.
|
|
|
442
466
|
def locator(selector, has: nil, hasText: nil)
|
|
443
467
|
```
|
|
444
468
|
|
|
445
|
-
The method finds an element matching the specified selector in the [Locator](./locator)'s subtree.
|
|
469
|
+
The method finds an element matching the specified selector in the [Locator](./locator)'s subtree. It also accepts filter options,
|
|
470
|
+
similar to [Locator#filter](./locator#filter) method.
|
|
446
471
|
|
|
447
472
|
## nth
|
|
448
473
|
|
|
@@ -500,11 +525,15 @@ def screenshot(
|
|
|
500
525
|
type: nil)
|
|
501
526
|
```
|
|
502
527
|
|
|
503
|
-
|
|
528
|
+
This method captures a screenshot of the page, clipped to the size and position of a particular element matching the
|
|
529
|
+
locator. If the element is covered by other elements, it will not be actually visible on the screenshot. If the element
|
|
530
|
+
is a scrollable container, only the currently scrolled content will be visible on the screenshot.
|
|
504
531
|
|
|
505
532
|
This method waits for the [actionability](https://playwright.dev/python/docs/actionability) checks, then scrolls element into view before taking a
|
|
506
533
|
screenshot. If the element is detached from DOM, the method throws an error.
|
|
507
534
|
|
|
535
|
+
Returns the buffer with the captured screenshot.
|
|
536
|
+
|
|
508
537
|
## scroll_into_view_if_needed
|
|
509
538
|
|
|
510
539
|
```
|
|
@@ -548,11 +577,6 @@ element.select_option(label: "blue")
|
|
|
548
577
|
element.select_option(value: ["red", "green", "blue"])
|
|
549
578
|
```
|
|
550
579
|
|
|
551
|
-
```ruby
|
|
552
|
-
# multiple selection for blue, red and second option
|
|
553
|
-
element.select_option(value: "blue", index: 2, label: "red")
|
|
554
|
-
```
|
|
555
|
-
|
|
556
580
|
|
|
557
581
|
|
|
558
582
|
## select_text
|
|
@@ -564,6 +588,10 @@ def select_text(force: nil, timeout: nil)
|
|
|
564
588
|
This method waits for [actionability](https://playwright.dev/python/docs/actionability) checks, then focuses the element and selects all its text
|
|
565
589
|
content.
|
|
566
590
|
|
|
591
|
+
If the element is inside the `<label>` element that has an associated
|
|
592
|
+
[control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), focuses and selects text in the
|
|
593
|
+
control instead.
|
|
594
|
+
|
|
567
595
|
## set_checked
|
|
568
596
|
|
|
569
597
|
```
|
|
@@ -597,11 +625,13 @@ def set_input_files(files, noWaitAfter: nil, timeout: nil)
|
|
|
597
625
|
```
|
|
598
626
|
alias: `input_files=`
|
|
599
627
|
|
|
600
|
-
This method expects `element` to point to an
|
|
601
|
-
[input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
|
|
602
|
-
|
|
603
628
|
Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
|
|
604
|
-
are resolved relative to the
|
|
629
|
+
are resolved relative to the current working directory. For empty array, clears the selected files.
|
|
630
|
+
|
|
631
|
+
This method expects [Locator](./locator) to point to an
|
|
632
|
+
[input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). However, if the element is inside the
|
|
633
|
+
`<label>` element that has an associated
|
|
634
|
+
[control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), targets the control instead.
|
|
605
635
|
|
|
606
636
|
## tap_point
|
|
607
637
|
|
|
@@ -462,7 +462,7 @@ page.content = <<~HTML
|
|
|
462
462
|
<button onclick="onClick()">Click me</button>
|
|
463
463
|
<div></div>
|
|
464
464
|
HTML
|
|
465
|
-
page.
|
|
465
|
+
page.locator("button").click
|
|
466
466
|
```
|
|
467
467
|
|
|
468
468
|
An example of passing an element handle:
|
|
@@ -483,7 +483,7 @@ page.content = <<~HTML
|
|
|
483
483
|
<div>Or click me</div>
|
|
484
484
|
HTML
|
|
485
485
|
|
|
486
|
-
page.
|
|
486
|
+
page.locator('div').first.click
|
|
487
487
|
```
|
|
488
488
|
|
|
489
489
|
|
|
@@ -522,7 +522,7 @@ page.content = <<~HTML
|
|
|
522
522
|
<button onclick="onClick()">Click me</button>
|
|
523
523
|
<div></div>
|
|
524
524
|
HTML
|
|
525
|
-
page.
|
|
525
|
+
page.locator("button").click
|
|
526
526
|
```
|
|
527
527
|
|
|
528
528
|
|
|
@@ -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,6 +1013,19 @@ 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
|
```
|
|
@@ -1155,11 +1173,13 @@ def set_input_files(
|
|
|
1155
1173
|
timeout: nil)
|
|
1156
1174
|
```
|
|
1157
1175
|
|
|
1158
|
-
This method expects `selector` to point to an
|
|
1159
|
-
[input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
|
|
1160
|
-
|
|
1161
1176
|
Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
|
|
1162
|
-
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.
|
|
1163
1183
|
|
|
1164
1184
|
## set_viewport_size
|
|
1165
1185
|
|
|
@@ -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
|
|