playwright-ruby-client 1.14.beta2 → 1.15.beta2
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/README.md +10 -14
- data/documentation/docs/api/accessibility.md +16 -17
- data/documentation/docs/api/browser.md +4 -0
- data/documentation/docs/api/browser_context.md +5 -1
- data/documentation/docs/api/browser_type.md +2 -0
- data/documentation/docs/api/element_handle.md +30 -5
- data/documentation/docs/api/experimental/android.md +15 -2
- data/documentation/docs/api/experimental/android_device.md +2 -0
- data/documentation/docs/api/frame.md +86 -104
- data/documentation/docs/api/locator.md +69 -40
- data/documentation/docs/api/mouse.md +3 -4
- data/documentation/docs/api/page.md +38 -7
- data/documentation/docs/api/request.md +42 -20
- data/documentation/docs/api/response.md +18 -1
- data/documentation/docs/api/selectors.md +29 -3
- data/documentation/docs/api/tracing.md +51 -16
- data/documentation/docs/api/worker.md +12 -11
- data/documentation/docs/article/getting_started.md +10 -1
- data/documentation/docs/article/guides/download_playwright_driver.md +9 -0
- data/documentation/docs/article/guides/inspector.md +1 -1
- data/documentation/docs/article/guides/playwright_on_alpine_linux.md +56 -3
- data/documentation/docs/article/guides/rails_integration.md +4 -2
- data/documentation/docs/article/guides/rails_integration_with_null_driver.md +86 -0
- data/documentation/docs/article/guides/recording_video.md +1 -1
- data/documentation/docs/article/guides/semi_automation.md +2 -2
- data/documentation/docs/article/guides/use_storage_state.md +78 -0
- data/documentation/docs/include/api_coverage.md +11 -0
- data/documentation/docusaurus.config.js +1 -0
- data/documentation/package.json +2 -2
- data/documentation/src/pages/index.js +0 -1
- data/documentation/static/img/playwright-ruby-client.png +0 -0
- data/documentation/yarn.lock +625 -549
- data/lib/playwright/channel.rb +36 -2
- data/lib/playwright/channel_owners/artifact.rb +6 -2
- data/lib/playwright/channel_owners/browser.rb +4 -0
- data/lib/playwright/channel_owners/browser_context.rb +21 -14
- data/lib/playwright/channel_owners/browser_type.rb +0 -1
- data/lib/playwright/channel_owners/element_handle.rb +10 -2
- data/lib/playwright/channel_owners/frame.rb +8 -0
- data/lib/playwright/channel_owners/page.rb +20 -4
- data/lib/playwright/channel_owners/playwright.rb +9 -0
- data/lib/playwright/channel_owners/request.rb +46 -25
- data/lib/playwright/channel_owners/response.rb +41 -5
- data/lib/playwright/connection.rb +8 -11
- data/lib/playwright/http_headers.rb +9 -4
- data/lib/playwright/locator_impl.rb +11 -3
- data/lib/playwright/{route_handler_entry.rb → route_handler.rb} +30 -2
- data/lib/playwright/tracing_impl.rb +18 -7
- data/lib/playwright/transport.rb +2 -0
- data/lib/playwright/utils.rb +8 -1
- data/lib/playwright/version.rb +2 -2
- data/lib/playwright/web_socket_transport.rb +2 -0
- data/lib/playwright.rb +45 -5
- data/lib/playwright_api/android.rb +21 -8
- data/lib/playwright_api/android_device.rb +11 -9
- data/lib/playwright_api/browser.rb +12 -8
- data/lib/playwright_api/browser_context.rb +12 -8
- data/lib/playwright_api/browser_type.rb +9 -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/element_handle.rb +31 -8
- data/lib/playwright_api/frame.rb +35 -12
- data/lib/playwright_api/js_handle.rb +6 -6
- data/lib/playwright_api/locator.rb +41 -2
- data/lib/playwright_api/page.rb +43 -15
- data/lib/playwright_api/playwright.rb +6 -6
- data/lib/playwright_api/request.rb +29 -7
- data/lib/playwright_api/response.rb +23 -7
- data/lib/playwright_api/route.rb +6 -6
- data/lib/playwright_api/selectors.rb +38 -7
- data/lib/playwright_api/tracing.rb +33 -4
- data/lib/playwright_api/web_socket.rb +6 -6
- data/lib/playwright_api/worker.rb +8 -8
- metadata +7 -4
|
@@ -7,10 +7,9 @@ sidebar_position: 10
|
|
|
7
7
|
Locator represents a view to the element(s) on the page. It captures the logic sufficient to retrieve the element at any
|
|
8
8
|
given moment. Locator can be created with the [Page#locator](./page#locator) method.
|
|
9
9
|
|
|
10
|
-
```
|
|
10
|
+
```ruby
|
|
11
11
|
locator = page.locator("text=Submit")
|
|
12
|
-
locator.click
|
|
13
|
-
|
|
12
|
+
locator.click
|
|
14
13
|
```
|
|
15
14
|
|
|
16
15
|
The difference between the Locator and [ElementHandle](./element_handle) is that the latter points to a particular element, while Locator
|
|
@@ -35,6 +34,22 @@ locator.hover
|
|
|
35
34
|
locator.click
|
|
36
35
|
```
|
|
37
36
|
|
|
37
|
+
**Strictness**
|
|
38
|
+
|
|
39
|
+
Locators are strict. This means that all operations on locators that imply some target DOM element will throw if more
|
|
40
|
+
than one element matches given selector.
|
|
41
|
+
|
|
42
|
+
```ruby
|
|
43
|
+
# Throws if there are several buttons in DOM:
|
|
44
|
+
page.locator('button').click
|
|
45
|
+
|
|
46
|
+
# Works because we explicitly tell locator to pick the first element:
|
|
47
|
+
page.locator('button').first.click
|
|
48
|
+
|
|
49
|
+
# Works because count knows what to do with multiple matches:
|
|
50
|
+
page.locator('button').count
|
|
51
|
+
```
|
|
52
|
+
|
|
38
53
|
|
|
39
54
|
|
|
40
55
|
## all_inner_texts
|
|
@@ -72,10 +87,12 @@ Elements from child frames return the bounding box relative to the main frame, u
|
|
|
72
87
|
Assuming the page is static, it is safe to use bounding box coordinates to perform input. For example, the following
|
|
73
88
|
snippet should click the center of the element.
|
|
74
89
|
|
|
75
|
-
```
|
|
76
|
-
box = element.bounding_box
|
|
77
|
-
page.mouse.click(
|
|
78
|
-
|
|
90
|
+
```ruby
|
|
91
|
+
box = element.bounding_box
|
|
92
|
+
page.mouse.click(
|
|
93
|
+
box["x"] + box["width"] / 2,
|
|
94
|
+
box["y"] + box["height"] / 2,
|
|
95
|
+
)
|
|
79
96
|
```
|
|
80
97
|
|
|
81
98
|
|
|
@@ -177,9 +194,8 @@ The snippet below dispatches the `click` event on the element. Regardless of the
|
|
|
177
194
|
`click` is dispatched. This is equivalent to calling
|
|
178
195
|
[element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
|
|
179
196
|
|
|
180
|
-
```
|
|
197
|
+
```ruby
|
|
181
198
|
element.dispatch_event("click")
|
|
182
|
-
|
|
183
199
|
```
|
|
184
200
|
|
|
185
201
|
Under the hood, it creates an instance of an event based on the given `type`, initializes it with `eventInit` properties
|
|
@@ -196,11 +212,10 @@ Since `eventInit` is event-specific, please refer to the events documentation fo
|
|
|
196
212
|
|
|
197
213
|
You can also specify [JSHandle](./js_handle) as the property value if you want live objects to be passed into the event:
|
|
198
214
|
|
|
199
|
-
```
|
|
215
|
+
```ruby
|
|
200
216
|
# note you can only create data_transfer in chromium and firefox
|
|
201
217
|
data_transfer = page.evaluate_handle("new DataTransfer()")
|
|
202
|
-
element.dispatch_event("
|
|
203
|
-
|
|
218
|
+
element.dispatch_event("dragstart", eventInit: { dataTransfer: data_transfer })
|
|
204
219
|
```
|
|
205
220
|
|
|
206
221
|
|
|
@@ -236,10 +251,9 @@ If `expression` returns a [Promise](https://developer.mozilla.org/en-US/docs/Web
|
|
|
236
251
|
|
|
237
252
|
Examples:
|
|
238
253
|
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
254
|
+
```ruby
|
|
255
|
+
tweet = page.query_selector(".tweet .retweets")
|
|
256
|
+
tweet.evaluate("node => node.innerText") # => "10 retweets"
|
|
243
257
|
```
|
|
244
258
|
|
|
245
259
|
|
|
@@ -253,15 +267,14 @@ def evaluate_all(expression, arg: nil)
|
|
|
253
267
|
The method finds all elements matching the specified locator and passes an array of matched elements as a first argument
|
|
254
268
|
to `expression`. Returns the result of `expression` invocation.
|
|
255
269
|
|
|
256
|
-
If `expression` returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), then [
|
|
257
|
-
value.
|
|
270
|
+
If `expression` returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), then [Locator#evaluate_all](./locator#evaluate_all) would wait for the promise to resolve and
|
|
271
|
+
return its value.
|
|
258
272
|
|
|
259
273
|
Examples:
|
|
260
274
|
|
|
261
|
-
```
|
|
275
|
+
```ruby
|
|
262
276
|
elements = page.locator("div")
|
|
263
|
-
|
|
264
|
-
|
|
277
|
+
elements.evaluate_all("(divs, min) => divs.length >= min", arg: 10)
|
|
265
278
|
```
|
|
266
279
|
|
|
267
280
|
|
|
@@ -518,26 +531,18 @@ Returns the array of option values that have been successfully selected.
|
|
|
518
531
|
|
|
519
532
|
Triggers a `change` and `input` event once all the provided options have been selected.
|
|
520
533
|
|
|
521
|
-
```
|
|
534
|
+
```ruby
|
|
522
535
|
# single selection matching the value
|
|
523
|
-
element.select_option("blue")
|
|
536
|
+
element.select_option(value: "blue")
|
|
524
537
|
# single selection matching both the label
|
|
525
|
-
element.select_option(label
|
|
538
|
+
element.select_option(label: "blue")
|
|
526
539
|
# multiple selection
|
|
527
|
-
element.select_option(value
|
|
528
|
-
|
|
540
|
+
element.select_option(value: ["red", "green", "blue"])
|
|
529
541
|
```
|
|
530
542
|
|
|
531
|
-
```
|
|
532
|
-
# single selection matching the value
|
|
533
|
-
element.select_option("blue")
|
|
534
|
-
# single selection matching both the value and the label
|
|
535
|
-
element.select_option(label="blue")
|
|
536
|
-
# multiple selection
|
|
537
|
-
element.select_option("red", "green", "blue")
|
|
543
|
+
```ruby
|
|
538
544
|
# multiple selection for blue, red and second option
|
|
539
|
-
element.select_option(value
|
|
540
|
-
|
|
545
|
+
element.select_option(value: "blue", index: 2, label: "red")
|
|
541
546
|
```
|
|
542
547
|
|
|
543
548
|
|
|
@@ -551,6 +556,32 @@ def select_text(force: nil, timeout: nil)
|
|
|
551
556
|
This method waits for [actionability](https://playwright.dev/python/docs/actionability) checks, then focuses the element and selects all its text
|
|
552
557
|
content.
|
|
553
558
|
|
|
559
|
+
## set_checked
|
|
560
|
+
|
|
561
|
+
```
|
|
562
|
+
def set_checked(
|
|
563
|
+
checked,
|
|
564
|
+
force: nil,
|
|
565
|
+
noWaitAfter: nil,
|
|
566
|
+
position: nil,
|
|
567
|
+
timeout: nil,
|
|
568
|
+
trial: nil)
|
|
569
|
+
```
|
|
570
|
+
alias: `checked=`
|
|
571
|
+
|
|
572
|
+
This method checks or unchecks an element by performing the following steps:
|
|
573
|
+
1. Ensure that matched element is a checkbox or a radio input. If not, this method throws.
|
|
574
|
+
1. If the element already has the right checked state, this method returns immediately.
|
|
575
|
+
1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the matched element, unless `force` option is set. If the
|
|
576
|
+
element is detached during the checks, the whole action is retried.
|
|
577
|
+
1. Scroll the element into view if needed.
|
|
578
|
+
1. Use [Page#mouse](./page#mouse) to click in the center of the element.
|
|
579
|
+
1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
|
580
|
+
1. Ensure that the element is now checked or unchecked. If not, this method throws.
|
|
581
|
+
|
|
582
|
+
When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
|
|
583
|
+
zero timeout disables this.
|
|
584
|
+
|
|
554
585
|
## set_input_files
|
|
555
586
|
|
|
556
587
|
```
|
|
@@ -607,19 +638,17 @@ Focuses the element, and then sends a `keydown`, `keypress`/`input`, and `keyup`
|
|
|
607
638
|
|
|
608
639
|
To press a special key, like `Control` or `ArrowDown`, use [Locator#press](./locator#press).
|
|
609
640
|
|
|
610
|
-
```
|
|
641
|
+
```ruby
|
|
611
642
|
element.type("hello") # types instantly
|
|
612
|
-
element.type("world", delay
|
|
613
|
-
|
|
643
|
+
element.type("world", delay: 100) # types slower, like a user
|
|
614
644
|
```
|
|
615
645
|
|
|
616
646
|
An example of typing into a text field and then submitting the form:
|
|
617
647
|
|
|
618
|
-
```
|
|
648
|
+
```ruby
|
|
619
649
|
element = page.locator("input")
|
|
620
650
|
element.type("some text")
|
|
621
651
|
element.press("Enter")
|
|
622
|
-
|
|
623
652
|
```
|
|
624
653
|
|
|
625
654
|
|
|
@@ -8,16 +8,15 @@ The Mouse class operates in main-frame CSS pixels relative to the top-left corne
|
|
|
8
8
|
|
|
9
9
|
Every `page` object has its own Mouse, accessible with [Page#mouse](./page#mouse).
|
|
10
10
|
|
|
11
|
-
```
|
|
11
|
+
```ruby
|
|
12
12
|
# using ‘page.mouse’ to trace a 100x100 square.
|
|
13
13
|
page.mouse.move(0, 0)
|
|
14
|
-
page.mouse.down
|
|
14
|
+
page.mouse.down
|
|
15
15
|
page.mouse.move(0, 100)
|
|
16
16
|
page.mouse.move(100, 100)
|
|
17
17
|
page.mouse.move(100, 0)
|
|
18
18
|
page.mouse.move(0, 0)
|
|
19
|
-
page.mouse.up
|
|
20
|
-
|
|
19
|
+
page.mouse.up
|
|
21
20
|
```
|
|
22
21
|
|
|
23
22
|
|
|
@@ -281,7 +281,7 @@ def drag_and_drop(
|
|
|
281
281
|
## emulate_media
|
|
282
282
|
|
|
283
283
|
```
|
|
284
|
-
def emulate_media(colorScheme: nil, media: nil, reducedMotion: nil)
|
|
284
|
+
def emulate_media(colorScheme: nil, forcedColors: nil, media: nil, reducedMotion: nil)
|
|
285
285
|
```
|
|
286
286
|
|
|
287
287
|
This method changes the `CSS media type` through the `media` argument, and/or the `'prefers-colors-scheme'` media
|
|
@@ -622,18 +622,18 @@ def goto(url, referer: nil, timeout: nil, waitUntil: nil)
|
|
|
622
622
|
Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
|
|
623
623
|
last redirect.
|
|
624
624
|
|
|
625
|
-
|
|
625
|
+
The method will throw an error if:
|
|
626
626
|
- there's an SSL error (e.g. in case of self-signed certificates).
|
|
627
627
|
- target URL is invalid.
|
|
628
628
|
- the `timeout` is exceeded during navigation.
|
|
629
629
|
- the remote server does not respond or is unreachable.
|
|
630
630
|
- the main resource failed to load.
|
|
631
631
|
|
|
632
|
-
|
|
632
|
+
The method will not throw an error when any valid HTTP status code is returned by the remote server, including 404 "Not
|
|
633
633
|
Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling
|
|
634
634
|
[Response#status](./response#status).
|
|
635
635
|
|
|
636
|
-
> NOTE:
|
|
636
|
+
> NOTE: The method either throws an error or returns a main resource response. The only exceptions are navigation to
|
|
637
637
|
`about:blank` or navigation to the same URL with a different hash, which would succeed and return `null`.
|
|
638
638
|
> NOTE: Headless mode doesn't support navigation to a PDF document. See the
|
|
639
639
|
[upstream issue](https://bugs.chromium.org/p/chromium/issues/detail?id=761295).
|
|
@@ -758,8 +758,6 @@ The method returns an element locator that can be used to perform actions on the
|
|
|
758
758
|
element immediately before performing an action, so a series of actions on the same locator can in fact be performed on
|
|
759
759
|
different DOM elements. That would happen if the DOM structure between those actions has changed.
|
|
760
760
|
|
|
761
|
-
Note that locator always implies visibility, so it will always be locating visible elements.
|
|
762
|
-
|
|
763
761
|
Shortcut for main frame's [Frame#locator](./frame#locator).
|
|
764
762
|
|
|
765
763
|
## main_frame
|
|
@@ -935,7 +933,7 @@ last redirect.
|
|
|
935
933
|
## route
|
|
936
934
|
|
|
937
935
|
```
|
|
938
|
-
def route(url, handler)
|
|
936
|
+
def route(url, handler, times: nil)
|
|
939
937
|
```
|
|
940
938
|
|
|
941
939
|
Routing provides the capability to modify network requests that are made by a page.
|
|
@@ -943,6 +941,9 @@ Routing provides the capability to modify network requests that are made by a pa
|
|
|
943
941
|
Once routing is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
|
|
944
942
|
|
|
945
943
|
> NOTE: The handler will only be called for the first url if the response is a redirect.
|
|
944
|
+
> NOTE: [Page#route](./page#route) will not intercept requests intercepted by Service Worker. See
|
|
945
|
+
[this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using
|
|
946
|
+
request interception. Via `await context.addInitScript(() => delete window.navigator.serviceWorker);`
|
|
946
947
|
|
|
947
948
|
An example of a naive handler that aborts all image requests:
|
|
948
949
|
|
|
@@ -1032,6 +1033,36 @@ page.select_option("select#colors", value: ["red", "green", "blue"])
|
|
|
1032
1033
|
|
|
1033
1034
|
Shortcut for main frame's [Frame#select_option](./frame#select_option).
|
|
1034
1035
|
|
|
1036
|
+
## set_checked
|
|
1037
|
+
|
|
1038
|
+
```
|
|
1039
|
+
def set_checked(
|
|
1040
|
+
selector,
|
|
1041
|
+
checked,
|
|
1042
|
+
force: nil,
|
|
1043
|
+
noWaitAfter: nil,
|
|
1044
|
+
position: nil,
|
|
1045
|
+
strict: nil,
|
|
1046
|
+
timeout: nil,
|
|
1047
|
+
trial: nil)
|
|
1048
|
+
```
|
|
1049
|
+
|
|
1050
|
+
This method checks or unchecks an element matching `selector` by performing the following steps:
|
|
1051
|
+
1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
|
1052
|
+
1. Ensure that matched element is a checkbox or a radio input. If not, this method throws.
|
|
1053
|
+
1. If the element already has the right checked state, this method returns immediately.
|
|
1054
|
+
1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the matched element, unless `force` option is set. If the
|
|
1055
|
+
element is detached during the checks, the whole action is retried.
|
|
1056
|
+
1. Scroll the element into view if needed.
|
|
1057
|
+
1. Use [Page#mouse](./page#mouse) to click in the center of the element.
|
|
1058
|
+
1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
|
1059
|
+
1. Ensure that the element is now checked or unchecked. If not, this method throws.
|
|
1060
|
+
|
|
1061
|
+
When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
|
|
1062
|
+
zero timeout disables this.
|
|
1063
|
+
|
|
1064
|
+
Shortcut for main frame's [Frame#set_checked](./frame#set_checked).
|
|
1065
|
+
|
|
1035
1066
|
## set_content
|
|
1036
1067
|
|
|
1037
1068
|
```
|
|
@@ -18,6 +18,14 @@ complete with `'requestfinished'` event.
|
|
|
18
18
|
If request gets a 'redirect' response, the request is successfully finished with the 'requestfinished' event, and a new
|
|
19
19
|
request is issued to a redirected url.
|
|
20
20
|
|
|
21
|
+
## all_headers
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
def all_headers
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
An object with all the request HTTP headers associated with this request. The header names are lower-cased.
|
|
28
|
+
|
|
21
29
|
## failure
|
|
22
30
|
|
|
23
31
|
```
|
|
@@ -28,9 +36,8 @@ The method returns `null` unless this request has failed, as reported by `reques
|
|
|
28
36
|
|
|
29
37
|
Example of logging of all the failed requests:
|
|
30
38
|
|
|
31
|
-
```
|
|
32
|
-
page.on("requestfailed",
|
|
33
|
-
|
|
39
|
+
```ruby
|
|
40
|
+
page.on("requestfailed", ->(request) { puts "#{request.url} #{request.failure}" })
|
|
34
41
|
```
|
|
35
42
|
|
|
36
43
|
|
|
@@ -49,7 +56,16 @@ Returns the [Frame](./frame) that initiated this request.
|
|
|
49
56
|
def headers
|
|
50
57
|
```
|
|
51
58
|
|
|
52
|
-
|
|
59
|
+
**DEPRECATED** Incomplete list of headers as seen by the rendering engine. Use [Request#all_headers](./request#all_headers) instead.
|
|
60
|
+
|
|
61
|
+
## headers_array
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
def headers_array
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
An array with all the request HTTP headers associated with this request. Unlike [Request#all_headers](./request#all_headers), header
|
|
68
|
+
names are not lower-cased. Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times.
|
|
53
69
|
|
|
54
70
|
## navigation_request?
|
|
55
71
|
|
|
@@ -108,18 +124,17 @@ construct the whole redirect chain by repeatedly calling `redirectedFrom()`.
|
|
|
108
124
|
|
|
109
125
|
For example, if the website `http://example.com` redirects to `https://example.com`:
|
|
110
126
|
|
|
111
|
-
```
|
|
112
|
-
response = page.goto("http://
|
|
113
|
-
|
|
114
|
-
|
|
127
|
+
```ruby
|
|
128
|
+
response = page.goto("http://github.com")
|
|
129
|
+
puts response.url # => "https://github.com"
|
|
130
|
+
puts response.request.redirected_from&.url # => "http://github.com"
|
|
115
131
|
```
|
|
116
132
|
|
|
117
133
|
If the website `https://google.com` has no redirects:
|
|
118
134
|
|
|
119
|
-
```
|
|
135
|
+
```ruby
|
|
120
136
|
response = page.goto("https://google.com")
|
|
121
|
-
|
|
122
|
-
|
|
137
|
+
puts response.request.redirected_from&.url # => nil
|
|
123
138
|
```
|
|
124
139
|
|
|
125
140
|
|
|
@@ -134,9 +149,8 @@ New request issued by the browser if the server responded with redirect.
|
|
|
134
149
|
|
|
135
150
|
This method is the opposite of [Request#redirected_from](./request#redirected_from):
|
|
136
151
|
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
|
|
152
|
+
```ruby
|
|
153
|
+
request.redirected_from.redirected_to # equals to request
|
|
140
154
|
```
|
|
141
155
|
|
|
142
156
|
|
|
@@ -159,6 +173,15 @@ def response
|
|
|
159
173
|
|
|
160
174
|
Returns the matching [Response](./response) object, or `null` if the response was not received due to error.
|
|
161
175
|
|
|
176
|
+
## sizes
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
def sizes
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Returns resource size information for given request. Requires the response to be finished via
|
|
183
|
+
[Response#finished](./response#finished) to ensure the info is available.
|
|
184
|
+
|
|
162
185
|
## timing
|
|
163
186
|
|
|
164
187
|
```
|
|
@@ -169,12 +192,11 @@ Returns resource timing information for given request. Most of the timing values
|
|
|
169
192
|
`responseEnd` becomes available when request finishes. Find more information at
|
|
170
193
|
[Resource Timing API](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming).
|
|
171
194
|
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
195
|
+
```ruby
|
|
196
|
+
request = page.expect_event("requestfinished") do
|
|
197
|
+
page.goto("https://example.com")
|
|
198
|
+
end
|
|
199
|
+
puts request.timing
|
|
178
200
|
```
|
|
179
201
|
|
|
180
202
|
|
|
@@ -6,6 +6,14 @@ sidebar_position: 10
|
|
|
6
6
|
|
|
7
7
|
[Response](./response) class represents responses which are received by page.
|
|
8
8
|
|
|
9
|
+
## all_headers
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
def all_headers
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
An object with all the response HTTP headers associated with this response.
|
|
16
|
+
|
|
9
17
|
## body
|
|
10
18
|
|
|
11
19
|
```
|
|
@@ -36,7 +44,16 @@ Returns the [Frame](./frame) that initiated this response.
|
|
|
36
44
|
def headers
|
|
37
45
|
```
|
|
38
46
|
|
|
39
|
-
|
|
47
|
+
**DEPRECATED** Incomplete list of headers as seen by the rendering engine. Use [Response#all_headers](./response#all_headers) instead.
|
|
48
|
+
|
|
49
|
+
## headers_array
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
def headers_array
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
An array with all the request HTTP headers associated with this response. Unlike [Response#all_headers](./response#all_headers), header
|
|
56
|
+
names are not lower-cased. Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times.
|
|
40
57
|
|
|
41
58
|
## json
|
|
42
59
|
|