playwright-ruby-client 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +114 -2
- data/docs/api_coverage.md +351 -0
- data/lib/playwright.rb +7 -1
- data/lib/playwright/android_input_impl.rb +23 -0
- data/lib/playwright/api_implementation.rb +18 -0
- data/lib/playwright/channel.rb +7 -0
- data/lib/playwright/channel_owner.rb +3 -2
- data/lib/playwright/channel_owners/android.rb +10 -1
- data/lib/playwright/channel_owners/android_device.rb +163 -0
- data/lib/playwright/channel_owners/browser.rb +13 -13
- data/lib/playwright/channel_owners/browser_context.rb +9 -1
- data/lib/playwright/channel_owners/download.rb +27 -0
- data/lib/playwright/channel_owners/element_handle.rb +306 -0
- data/lib/playwright/channel_owners/frame.rb +371 -19
- data/lib/playwright/channel_owners/js_handle.rb +51 -0
- data/lib/playwright/channel_owners/page.rb +416 -19
- data/lib/playwright/channel_owners/request.rb +98 -0
- data/lib/playwright/channel_owners/webkit_browser.rb +1 -1
- data/lib/playwright/connection.rb +9 -6
- data/lib/playwright/errors.rb +2 -2
- data/lib/playwright/event_emitter.rb +8 -1
- data/lib/playwright/event_emitter_proxy.rb +49 -0
- data/lib/playwright/file_chooser_impl.rb +23 -0
- data/lib/playwright/http_headers.rb +20 -0
- data/lib/playwright/input_files.rb +42 -0
- data/lib/playwright/javascript/expression.rb +37 -0
- data/lib/playwright/javascript/function.rb +37 -0
- data/lib/playwright/javascript/value_parser.rb +1 -1
- data/lib/playwright/javascript/value_serializer.rb +11 -11
- data/lib/playwright/keyboard_impl.rb +36 -0
- data/lib/playwright/mouse_impl.rb +7 -0
- data/lib/playwright/playwright_api.rb +84 -29
- data/lib/playwright/select_option_values.rb +32 -0
- data/lib/playwright/timeout_settings.rb +2 -2
- data/lib/playwright/touchscreen_impl.rb +7 -0
- data/lib/playwright/url_matcher.rb +19 -0
- data/lib/playwright/utils.rb +18 -0
- data/lib/playwright/version.rb +1 -1
- data/lib/playwright/wait_helper.rb +1 -1
- data/lib/playwright_api/accessibility.rb +46 -6
- data/lib/playwright_api/android.rb +37 -0
- data/lib/playwright_api/android_device.rb +82 -0
- data/lib/playwright_api/android_input.rb +25 -0
- data/lib/playwright_api/binding_call.rb +10 -6
- data/lib/playwright_api/browser.rb +85 -18
- data/lib/playwright_api/browser_context.rb +269 -37
- data/lib/playwright_api/browser_type.rb +60 -11
- data/lib/playwright_api/cdp_session.rb +23 -1
- data/lib/playwright_api/chromium_browser_context.rb +18 -6
- data/lib/playwright_api/console_message.rb +14 -15
- data/lib/playwright_api/dialog.rb +48 -2
- data/lib/playwright_api/download.rb +47 -10
- data/lib/playwright_api/element_handle.rb +269 -110
- data/lib/playwright_api/file_chooser.rb +23 -7
- data/lib/playwright_api/frame.rb +439 -154
- data/lib/playwright_api/js_handle.rb +69 -24
- data/lib/playwright_api/keyboard.rb +99 -9
- data/lib/playwright_api/mouse.rb +22 -0
- data/lib/playwright_api/page.rb +856 -229
- data/lib/playwright_api/playwright.rb +108 -20
- data/lib/playwright_api/request.rb +77 -29
- data/lib/playwright_api/response.rb +10 -13
- data/lib/playwright_api/route.rb +49 -0
- data/lib/playwright_api/selectors.rb +20 -8
- data/lib/playwright_api/video.rb +8 -0
- data/lib/playwright_api/web_socket.rb +0 -8
- data/lib/playwright_api/worker.rb +25 -13
- data/playwright.gemspec +1 -0
- metadata +33 -2
@@ -15,18 +15,46 @@ module Playwright
|
|
15
15
|
# })();
|
16
16
|
# ```
|
17
17
|
#
|
18
|
-
#
|
19
|
-
#
|
18
|
+
# ```python async
|
19
|
+
# import asyncio
|
20
|
+
# from playwright.async_api import async_playwright
|
21
|
+
#
|
22
|
+
# async def run(playwright):
|
23
|
+
# chromium = playwright.chromium # or "firefox" or "webkit".
|
24
|
+
# browser = await chromium.launch()
|
25
|
+
# page = await browser.new_page()
|
26
|
+
# await page.goto("http://example.com")
|
27
|
+
# # other actions...
|
28
|
+
# await browser.close()
|
29
|
+
#
|
30
|
+
# async def main():
|
31
|
+
# async with async_playwright() as playwright:
|
32
|
+
# await run(playwright)
|
33
|
+
# asyncio.run(main())
|
34
|
+
# ```
|
35
|
+
#
|
36
|
+
# ```python sync
|
37
|
+
# from playwright.sync_api import sync_playwright
|
38
|
+
#
|
39
|
+
# def run(playwright):
|
40
|
+
# chromium = playwright.chromium # or "firefox" or "webkit".
|
41
|
+
# browser = chromium.launch()
|
42
|
+
# page = browser.new_page()
|
43
|
+
# page.goto("http://example.com")
|
44
|
+
# # other actions...
|
45
|
+
# browser.close()
|
46
|
+
#
|
47
|
+
# with sync_playwright() as playwright:
|
48
|
+
# run(playwright)
|
49
|
+
# ```
|
20
50
|
class Playwright < PlaywrightApi
|
21
51
|
|
22
52
|
# This object can be used to launch or connect to Chromium, returning instances of `ChromiumBrowser`.
|
23
53
|
def chromium # property
|
24
|
-
|
54
|
+
wrap_impl(@impl.chromium)
|
25
55
|
end
|
26
56
|
|
27
|
-
# Returns a
|
28
|
-
# devices can be found in
|
29
|
-
# [src/server/deviceDescriptors.ts](https://github.com/Microsoft/playwright/blob/master/src/server/deviceDescriptors.ts).
|
57
|
+
# Returns a dictionary of devices to be used with [`method: Browser.newContext`] or [`method: Browser.newPage`].
|
30
58
|
#
|
31
59
|
#
|
32
60
|
# ```js
|
@@ -44,8 +72,45 @@ module Playwright
|
|
44
72
|
# await browser.close();
|
45
73
|
# })();
|
46
74
|
# ```
|
75
|
+
#
|
76
|
+
# ```python async
|
77
|
+
# import asyncio
|
78
|
+
# from playwright.async_api import async_playwright
|
79
|
+
#
|
80
|
+
# async def run(playwright):
|
81
|
+
# webkit = playwright.webkit
|
82
|
+
# iphone = playwright.devices["iPhone 6"]
|
83
|
+
# browser = await webkit.launch()
|
84
|
+
# context = await browser.new_context(**iphone)
|
85
|
+
# page = await context.new_page()
|
86
|
+
# await page.goto("http://example.com")
|
87
|
+
# # other actions...
|
88
|
+
# await browser.close()
|
89
|
+
#
|
90
|
+
# async def main():
|
91
|
+
# async with async_playwright() as playwright:
|
92
|
+
# await run(playwright)
|
93
|
+
# asyncio.run(main())
|
94
|
+
# ```
|
95
|
+
#
|
96
|
+
# ```python sync
|
97
|
+
# from playwright.sync_api import sync_playwright
|
98
|
+
#
|
99
|
+
# def run(playwright):
|
100
|
+
# webkit = playwright.webkit
|
101
|
+
# iphone = playwright.devices["iPhone 6"]
|
102
|
+
# browser = webkit.launch()
|
103
|
+
# context = browser.new_context(**iphone)
|
104
|
+
# page = context.new_page()
|
105
|
+
# page.goto("http://example.com")
|
106
|
+
# # other actions...
|
107
|
+
# browser.close()
|
108
|
+
#
|
109
|
+
# with sync_playwright() as playwright:
|
110
|
+
# run(playwright)
|
111
|
+
# ```
|
47
112
|
def devices # property
|
48
|
-
|
113
|
+
wrap_impl(@impl.devices)
|
49
114
|
end
|
50
115
|
|
51
116
|
# Playwright methods might throw errors if they are unable to fulfill a request. For example,
|
@@ -66,52 +131,75 @@ module Playwright
|
|
66
131
|
# }
|
67
132
|
# }
|
68
133
|
# ```
|
134
|
+
#
|
135
|
+
# ```python async
|
136
|
+
# try:
|
137
|
+
# await page.wait_for_selector(".foo")
|
138
|
+
# except TimeoutError as e:
|
139
|
+
# # do something if this is a timeout.
|
140
|
+
# ```
|
141
|
+
#
|
142
|
+
# ```python sync
|
143
|
+
# try:
|
144
|
+
# page.wait_for_selector(".foo")
|
145
|
+
# except TimeoutError as e:
|
146
|
+
# # do something if this is a timeout.
|
147
|
+
# ```
|
69
148
|
def errors # property
|
70
149
|
raise NotImplementedError.new('errors is not implemented yet.')
|
71
150
|
end
|
72
151
|
|
73
152
|
# This object can be used to launch or connect to Firefox, returning instances of `FirefoxBrowser`.
|
74
153
|
def firefox # property
|
75
|
-
|
154
|
+
wrap_impl(@impl.firefox)
|
76
155
|
end
|
77
156
|
|
78
|
-
# Selectors can be used to install custom selector engines. See
|
79
|
-
#
|
157
|
+
# Selectors can be used to install custom selector engines. See [Working with selectors](./selectors.md) for more
|
158
|
+
# information.
|
80
159
|
def selectors # property
|
81
160
|
raise NotImplementedError.new('selectors is not implemented yet.')
|
82
161
|
end
|
83
162
|
|
84
163
|
# This object can be used to launch or connect to WebKit, returning instances of `WebKitBrowser`.
|
85
164
|
def webkit # property
|
86
|
-
|
165
|
+
wrap_impl(@impl.webkit)
|
87
166
|
end
|
88
167
|
|
89
|
-
#
|
90
|
-
def
|
91
|
-
|
168
|
+
# Terminates this instance of Playwright, will also close all created browsers if they are still running.
|
169
|
+
def close
|
170
|
+
raise NotImplementedError.new('close is not implemented yet.')
|
92
171
|
end
|
93
172
|
|
94
173
|
# @nodoc
|
95
174
|
def electron
|
96
|
-
|
175
|
+
wrap_impl(@impl.electron)
|
97
176
|
end
|
98
177
|
|
99
|
-
# -- inherited from EventEmitter --
|
100
178
|
# @nodoc
|
101
|
-
def
|
102
|
-
|
179
|
+
def android
|
180
|
+
wrap_impl(@impl.android)
|
103
181
|
end
|
104
182
|
|
105
183
|
# -- inherited from EventEmitter --
|
106
184
|
# @nodoc
|
107
185
|
def once(event, callback)
|
108
|
-
|
186
|
+
event_emitter_proxy.once(event, callback)
|
109
187
|
end
|
110
188
|
|
111
189
|
# -- inherited from EventEmitter --
|
112
190
|
# @nodoc
|
113
191
|
def on(event, callback)
|
114
|
-
|
192
|
+
event_emitter_proxy.on(event, callback)
|
193
|
+
end
|
194
|
+
|
195
|
+
# -- inherited from EventEmitter --
|
196
|
+
# @nodoc
|
197
|
+
def off(event, callback)
|
198
|
+
event_emitter_proxy.off(event, callback)
|
199
|
+
end
|
200
|
+
|
201
|
+
private def event_emitter_proxy
|
202
|
+
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
115
203
|
end
|
116
204
|
end
|
117
205
|
end
|
@@ -7,8 +7,8 @@ module Playwright
|
|
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
|
-
# >
|
11
|
-
#
|
10
|
+
# > NOTE: HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will
|
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.
|
@@ -24,46 +24,42 @@ module Playwright
|
|
24
24
|
# console.log(request.url() + ' ' + request.failure().errorText);
|
25
25
|
# });
|
26
26
|
# ```
|
27
|
+
#
|
28
|
+
# ```py
|
29
|
+
# page.on("requestfailed", lambda request: print(request.url + " " + request.failure))
|
30
|
+
# ```
|
27
31
|
def failure
|
28
|
-
|
32
|
+
wrap_impl(@impl.failure)
|
29
33
|
end
|
30
34
|
|
31
35
|
# Returns the `Frame` that initiated this request.
|
32
36
|
def frame
|
33
|
-
|
37
|
+
wrap_impl(@impl.frame)
|
34
38
|
end
|
35
39
|
|
36
40
|
# An object with HTTP headers associated with the request. All header names are lower-case.
|
37
41
|
def headers
|
38
|
-
|
42
|
+
wrap_impl(@impl.headers)
|
39
43
|
end
|
40
44
|
|
41
45
|
# Whether this request is driving frame's navigation.
|
42
46
|
def navigation_request?
|
43
|
-
|
47
|
+
wrap_impl(@impl.navigation_request?)
|
44
48
|
end
|
45
49
|
|
46
50
|
# Request's method (GET, POST, etc.)
|
47
51
|
def method
|
48
|
-
|
52
|
+
wrap_impl(@impl.method)
|
49
53
|
end
|
50
54
|
|
51
55
|
# Request's post body, if any.
|
52
56
|
def post_data
|
53
|
-
|
57
|
+
wrap_impl(@impl.post_data)
|
54
58
|
end
|
55
59
|
|
56
60
|
# Request's post body in a binary form, if any.
|
57
61
|
def post_data_buffer
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
# Returns parsed request's body for `form-urlencoded` and JSON as a fallback if any.
|
62
|
-
#
|
63
|
-
# When the response is `application/x-www-form-urlencoded` then a key/value object of the values will be returned.
|
64
|
-
# Otherwise it will be parsed as JSON.
|
65
|
-
def post_data_json
|
66
|
-
raise NotImplementedError.new('post_data_json is not implemented yet.')
|
62
|
+
wrap_impl(@impl.post_data_buffer)
|
67
63
|
end
|
68
64
|
|
69
65
|
# Request that was redirected by the server to this one, if any.
|
@@ -80,6 +76,16 @@ module Playwright
|
|
80
76
|
# console.log(response.request().redirectedFrom().url()); // 'http://example.com'
|
81
77
|
# ```
|
82
78
|
#
|
79
|
+
# ```python async
|
80
|
+
# response = await page.goto("http://example.com")
|
81
|
+
# print(response.request.redirected_from.url) # "http://example.com"
|
82
|
+
# ```
|
83
|
+
#
|
84
|
+
# ```python sync
|
85
|
+
# response = page.goto("http://example.com")
|
86
|
+
# print(response.request.redirected_from.url) # "http://example.com"
|
87
|
+
# ```
|
88
|
+
#
|
83
89
|
# If the website `https://google.com` has no redirects:
|
84
90
|
#
|
85
91
|
#
|
@@ -87,8 +93,18 @@ module Playwright
|
|
87
93
|
# const response = await page.goto('https://google.com');
|
88
94
|
# console.log(response.request().redirectedFrom()); // null
|
89
95
|
# ```
|
96
|
+
#
|
97
|
+
# ```python async
|
98
|
+
# response = await page.goto("https://google.com")
|
99
|
+
# print(response.request.redirected_from) # None
|
100
|
+
# ```
|
101
|
+
#
|
102
|
+
# ```python sync
|
103
|
+
# response = page.goto("https://google.com")
|
104
|
+
# print(response.request.redirected_from) # None
|
105
|
+
# ```
|
90
106
|
def redirected_from
|
91
|
-
|
107
|
+
wrap_impl(@impl.redirected_from)
|
92
108
|
end
|
93
109
|
|
94
110
|
# New request issued by the browser if the server responded with redirect.
|
@@ -99,20 +115,24 @@ module Playwright
|
|
99
115
|
# ```js
|
100
116
|
# console.log(request.redirectedFrom().redirectedTo() === request); // true
|
101
117
|
# ```
|
118
|
+
#
|
119
|
+
# ```py
|
120
|
+
# assert request.redirected_from.redirected_to == request
|
121
|
+
# ```
|
102
122
|
def redirected_to
|
103
|
-
|
123
|
+
wrap_impl(@impl.redirected_to)
|
104
124
|
end
|
105
125
|
|
106
126
|
# Contains the request's resource type as it was perceived by the rendering engine. ResourceType will be one of the
|
107
127
|
# following: `document`, `stylesheet`, `image`, `media`, `font`, `script`, `texttrack`, `xhr`, `fetch`, `eventsource`,
|
108
128
|
# `websocket`, `manifest`, `other`.
|
109
129
|
def resource_type
|
110
|
-
|
130
|
+
wrap_impl(@impl.resource_type)
|
111
131
|
end
|
112
132
|
|
113
133
|
# Returns the matching `Response` object, or `null` if the response was not received due to error.
|
114
134
|
def response
|
115
|
-
|
135
|
+
wrap_impl(@impl.response)
|
116
136
|
end
|
117
137
|
|
118
138
|
# Returns resource timing information for given request. Most of the timing values become available upon the response,
|
@@ -123,35 +143,63 @@ module Playwright
|
|
123
143
|
# ```js
|
124
144
|
# const [request] = await Promise.all([
|
125
145
|
# page.waitForEvent('requestfinished'),
|
126
|
-
# page.goto(
|
146
|
+
# page.goto('http://example.com')
|
127
147
|
# ]);
|
128
148
|
# console.log(request.timing());
|
129
149
|
# ```
|
150
|
+
#
|
151
|
+
# ```python async
|
152
|
+
# async with page.expect_event("requestfinished") as request_info:
|
153
|
+
# await page.goto("http://example.com")
|
154
|
+
# request = await request_info.value
|
155
|
+
# print(request.timing)
|
156
|
+
# ```
|
157
|
+
#
|
158
|
+
# ```python sync
|
159
|
+
# with page.expect_event("requestfinished") as request_info:
|
160
|
+
# page.goto("http://example.com")
|
161
|
+
# request = request_info.value
|
162
|
+
# print(request.timing)
|
163
|
+
# ```
|
130
164
|
def timing
|
131
|
-
|
165
|
+
wrap_impl(@impl.timing)
|
132
166
|
end
|
133
167
|
|
134
168
|
# URL of the request.
|
135
169
|
def url
|
136
|
-
|
170
|
+
wrap_impl(@impl.url)
|
137
171
|
end
|
138
172
|
|
139
|
-
# -- inherited from EventEmitter --
|
140
173
|
# @nodoc
|
141
|
-
def
|
142
|
-
|
174
|
+
def post_data_json
|
175
|
+
wrap_impl(@impl.post_data_json)
|
176
|
+
end
|
177
|
+
|
178
|
+
# @nodoc
|
179
|
+
def after_initialize
|
180
|
+
wrap_impl(@impl.after_initialize)
|
143
181
|
end
|
144
182
|
|
145
183
|
# -- inherited from EventEmitter --
|
146
184
|
# @nodoc
|
147
185
|
def once(event, callback)
|
148
|
-
|
186
|
+
event_emitter_proxy.once(event, callback)
|
149
187
|
end
|
150
188
|
|
151
189
|
# -- inherited from EventEmitter --
|
152
190
|
# @nodoc
|
153
191
|
def on(event, callback)
|
154
|
-
|
192
|
+
event_emitter_proxy.on(event, callback)
|
193
|
+
end
|
194
|
+
|
195
|
+
# -- inherited from EventEmitter --
|
196
|
+
# @nodoc
|
197
|
+
def off(event, callback)
|
198
|
+
event_emitter_proxy.off(event, callback)
|
199
|
+
end
|
200
|
+
|
201
|
+
private def event_emitter_proxy
|
202
|
+
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
155
203
|
end
|
156
204
|
end
|
157
205
|
end
|
@@ -22,13 +22,6 @@ module Playwright
|
|
22
22
|
raise NotImplementedError.new('headers is not implemented yet.')
|
23
23
|
end
|
24
24
|
|
25
|
-
# Returns the JSON representation of response body.
|
26
|
-
#
|
27
|
-
# This method will throw if the response body is not parsable via `JSON.parse`.
|
28
|
-
def json
|
29
|
-
raise NotImplementedError.new('json is not implemented yet.')
|
30
|
-
end
|
31
|
-
|
32
25
|
# Contains a boolean stating whether the response was successful (status in the range 200-299) or not.
|
33
26
|
def ok
|
34
27
|
raise NotImplementedError.new('ok is not implemented yet.')
|
@@ -61,20 +54,24 @@ module Playwright
|
|
61
54
|
|
62
55
|
# -- inherited from EventEmitter --
|
63
56
|
# @nodoc
|
64
|
-
def
|
65
|
-
|
57
|
+
def once(event, callback)
|
58
|
+
event_emitter_proxy.once(event, callback)
|
66
59
|
end
|
67
60
|
|
68
61
|
# -- inherited from EventEmitter --
|
69
62
|
# @nodoc
|
70
|
-
def
|
71
|
-
|
63
|
+
def on(event, callback)
|
64
|
+
event_emitter_proxy.on(event, callback)
|
72
65
|
end
|
73
66
|
|
74
67
|
# -- inherited from EventEmitter --
|
75
68
|
# @nodoc
|
76
|
-
def
|
77
|
-
|
69
|
+
def off(event, callback)
|
70
|
+
event_emitter_proxy.off(event, callback)
|
71
|
+
end
|
72
|
+
|
73
|
+
private def event_emitter_proxy
|
74
|
+
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
78
75
|
end
|
79
76
|
end
|
80
77
|
end
|
data/lib/playwright_api/route.rb
CHANGED
@@ -22,6 +22,32 @@ module Playwright
|
|
22
22
|
# route.continue({headers});
|
23
23
|
# });
|
24
24
|
# ```
|
25
|
+
#
|
26
|
+
# ```python async
|
27
|
+
# async def handle(route, request):
|
28
|
+
# # override headers
|
29
|
+
# headers = {
|
30
|
+
# **request.headers,
|
31
|
+
# "foo": "bar" # set "foo" header
|
32
|
+
# "origin": None # remove "origin" header
|
33
|
+
# }
|
34
|
+
# await route.continue(headers=headers)
|
35
|
+
# }
|
36
|
+
# await page.route("**/*", handle)
|
37
|
+
# ```
|
38
|
+
#
|
39
|
+
# ```python sync
|
40
|
+
# def handle(route, request):
|
41
|
+
# # override headers
|
42
|
+
# headers = {
|
43
|
+
# **request.headers,
|
44
|
+
# "foo": "bar" # set "foo" header
|
45
|
+
# "origin": None # remove "origin" header
|
46
|
+
# }
|
47
|
+
# route.continue(headers=headers)
|
48
|
+
# }
|
49
|
+
# page.route("**/*", handle)
|
50
|
+
# ```
|
25
51
|
def continue_(headers: nil, method: nil, postData: nil, url: nil)
|
26
52
|
raise NotImplementedError.new('continue_ is not implemented yet.')
|
27
53
|
end
|
@@ -41,14 +67,37 @@ module Playwright
|
|
41
67
|
# });
|
42
68
|
# ```
|
43
69
|
#
|
70
|
+
# ```python async
|
71
|
+
# await page.route("**/*", lambda route: route.fulfill(
|
72
|
+
# status=404,
|
73
|
+
# content_type="text/plain",
|
74
|
+
# body="not found!"))
|
75
|
+
# ```
|
76
|
+
#
|
77
|
+
# ```python sync
|
78
|
+
# page.route("**/*", lambda route: route.fulfill(
|
79
|
+
# status=404,
|
80
|
+
# content_type="text/plain",
|
81
|
+
# body="not found!"))
|
82
|
+
# ```
|
83
|
+
#
|
44
84
|
# An example of serving static file:
|
45
85
|
#
|
46
86
|
#
|
47
87
|
# ```js
|
48
88
|
# await page.route('**/xhr_endpoint', route => route.fulfill({ path: 'mock_data.json' }));
|
49
89
|
# ```
|
90
|
+
#
|
91
|
+
# ```python async
|
92
|
+
# await page.route("**/xhr_endpoint", lambda route: route.fulfill(path="mock_data.json"))
|
93
|
+
# ```
|
94
|
+
#
|
95
|
+
# ```python sync
|
96
|
+
# page.route("**/xhr_endpoint", lambda route: route.fulfill(path="mock_data.json"))
|
97
|
+
# ```
|
50
98
|
def fulfill(
|
51
99
|
body: nil,
|
100
|
+
bodyBytes: nil,
|
52
101
|
contentType: nil,
|
53
102
|
headers: nil,
|
54
103
|
path: nil,
|