playwright-ruby-client 0.5.7 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/documentation/README.md +33 -0
- data/documentation/babel.config.js +3 -0
- data/documentation/docs/api/accessibility.md +7 -0
- data/documentation/docs/api/browser.md +185 -0
- data/documentation/docs/api/browser_context.md +398 -0
- data/documentation/docs/api/browser_type.md +105 -0
- data/documentation/docs/api/cdp_session.md +7 -0
- data/documentation/docs/api/console_message.md +41 -0
- data/documentation/docs/api/dialog.md +74 -0
- data/documentation/docs/api/element_handle.md +640 -0
- data/documentation/docs/api/experimental/_category_.yml +3 -0
- data/documentation/docs/api/experimental/android.md +25 -0
- data/documentation/docs/api/experimental/android_device.md +91 -0
- data/documentation/docs/api/experimental/android_input.md +38 -0
- data/documentation/docs/api/experimental/android_socket.md +7 -0
- data/documentation/docs/api/experimental/android_web_view.md +7 -0
- data/documentation/docs/api/file_chooser.md +51 -0
- data/documentation/docs/api/frame.md +867 -0
- data/documentation/docs/api/js_handle.md +116 -0
- data/documentation/docs/api/keyboard.md +157 -0
- data/documentation/docs/api/mouse.md +69 -0
- data/documentation/docs/api/page.md +1469 -0
- data/documentation/docs/api/playwright.md +63 -0
- data/documentation/docs/api/request.md +188 -0
- data/documentation/docs/api/response.md +97 -0
- data/documentation/docs/api/route.md +80 -0
- data/documentation/docs/api/selectors.md +23 -0
- data/documentation/docs/api/touchscreen.md +8 -0
- data/documentation/docs/api/tracing.md +54 -0
- data/documentation/docs/api/web_socket.md +7 -0
- data/documentation/docs/api/worker.md +7 -0
- data/documentation/docs/article/api_coverage.mdx +11 -0
- data/documentation/docs/article/getting_started.md +152 -0
- data/documentation/docs/article/guides/_category_.yml +3 -0
- data/documentation/docs/article/guides/download_playwright_driver.md +49 -0
- data/documentation/docs/article/guides/launch_browser.md +119 -0
- data/documentation/docs/article/guides/rails_integration.md +51 -0
- data/{docs → documentation/docs/include}/api_coverage.md +10 -1
- data/documentation/docusaurus.config.js +107 -0
- data/documentation/package.json +39 -0
- data/documentation/sidebars.js +15 -0
- data/documentation/src/components/HomepageFeatures.js +61 -0
- data/documentation/src/components/HomepageFeatures.module.css +13 -0
- data/documentation/src/css/custom.css +44 -0
- data/documentation/src/pages/index.js +50 -0
- data/documentation/src/pages/index.module.css +41 -0
- data/documentation/src/pages/markdown-page.md +7 -0
- data/documentation/static/.nojekyll +0 -0
- data/documentation/static/img/playwright-logo.svg +9 -0
- data/documentation/static/img/undraw_dropdown_menu.svg +1 -0
- data/documentation/static/img/undraw_web_development.svg +1 -0
- data/documentation/static/img/undraw_windows.svg +1 -0
- data/documentation/yarn.lock +8805 -0
- data/lib/playwright/channel_owner.rb +3 -0
- data/lib/playwright/channel_owners/binding_call.rb +33 -0
- data/lib/playwright/channel_owners/browser.rb +27 -2
- data/lib/playwright/channel_owners/browser_context.rb +54 -3
- data/lib/playwright/channel_owners/browser_type.rb +8 -1
- data/lib/playwright/channel_owners/element_handle.rb +17 -16
- data/lib/playwright/channel_owners/frame.rb +29 -34
- data/lib/playwright/channel_owners/js_handle.rb +2 -10
- data/lib/playwright/channel_owners/page.rb +29 -45
- data/lib/playwright/download.rb +3 -2
- data/lib/playwright/events.rb +4 -0
- data/lib/playwright/input_files.rb +0 -8
- data/lib/playwright/javascript.rb +0 -10
- data/lib/playwright/javascript/expression.rb +2 -7
- data/lib/playwright/playwright_api.rb +1 -5
- data/lib/playwright/tracing_impl.rb +31 -0
- data/lib/playwright/version.rb +2 -1
- data/lib/playwright_api/accessibility.rb +7 -88
- data/lib/playwright_api/android.rb +8 -65
- data/lib/playwright_api/android_device.rb +8 -8
- data/lib/playwright_api/browser.rb +15 -126
- data/lib/playwright_api/browser_context.rb +63 -429
- data/lib/playwright_api/browser_type.rb +33 -84
- data/lib/playwright_api/cdp_session.rb +2 -25
- data/lib/playwright_api/console_message.rb +8 -6
- data/lib/playwright_api/dialog.rb +11 -69
- data/lib/playwright_api/element_handle.rb +102 -300
- data/lib/playwright_api/file_chooser.rb +0 -21
- data/lib/playwright_api/frame.rb +105 -571
- data/lib/playwright_api/js_handle.rb +16 -73
- data/lib/playwright_api/keyboard.rb +22 -166
- data/lib/playwright_api/mouse.rb +1 -45
- data/lib/playwright_api/page.rb +202 -1217
- data/lib/playwright_api/playwright.rb +14 -99
- data/lib/playwright_api/request.rb +15 -93
- data/lib/playwright_api/response.rb +7 -7
- data/lib/playwright_api/route.rb +9 -86
- data/lib/playwright_api/selectors.rb +6 -72
- data/lib/playwright_api/tracing.rb +39 -0
- data/lib/playwright_api/web_socket.rb +1 -1
- data/lib/playwright_api/worker.rb +6 -42
- data/playwright.gemspec +2 -2
- metadata +59 -20
- data/lib/playwright/javascript/function.rb +0 -67
@@ -1,58 +1,10 @@
|
|
1
1
|
module Playwright
|
2
2
|
# Playwright module provides a method to launch a browser instance. The following is a typical example of using Playwright
|
3
3
|
# to drive automation:
|
4
|
-
#
|
5
4
|
#
|
6
|
-
# ```js
|
7
|
-
# const { chromium, firefox, webkit } = require('playwright');
|
8
|
-
#
|
9
|
-
# (async () => {
|
10
|
-
# const browser = await chromium.launch(); // Or 'firefox' or 'webkit'.
|
11
|
-
# const page = await browser.newPage();
|
12
|
-
# await page.goto('http://example.com');
|
13
|
-
# // other actions...
|
14
|
-
# await browser.close();
|
15
|
-
# })();
|
16
|
-
# ```
|
17
|
-
#
|
18
|
-
# ```java
|
19
|
-
# import com.microsoft.playwright.*;
|
20
|
-
#
|
21
|
-
# public class Example {
|
22
|
-
# public static void main(String[] args) {
|
23
|
-
# try (Playwright playwright = Playwright.create()) {
|
24
|
-
# BrowserType chromium = playwright.chromium();
|
25
|
-
# Browser browser = chromium.launch();
|
26
|
-
# Page page = browser.newPage();
|
27
|
-
# page.navigate("http://example.com");
|
28
|
-
# // other actions...
|
29
|
-
# browser.close();
|
30
|
-
# }
|
31
|
-
# }
|
32
|
-
# }
|
33
|
-
# ```
|
34
|
-
#
|
35
|
-
# ```python async
|
36
|
-
# import asyncio
|
37
|
-
# from playwright.async_api import async_playwright
|
38
|
-
#
|
39
|
-
# async def run(playwright):
|
40
|
-
# chromium = playwright.chromium # or "firefox" or "webkit".
|
41
|
-
# browser = await chromium.launch()
|
42
|
-
# page = await browser.new_page()
|
43
|
-
# await page.goto("http://example.com")
|
44
|
-
# # other actions...
|
45
|
-
# await browser.close()
|
46
|
-
#
|
47
|
-
# async def main():
|
48
|
-
# async with async_playwright() as playwright:
|
49
|
-
# await run(playwright)
|
50
|
-
# asyncio.run(main())
|
51
|
-
# ```
|
52
|
-
#
|
53
5
|
# ```python sync
|
54
6
|
# from playwright.sync_api import sync_playwright
|
55
|
-
#
|
7
|
+
#
|
56
8
|
# def run(playwright):
|
57
9
|
# chromium = playwright.chromium # or "firefox" or "webkit".
|
58
10
|
# browser = chromium.launch()
|
@@ -60,7 +12,7 @@ module Playwright
|
|
60
12
|
# page.goto("http://example.com")
|
61
13
|
# # other actions...
|
62
14
|
# browser.close()
|
63
|
-
#
|
15
|
+
#
|
64
16
|
# with sync_playwright() as playwright:
|
65
17
|
# run(playwright)
|
66
18
|
# ```
|
@@ -72,47 +24,10 @@ module Playwright
|
|
72
24
|
end
|
73
25
|
|
74
26
|
# Returns a dictionary of devices to be used with [`method: Browser.newContext`] or [`method: Browser.newPage`].
|
75
|
-
#
|
76
27
|
#
|
77
|
-
# ```js
|
78
|
-
# const { webkit, devices } = require('playwright');
|
79
|
-
# const iPhone = devices['iPhone 6'];
|
80
|
-
#
|
81
|
-
# (async () => {
|
82
|
-
# const browser = await webkit.launch();
|
83
|
-
# const context = await browser.newContext({
|
84
|
-
# ...iPhone
|
85
|
-
# });
|
86
|
-
# const page = await context.newPage();
|
87
|
-
# await page.goto('http://example.com');
|
88
|
-
# // other actions...
|
89
|
-
# await browser.close();
|
90
|
-
# })();
|
91
|
-
# ```
|
92
|
-
#
|
93
|
-
# ```python async
|
94
|
-
# import asyncio
|
95
|
-
# from playwright.async_api import async_playwright
|
96
|
-
#
|
97
|
-
# async def run(playwright):
|
98
|
-
# webkit = playwright.webkit
|
99
|
-
# iphone = playwright.devices["iPhone 6"]
|
100
|
-
# browser = await webkit.launch()
|
101
|
-
# context = await browser.new_context(**iphone)
|
102
|
-
# page = await context.new_page()
|
103
|
-
# await page.goto("http://example.com")
|
104
|
-
# # other actions...
|
105
|
-
# await browser.close()
|
106
|
-
#
|
107
|
-
# async def main():
|
108
|
-
# async with async_playwright() as playwright:
|
109
|
-
# await run(playwright)
|
110
|
-
# asyncio.run(main())
|
111
|
-
# ```
|
112
|
-
#
|
113
28
|
# ```python sync
|
114
29
|
# from playwright.sync_api import sync_playwright
|
115
|
-
#
|
30
|
+
#
|
116
31
|
# def run(playwright):
|
117
32
|
# webkit = playwright.webkit
|
118
33
|
# iphone = playwright.devices["iPhone 6"]
|
@@ -122,7 +37,7 @@ module Playwright
|
|
122
37
|
# page.goto("http://example.com")
|
123
38
|
# # other actions...
|
124
39
|
# browser.close()
|
125
|
-
#
|
40
|
+
#
|
126
41
|
# with sync_playwright() as playwright:
|
127
42
|
# run(playwright)
|
128
43
|
# ```
|
@@ -148,18 +63,18 @@ module Playwright
|
|
148
63
|
|
149
64
|
# Terminates this instance of Playwright in case it was created bypassing the Python context manager. This is useful in
|
150
65
|
# REPL applications.
|
151
|
-
#
|
66
|
+
#
|
152
67
|
# ```py
|
153
68
|
# >>> from playwright.sync_api import sync_playwright
|
154
|
-
#
|
69
|
+
#
|
155
70
|
# >>> playwright = sync_playwright().start()
|
156
|
-
#
|
71
|
+
#
|
157
72
|
# >>> browser = playwright.chromium.launch()
|
158
73
|
# >>> page = browser.new_page()
|
159
74
|
# >>> page.goto("http://whatsmyuseragent.org/")
|
160
75
|
# >>> page.screenshot(path="example.png")
|
161
76
|
# >>> browser.close()
|
162
|
-
#
|
77
|
+
#
|
163
78
|
# >>> playwright.stop()
|
164
79
|
# ```
|
165
80
|
def stop
|
@@ -176,12 +91,6 @@ module Playwright
|
|
176
91
|
wrap_impl(@impl.electron)
|
177
92
|
end
|
178
93
|
|
179
|
-
# -- inherited from EventEmitter --
|
180
|
-
# @nodoc
|
181
|
-
def once(event, callback)
|
182
|
-
event_emitter_proxy.once(event, callback)
|
183
|
-
end
|
184
|
-
|
185
94
|
# -- inherited from EventEmitter --
|
186
95
|
# @nodoc
|
187
96
|
def on(event, callback)
|
@@ -194,6 +103,12 @@ module Playwright
|
|
194
103
|
event_emitter_proxy.off(event, callback)
|
195
104
|
end
|
196
105
|
|
106
|
+
# -- inherited from EventEmitter --
|
107
|
+
# @nodoc
|
108
|
+
def once(event, callback)
|
109
|
+
event_emitter_proxy.once(event, callback)
|
110
|
+
end
|
111
|
+
|
197
112
|
private def event_emitter_proxy
|
198
113
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
199
114
|
end
|
@@ -3,34 +3,21 @@ module Playwright
|
|
3
3
|
# - [`event: Page.request`] emitted when the request is issued by the page.
|
4
4
|
# - [`event: Page.response`] emitted when/if the response status and headers are received for the request.
|
5
5
|
# - [`event: Page.requestFinished`] emitted when the response body is downloaded and the request is complete.
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# If request fails at some point, then instead of `'requestfinished'` event (and possibly instead of 'response' event),
|
8
8
|
# the [`event: Page.requestFailed`] event is emitted.
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# > NOTE: HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will
|
11
11
|
# complete with `'requestfinished'` event.
|
12
|
-
#
|
12
|
+
#
|
13
13
|
# If request gets a 'redirect' response, the request is successfully finished with the 'requestfinished' event, and a new
|
14
14
|
# request is issued to a redirected url.
|
15
15
|
class Request < PlaywrightApi
|
16
16
|
|
17
17
|
# The method returns `null` unless this request has failed, as reported by `requestfailed` event.
|
18
|
-
#
|
18
|
+
#
|
19
19
|
# Example of logging of all the failed requests:
|
20
|
-
#
|
21
20
|
#
|
22
|
-
# ```js
|
23
|
-
# page.on('requestfailed', request => {
|
24
|
-
# console.log(request.url() + ' ' + request.failure().errorText);
|
25
|
-
# });
|
26
|
-
# ```
|
27
|
-
#
|
28
|
-
# ```java
|
29
|
-
# page.onRequestFailed(request -> {
|
30
|
-
# System.out.println(request.url() + " " + request.failure());
|
31
|
-
# });
|
32
|
-
# ```
|
33
|
-
#
|
34
21
|
# ```py
|
35
22
|
# page.on("requestfailed", lambda request: print(request.url + " " + request.failure))
|
36
23
|
# ```
|
@@ -69,7 +56,7 @@ module Playwright
|
|
69
56
|
end
|
70
57
|
|
71
58
|
# Returns parsed request's body for `form-urlencoded` and JSON as a fallback if any.
|
72
|
-
#
|
59
|
+
#
|
73
60
|
# When the response is `application/x-www-form-urlencoded` then a key/value object of the values will be returned.
|
74
61
|
# Otherwise it will be parsed as JSON.
|
75
62
|
def post_data_json
|
@@ -77,52 +64,20 @@ module Playwright
|
|
77
64
|
end
|
78
65
|
|
79
66
|
# Request that was redirected by the server to this one, if any.
|
80
|
-
#
|
67
|
+
#
|
81
68
|
# When the server responds with a redirect, Playwright creates a new `Request` object. The two requests are connected by
|
82
69
|
# `redirectedFrom()` and `redirectedTo()` methods. When multiple server redirects has happened, it is possible to
|
83
70
|
# construct the whole redirect chain by repeatedly calling `redirectedFrom()`.
|
84
|
-
#
|
71
|
+
#
|
85
72
|
# For example, if the website `http://example.com` redirects to `https://example.com`:
|
86
|
-
#
|
87
73
|
#
|
88
|
-
# ```js
|
89
|
-
# const response = await page.goto('http://example.com');
|
90
|
-
# console.log(response.request().redirectedFrom().url()); // 'http://example.com'
|
91
|
-
# ```
|
92
|
-
#
|
93
|
-
# ```java
|
94
|
-
# Response response = page.navigate("http://example.com");
|
95
|
-
# System.out.println(response.request().redirectedFrom().url()); // "http://example.com"
|
96
|
-
# ```
|
97
|
-
#
|
98
|
-
# ```python async
|
99
|
-
# response = await page.goto("http://example.com")
|
100
|
-
# print(response.request.redirected_from.url) # "http://example.com"
|
101
|
-
# ```
|
102
|
-
#
|
103
74
|
# ```python sync
|
104
75
|
# response = page.goto("http://example.com")
|
105
76
|
# print(response.request.redirected_from.url) # "http://example.com"
|
106
77
|
# ```
|
107
|
-
#
|
78
|
+
#
|
108
79
|
# If the website `https://google.com` has no redirects:
|
109
|
-
#
|
110
80
|
#
|
111
|
-
# ```js
|
112
|
-
# const response = await page.goto('https://google.com');
|
113
|
-
# console.log(response.request().redirectedFrom()); // null
|
114
|
-
# ```
|
115
|
-
#
|
116
|
-
# ```java
|
117
|
-
# Response response = page.navigate("https://google.com");
|
118
|
-
# System.out.println(response.request().redirectedFrom()); // null
|
119
|
-
# ```
|
120
|
-
#
|
121
|
-
# ```python async
|
122
|
-
# response = await page.goto("https://google.com")
|
123
|
-
# print(response.request.redirected_from) # None
|
124
|
-
# ```
|
125
|
-
#
|
126
81
|
# ```python sync
|
127
82
|
# response = page.goto("https://google.com")
|
128
83
|
# print(response.request.redirected_from) # None
|
@@ -132,18 +87,9 @@ module Playwright
|
|
132
87
|
end
|
133
88
|
|
134
89
|
# New request issued by the browser if the server responded with redirect.
|
135
|
-
#
|
90
|
+
#
|
136
91
|
# This method is the opposite of [`method: Request.redirectedFrom`]:
|
137
|
-
#
|
138
92
|
#
|
139
|
-
# ```js
|
140
|
-
# console.log(request.redirectedFrom().redirectedTo() === request); // true
|
141
|
-
# ```
|
142
|
-
#
|
143
|
-
# ```java
|
144
|
-
# System.out.println(request.redirectedFrom().redirectedTo() == request); // true
|
145
|
-
# ```
|
146
|
-
#
|
147
93
|
# ```py
|
148
94
|
# assert request.redirected_from.redirected_to == request
|
149
95
|
# ```
|
@@ -166,31 +112,7 @@ module Playwright
|
|
166
112
|
# Returns resource timing information for given request. Most of the timing values become available upon the response,
|
167
113
|
# `responseEnd` becomes available when request finishes. Find more information at
|
168
114
|
# [Resource Timing API](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming).
|
169
|
-
#
|
170
115
|
#
|
171
|
-
# ```js
|
172
|
-
# const [request] = await Promise.all([
|
173
|
-
# page.waitForEvent('requestfinished'),
|
174
|
-
# page.goto('http://example.com')
|
175
|
-
# ]);
|
176
|
-
# console.log(request.timing());
|
177
|
-
# ```
|
178
|
-
#
|
179
|
-
# ```java
|
180
|
-
# page.onRequestFinished(request -> {
|
181
|
-
# Timing timing = request.timing();
|
182
|
-
# System.out.println(timing.responseEnd - timing.startTime);
|
183
|
-
# });
|
184
|
-
# page.navigate("http://example.com");
|
185
|
-
# ```
|
186
|
-
#
|
187
|
-
# ```python async
|
188
|
-
# async with page.expect_event("requestfinished") as request_info:
|
189
|
-
# await page.goto("http://example.com")
|
190
|
-
# request = await request_info.value
|
191
|
-
# print(request.timing)
|
192
|
-
# ```
|
193
|
-
#
|
194
116
|
# ```python sync
|
195
117
|
# with page.expect_event("requestfinished") as request_info:
|
196
118
|
# page.goto("http://example.com")
|
@@ -206,12 +128,6 @@ module Playwright
|
|
206
128
|
wrap_impl(@impl.url)
|
207
129
|
end
|
208
130
|
|
209
|
-
# -- inherited from EventEmitter --
|
210
|
-
# @nodoc
|
211
|
-
def once(event, callback)
|
212
|
-
event_emitter_proxy.once(event, callback)
|
213
|
-
end
|
214
|
-
|
215
131
|
# -- inherited from EventEmitter --
|
216
132
|
# @nodoc
|
217
133
|
def on(event, callback)
|
@@ -224,6 +140,12 @@ module Playwright
|
|
224
140
|
event_emitter_proxy.off(event, callback)
|
225
141
|
end
|
226
142
|
|
143
|
+
# -- inherited from EventEmitter --
|
144
|
+
# @nodoc
|
145
|
+
def once(event, callback)
|
146
|
+
event_emitter_proxy.once(event, callback)
|
147
|
+
end
|
148
|
+
|
227
149
|
private def event_emitter_proxy
|
228
150
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
229
151
|
end
|
@@ -23,7 +23,7 @@ module Playwright
|
|
23
23
|
end
|
24
24
|
|
25
25
|
# Returns the JSON representation of response body.
|
26
|
-
#
|
26
|
+
#
|
27
27
|
# This method will throw if the response body is not parsable via `JSON.parse`.
|
28
28
|
def json
|
29
29
|
wrap_impl(@impl.json)
|
@@ -69,12 +69,6 @@ module Playwright
|
|
69
69
|
wrap_impl(@impl.after_initialize)
|
70
70
|
end
|
71
71
|
|
72
|
-
# -- inherited from EventEmitter --
|
73
|
-
# @nodoc
|
74
|
-
def once(event, callback)
|
75
|
-
event_emitter_proxy.once(event, callback)
|
76
|
-
end
|
77
|
-
|
78
72
|
# -- inherited from EventEmitter --
|
79
73
|
# @nodoc
|
80
74
|
def on(event, callback)
|
@@ -87,6 +81,12 @@ module Playwright
|
|
87
81
|
event_emitter_proxy.off(event, callback)
|
88
82
|
end
|
89
83
|
|
84
|
+
# -- inherited from EventEmitter --
|
85
|
+
# @nodoc
|
86
|
+
def once(event, callback)
|
87
|
+
event_emitter_proxy.once(event, callback)
|
88
|
+
end
|
89
|
+
|
90
90
|
private def event_emitter_proxy
|
91
91
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
92
92
|
end
|
data/lib/playwright_api/route.rb
CHANGED
@@ -9,43 +9,7 @@ module Playwright
|
|
9
9
|
end
|
10
10
|
|
11
11
|
# Continues route's request with optional overrides.
|
12
|
-
#
|
13
12
|
#
|
14
|
-
# ```js
|
15
|
-
# await page.route('**/*', (route, request) => {
|
16
|
-
# // Override headers
|
17
|
-
# const headers = {
|
18
|
-
# ...request.headers(),
|
19
|
-
# foo: 'bar', // set "foo" header
|
20
|
-
# origin: undefined, // remove "origin" header
|
21
|
-
# };
|
22
|
-
# route.continue({headers});
|
23
|
-
# });
|
24
|
-
# ```
|
25
|
-
#
|
26
|
-
# ```java
|
27
|
-
# page.route("**/*", route -> {
|
28
|
-
# // Override headers
|
29
|
-
# Map<String, String> headers = new HashMap<>(route.request().headers());
|
30
|
-
# headers.put("foo", "bar"); // set "foo" header
|
31
|
-
# headers.remove("origin"); // remove "origin" header
|
32
|
-
# route.resume(new Route.ResumeOptions().setHeaders(headers));
|
33
|
-
# });
|
34
|
-
# ```
|
35
|
-
#
|
36
|
-
# ```python async
|
37
|
-
# async def handle(route, request):
|
38
|
-
# # override headers
|
39
|
-
# headers = {
|
40
|
-
# **request.headers,
|
41
|
-
# "foo": "bar" # set "foo" header
|
42
|
-
# "origin": None # remove "origin" header
|
43
|
-
# }
|
44
|
-
# await route.continue(headers=headers)
|
45
|
-
# }
|
46
|
-
# await page.route("**/*", handle)
|
47
|
-
# ```
|
48
|
-
#
|
49
13
|
# ```python sync
|
50
14
|
# def handle(route, request):
|
51
15
|
# # override headers
|
@@ -54,7 +18,7 @@ module Playwright
|
|
54
18
|
# "foo": "bar" # set "foo" header
|
55
19
|
# "origin": None # remove "origin" header
|
56
20
|
# }
|
57
|
-
# route.
|
21
|
+
# route.continue_(headers=headers)
|
58
22
|
# }
|
59
23
|
# page.route("**/*", handle)
|
60
24
|
# ```
|
@@ -63,59 +27,18 @@ module Playwright
|
|
63
27
|
end
|
64
28
|
|
65
29
|
# Fulfills route's request with given response.
|
66
|
-
#
|
30
|
+
#
|
67
31
|
# An example of fulfilling all requests with 404 responses:
|
68
|
-
#
|
69
32
|
#
|
70
|
-
# ```js
|
71
|
-
# await page.route('**/*', route => {
|
72
|
-
# route.fulfill({
|
73
|
-
# status: 404,
|
74
|
-
# contentType: 'text/plain',
|
75
|
-
# body: 'Not Found!'
|
76
|
-
# });
|
77
|
-
# });
|
78
|
-
# ```
|
79
|
-
#
|
80
|
-
# ```java
|
81
|
-
# page.route("**/*", route -> {
|
82
|
-
# route.fulfill(new Route.FulfillOptions()
|
83
|
-
# .setStatus(404)
|
84
|
-
# .setContentType("text/plain")
|
85
|
-
# .setBody("Not Found!"));
|
86
|
-
# });
|
87
|
-
# ```
|
88
|
-
#
|
89
|
-
# ```python async
|
90
|
-
# await page.route("**/*", lambda route: route.fulfill(
|
91
|
-
# status=404,
|
92
|
-
# content_type="text/plain",
|
93
|
-
# body="not found!"))
|
94
|
-
# ```
|
95
|
-
#
|
96
33
|
# ```python sync
|
97
34
|
# page.route("**/*", lambda route: route.fulfill(
|
98
35
|
# status=404,
|
99
36
|
# content_type="text/plain",
|
100
37
|
# body="not found!"))
|
101
38
|
# ```
|
102
|
-
#
|
39
|
+
#
|
103
40
|
# An example of serving static file:
|
104
|
-
#
|
105
41
|
#
|
106
|
-
# ```js
|
107
|
-
# await page.route('**/xhr_endpoint', route => route.fulfill({ path: 'mock_data.json' }));
|
108
|
-
# ```
|
109
|
-
#
|
110
|
-
# ```java
|
111
|
-
# page.route("**/xhr_endpoint", route -> route.fulfill(
|
112
|
-
# new Route.FulfillOptions().setPath(Paths.get("mock_data.json")));
|
113
|
-
# ```
|
114
|
-
#
|
115
|
-
# ```python async
|
116
|
-
# await page.route("**/xhr_endpoint", lambda route: route.fulfill(path="mock_data.json"))
|
117
|
-
# ```
|
118
|
-
#
|
119
42
|
# ```python sync
|
120
43
|
# page.route("**/xhr_endpoint", lambda route: route.fulfill(path="mock_data.json"))
|
121
44
|
# ```
|
@@ -133,12 +56,6 @@ module Playwright
|
|
133
56
|
wrap_impl(@impl.request)
|
134
57
|
end
|
135
58
|
|
136
|
-
# -- inherited from EventEmitter --
|
137
|
-
# @nodoc
|
138
|
-
def once(event, callback)
|
139
|
-
event_emitter_proxy.once(event, callback)
|
140
|
-
end
|
141
|
-
|
142
59
|
# -- inherited from EventEmitter --
|
143
60
|
# @nodoc
|
144
61
|
def on(event, callback)
|
@@ -151,6 +68,12 @@ module Playwright
|
|
151
68
|
event_emitter_proxy.off(event, callback)
|
152
69
|
end
|
153
70
|
|
71
|
+
# -- inherited from EventEmitter --
|
72
|
+
# @nodoc
|
73
|
+
def once(event, callback)
|
74
|
+
event_emitter_proxy.once(event, callback)
|
75
|
+
end
|
76
|
+
|
154
77
|
private def event_emitter_proxy
|
155
78
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
156
79
|
end
|