playwright-ruby-client 0.0.3 → 0.0.8
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 +119 -12
- data/docs/api_coverage.md +354 -0
- data/lib/playwright.rb +8 -0
- data/lib/playwright/channel_owner.rb +16 -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 +22 -29
- data/lib/playwright/channel_owners/browser_context.rb +43 -0
- data/lib/playwright/channel_owners/console_message.rb +21 -0
- data/lib/playwright/channel_owners/element_handle.rb +314 -0
- data/lib/playwright/channel_owners/frame.rb +466 -7
- data/lib/playwright/channel_owners/js_handle.rb +55 -0
- data/lib/playwright/channel_owners/page.rb +353 -5
- data/lib/playwright/channel_owners/request.rb +90 -0
- data/lib/playwright/channel_owners/webkit_browser.rb +1 -1
- data/lib/playwright/connection.rb +15 -14
- data/lib/playwright/errors.rb +1 -1
- data/lib/playwright/event_emitter.rb +13 -0
- data/lib/playwright/input_files.rb +42 -0
- data/lib/playwright/input_type.rb +19 -0
- data/lib/playwright/input_types/android_input.rb +19 -0
- data/lib/playwright/input_types/keyboard.rb +32 -0
- data/lib/playwright/input_types/mouse.rb +4 -0
- data/lib/playwright/input_types/touchscreen.rb +4 -0
- data/lib/playwright/javascript.rb +13 -0
- data/lib/playwright/javascript/expression.rb +67 -0
- data/lib/playwright/javascript/function.rb +67 -0
- data/lib/playwright/javascript/value_parser.rb +75 -0
- data/lib/playwright/javascript/value_serializer.rb +54 -0
- data/lib/playwright/playwright_api.rb +45 -25
- data/lib/playwright/select_option_values.rb +32 -0
- data/lib/playwright/timeout_settings.rb +19 -0
- data/lib/playwright/url_matcher.rb +19 -0
- data/lib/playwright/utils.rb +37 -0
- data/lib/playwright/version.rb +1 -1
- data/lib/playwright/wait_helper.rb +73 -0
- data/lib/playwright_api/accessibility.rb +60 -6
- data/lib/playwright_api/android.rb +33 -0
- data/lib/playwright_api/android_device.rb +78 -0
- data/lib/playwright_api/android_input.rb +25 -0
- data/lib/playwright_api/binding_call.rb +18 -0
- data/lib/playwright_api/browser.rb +136 -44
- data/lib/playwright_api/browser_context.rb +378 -51
- data/lib/playwright_api/browser_type.rb +137 -55
- data/lib/playwright_api/cdp_session.rb +32 -7
- data/lib/playwright_api/chromium_browser_context.rb +31 -0
- data/lib/playwright_api/console_message.rb +27 -7
- data/lib/playwright_api/dialog.rb +47 -3
- data/lib/playwright_api/download.rb +29 -5
- data/lib/playwright_api/element_handle.rb +429 -143
- data/lib/playwright_api/file_chooser.rb +13 -2
- data/lib/playwright_api/frame.rb +633 -179
- data/lib/playwright_api/js_handle.rb +97 -17
- data/lib/playwright_api/keyboard.rb +152 -24
- data/lib/playwright_api/mouse.rb +28 -3
- data/lib/playwright_api/page.rb +1183 -317
- data/lib/playwright_api/playwright.rb +174 -13
- data/lib/playwright_api/request.rb +115 -30
- data/lib/playwright_api/response.rb +22 -3
- data/lib/playwright_api/route.rb +63 -4
- data/lib/playwright_api/selectors.rb +29 -7
- data/lib/playwright_api/touchscreen.rb +2 -1
- data/lib/playwright_api/video.rb +11 -1
- data/lib/playwright_api/web_socket.rb +5 -5
- data/lib/playwright_api/worker.rb +29 -5
- data/playwright.gemspec +3 -0
- metadata +68 -2
@@ -0,0 +1,33 @@
|
|
1
|
+
module Playwright
|
2
|
+
# @nodoc
|
3
|
+
class Android < PlaywrightApi
|
4
|
+
|
5
|
+
# @nodoc
|
6
|
+
def devices
|
7
|
+
wrap_impl(@impl.devices)
|
8
|
+
end
|
9
|
+
|
10
|
+
# @nodoc
|
11
|
+
def after_initialize
|
12
|
+
wrap_impl(@impl.after_initialize)
|
13
|
+
end
|
14
|
+
|
15
|
+
# -- inherited from EventEmitter --
|
16
|
+
# @nodoc
|
17
|
+
def on(event, callback)
|
18
|
+
wrap_impl(@impl.on(unwrap_impl(event), unwrap_impl(callback)))
|
19
|
+
end
|
20
|
+
|
21
|
+
# -- inherited from EventEmitter --
|
22
|
+
# @nodoc
|
23
|
+
def off(event, callback)
|
24
|
+
wrap_impl(@impl.off(unwrap_impl(event), unwrap_impl(callback)))
|
25
|
+
end
|
26
|
+
|
27
|
+
# -- inherited from EventEmitter --
|
28
|
+
# @nodoc
|
29
|
+
def once(event, callback)
|
30
|
+
wrap_impl(@impl.once(unwrap_impl(event), unwrap_impl(callback)))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module Playwright
|
2
|
+
# @nodoc
|
3
|
+
class AndroidDevice < PlaywrightApi
|
4
|
+
|
5
|
+
# @nodoc
|
6
|
+
def tree
|
7
|
+
wrap_impl(@impl.tree)
|
8
|
+
end
|
9
|
+
|
10
|
+
# @nodoc
|
11
|
+
def close
|
12
|
+
wrap_impl(@impl.close)
|
13
|
+
end
|
14
|
+
|
15
|
+
# @nodoc
|
16
|
+
def after_initialize
|
17
|
+
wrap_impl(@impl.after_initialize)
|
18
|
+
end
|
19
|
+
|
20
|
+
# @nodoc
|
21
|
+
def tap_on(selector, duration: nil, timeout: nil)
|
22
|
+
wrap_impl(@impl.tap_on(unwrap_impl(selector), duration: unwrap_impl(duration), timeout: unwrap_impl(timeout)))
|
23
|
+
end
|
24
|
+
|
25
|
+
# @nodoc
|
26
|
+
def screenshot(path: nil)
|
27
|
+
wrap_impl(@impl.screenshot(path: unwrap_impl(path)))
|
28
|
+
end
|
29
|
+
|
30
|
+
# @nodoc
|
31
|
+
def shell(command)
|
32
|
+
wrap_impl(@impl.shell(unwrap_impl(command)))
|
33
|
+
end
|
34
|
+
|
35
|
+
# @nodoc
|
36
|
+
def input
|
37
|
+
wrap_impl(@impl.input)
|
38
|
+
end
|
39
|
+
|
40
|
+
# @nodoc
|
41
|
+
def launch_browser(pkg: nil, acceptDownloads: nil, bypassCSP: nil, colorScheme: nil, deviceScaleFactor: nil, extraHTTPHeaders: nil, geolocation: nil, hasTouch: nil, httpCredentials: nil, ignoreHTTPSErrors: nil, isMobile: nil, javaScriptEnabled: nil, locale: nil, logger: nil, offline: nil, permissions: nil, proxy: nil, recordHar: nil, recordVideo: nil, storageState: nil, timezoneId: nil, userAgent: nil, videoSize: nil, videosPath: nil, viewport: nil, &block)
|
42
|
+
wrap_impl(@impl.launch_browser(pkg: unwrap_impl(pkg), acceptDownloads: unwrap_impl(acceptDownloads), bypassCSP: unwrap_impl(bypassCSP), colorScheme: unwrap_impl(colorScheme), deviceScaleFactor: unwrap_impl(deviceScaleFactor), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), geolocation: unwrap_impl(geolocation), hasTouch: unwrap_impl(hasTouch), httpCredentials: unwrap_impl(httpCredentials), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), isMobile: unwrap_impl(isMobile), javaScriptEnabled: unwrap_impl(javaScriptEnabled), locale: unwrap_impl(locale), logger: unwrap_impl(logger), offline: unwrap_impl(offline), permissions: unwrap_impl(permissions), proxy: unwrap_impl(proxy), recordHar: unwrap_impl(recordHar), recordVideo: unwrap_impl(recordVideo), storageState: unwrap_impl(storageState), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), videoSize: unwrap_impl(videoSize), videosPath: unwrap_impl(videosPath), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
|
43
|
+
end
|
44
|
+
|
45
|
+
# @nodoc
|
46
|
+
def info(selector)
|
47
|
+
wrap_impl(@impl.info(unwrap_impl(selector)))
|
48
|
+
end
|
49
|
+
|
50
|
+
# @nodoc
|
51
|
+
def serial
|
52
|
+
wrap_impl(@impl.serial)
|
53
|
+
end
|
54
|
+
|
55
|
+
# @nodoc
|
56
|
+
def model
|
57
|
+
wrap_impl(@impl.model)
|
58
|
+
end
|
59
|
+
|
60
|
+
# -- inherited from EventEmitter --
|
61
|
+
# @nodoc
|
62
|
+
def on(event, callback)
|
63
|
+
wrap_impl(@impl.on(unwrap_impl(event), unwrap_impl(callback)))
|
64
|
+
end
|
65
|
+
|
66
|
+
# -- inherited from EventEmitter --
|
67
|
+
# @nodoc
|
68
|
+
def off(event, callback)
|
69
|
+
wrap_impl(@impl.off(unwrap_impl(event), unwrap_impl(callback)))
|
70
|
+
end
|
71
|
+
|
72
|
+
# -- inherited from EventEmitter --
|
73
|
+
# @nodoc
|
74
|
+
def once(event, callback)
|
75
|
+
wrap_impl(@impl.once(unwrap_impl(event), unwrap_impl(callback)))
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Playwright
|
2
|
+
# @nodoc
|
3
|
+
class AndroidInput < PlaywrightApi
|
4
|
+
|
5
|
+
# @nodoc
|
6
|
+
def type(text)
|
7
|
+
wrap_impl(@impl.type(unwrap_impl(text)))
|
8
|
+
end
|
9
|
+
|
10
|
+
# @nodoc
|
11
|
+
def tap_point(point)
|
12
|
+
wrap_impl(@impl.tap_point(unwrap_impl(point)))
|
13
|
+
end
|
14
|
+
|
15
|
+
# @nodoc
|
16
|
+
def press(key)
|
17
|
+
wrap_impl(@impl.press(unwrap_impl(key)))
|
18
|
+
end
|
19
|
+
|
20
|
+
# @nodoc
|
21
|
+
def drag(from, to, steps)
|
22
|
+
wrap_impl(@impl.drag(unwrap_impl(from), unwrap_impl(to), unwrap_impl(steps)))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,5 +1,23 @@
|
|
1
1
|
module Playwright
|
2
2
|
# @nodoc
|
3
3
|
class BindingCall < PlaywrightApi
|
4
|
+
|
5
|
+
# -- inherited from EventEmitter --
|
6
|
+
# @nodoc
|
7
|
+
def on(event, callback)
|
8
|
+
wrap_impl(@impl.on(unwrap_impl(event), unwrap_impl(callback)))
|
9
|
+
end
|
10
|
+
|
11
|
+
# -- inherited from EventEmitter --
|
12
|
+
# @nodoc
|
13
|
+
def off(event, callback)
|
14
|
+
wrap_impl(@impl.off(unwrap_impl(event), unwrap_impl(callback)))
|
15
|
+
end
|
16
|
+
|
17
|
+
# -- inherited from EventEmitter --
|
18
|
+
# @nodoc
|
19
|
+
def once(event, callback)
|
20
|
+
wrap_impl(@impl.once(unwrap_impl(event), unwrap_impl(callback)))
|
21
|
+
end
|
4
22
|
end
|
5
23
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Playwright
|
2
|
-
#
|
3
|
-
#
|
2
|
+
# - extends: [EventEmitter]
|
3
|
+
#
|
4
|
+
# A Browser is created via [`method: BrowserType.launch`]. An example of using a `Browser` to create a [Page]:
|
5
|
+
#
|
4
6
|
#
|
5
7
|
# ```js
|
6
8
|
# const { firefox } = require('playwright'); // Or 'chromium' or 'webkit'.
|
@@ -12,17 +14,52 @@ module Playwright
|
|
12
14
|
# await browser.close();
|
13
15
|
# })();
|
14
16
|
# ```
|
15
|
-
#
|
17
|
+
#
|
18
|
+
# ```python async
|
19
|
+
# import asyncio
|
20
|
+
# from playwright.async_api import async_playwright
|
21
|
+
#
|
22
|
+
# async def run(playwright):
|
23
|
+
# firefox = playwright.firefox
|
24
|
+
# browser = await firefox.launch()
|
25
|
+
# page = await browser.new_page()
|
26
|
+
# await page.goto("https://example.com")
|
27
|
+
# await browser.close()
|
28
|
+
#
|
29
|
+
# async def main():
|
30
|
+
# async with async_playwright() as playwright:
|
31
|
+
# await run(playwright)
|
32
|
+
# asyncio.run(main())
|
33
|
+
# ```
|
34
|
+
#
|
35
|
+
# ```python sync
|
36
|
+
# from playwright.sync_api import sync_playwright
|
37
|
+
#
|
38
|
+
# def run(playwright):
|
39
|
+
# firefox = playwright.firefox
|
40
|
+
# browser = firefox.launch()
|
41
|
+
# page = browser.new_page()
|
42
|
+
# page.goto("https://example.com")
|
43
|
+
# browser.close()
|
44
|
+
#
|
45
|
+
# with sync_playwright() as playwright:
|
46
|
+
# run(playwright)
|
47
|
+
# ```
|
16
48
|
class Browser < PlaywrightApi
|
17
49
|
|
18
|
-
# In case this browser is obtained using `
|
19
|
-
#
|
20
|
-
#
|
50
|
+
# In case this browser is obtained using [`method: BrowserType.launch`], closes the browser and all of its pages (if any
|
51
|
+
# were opened).
|
52
|
+
#
|
53
|
+
# In case this browser is connected to, clears all created contexts belonging to this browser and disconnects from the
|
54
|
+
# browser server.
|
55
|
+
#
|
56
|
+
# The `Browser` object itself is considered to be disposed and cannot be used anymore.
|
21
57
|
def close
|
22
|
-
|
58
|
+
wrap_impl(@impl.close)
|
23
59
|
end
|
24
60
|
|
25
61
|
# Returns an array of all open browser contexts. In a newly created browser, this will return zero browser contexts.
|
62
|
+
#
|
26
63
|
#
|
27
64
|
# ```js
|
28
65
|
# const browser = await pw.webkit.launch();
|
@@ -31,16 +68,31 @@ module Playwright
|
|
31
68
|
# const context = await browser.newContext();
|
32
69
|
# console.log(browser.contexts().length); // prints `1`
|
33
70
|
# ```
|
71
|
+
#
|
72
|
+
# ```python async
|
73
|
+
# browser = await pw.webkit.launch()
|
74
|
+
# print(len(browser.contexts())) # prints `0`
|
75
|
+
# context = await browser.new_context()
|
76
|
+
# print(len(browser.contexts())) # prints `1`
|
77
|
+
# ```
|
78
|
+
#
|
79
|
+
# ```python sync
|
80
|
+
# browser = pw.webkit.launch()
|
81
|
+
# print(len(browser.contexts())) # prints `0`
|
82
|
+
# context = browser.new_context()
|
83
|
+
# print(len(browser.contexts())) # prints `1`
|
84
|
+
# ```
|
34
85
|
def contexts
|
35
|
-
|
86
|
+
wrap_impl(@impl.contexts)
|
36
87
|
end
|
37
88
|
|
38
89
|
# Indicates that the browser is connected.
|
39
90
|
def connected?
|
40
|
-
|
91
|
+
wrap_impl(@impl.connected?)
|
41
92
|
end
|
42
93
|
|
43
94
|
# Creates a new browser context. It won't share cookies/cache with other browser contexts.
|
95
|
+
#
|
44
96
|
#
|
45
97
|
# ```js
|
46
98
|
# (async () => {
|
@@ -52,72 +104,112 @@ module Playwright
|
|
52
104
|
# await page.goto('https://example.com');
|
53
105
|
# })();
|
54
106
|
# ```
|
107
|
+
#
|
108
|
+
# ```python async
|
109
|
+
# browser = await playwright.firefox.launch() # or "chromium" or "webkit".
|
110
|
+
# # create a new incognito browser context.
|
111
|
+
# context = await browser.new_context()
|
112
|
+
# # create a new page in a pristine context.
|
113
|
+
# page = await context.new_page()
|
114
|
+
# await page.goto("https://example.com")
|
115
|
+
# ```
|
116
|
+
#
|
117
|
+
# ```python sync
|
118
|
+
# browser = playwright.firefox.launch() # or "chromium" or "webkit".
|
119
|
+
# # create a new incognito browser context.
|
120
|
+
# context = browser.new_context()
|
121
|
+
# # create a new page in a pristine context.
|
122
|
+
# page = context.new_page()
|
123
|
+
# page.goto("https://example.com")
|
124
|
+
# ```
|
55
125
|
def new_context(
|
56
126
|
acceptDownloads: nil,
|
57
|
-
ignoreHTTPSErrors: nil,
|
58
127
|
bypassCSP: nil,
|
59
|
-
|
60
|
-
userAgent: nil,
|
128
|
+
colorScheme: nil,
|
61
129
|
deviceScaleFactor: nil,
|
62
|
-
|
130
|
+
extraHTTPHeaders: nil,
|
131
|
+
geolocation: nil,
|
63
132
|
hasTouch: nil,
|
133
|
+
httpCredentials: nil,
|
134
|
+
ignoreHTTPSErrors: nil,
|
135
|
+
isMobile: nil,
|
64
136
|
javaScriptEnabled: nil,
|
65
|
-
timezoneId: nil,
|
66
|
-
geolocation: nil,
|
67
137
|
locale: nil,
|
68
|
-
permissions: nil,
|
69
|
-
extraHTTPHeaders: nil,
|
70
|
-
offline: nil,
|
71
|
-
httpCredentials: nil,
|
72
|
-
colorScheme: nil,
|
73
138
|
logger: nil,
|
74
|
-
|
75
|
-
|
139
|
+
offline: nil,
|
140
|
+
permissions: nil,
|
141
|
+
proxy: nil,
|
76
142
|
recordHar: nil,
|
77
143
|
recordVideo: nil,
|
78
|
-
|
79
|
-
|
80
|
-
|
144
|
+
storageState: nil,
|
145
|
+
timezoneId: nil,
|
146
|
+
userAgent: nil,
|
147
|
+
videoSize: nil,
|
148
|
+
videosPath: nil,
|
149
|
+
viewport: nil,
|
150
|
+
&block)
|
151
|
+
wrap_impl(@impl.new_context(acceptDownloads: unwrap_impl(acceptDownloads), bypassCSP: unwrap_impl(bypassCSP), colorScheme: unwrap_impl(colorScheme), deviceScaleFactor: unwrap_impl(deviceScaleFactor), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), geolocation: unwrap_impl(geolocation), hasTouch: unwrap_impl(hasTouch), httpCredentials: unwrap_impl(httpCredentials), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), isMobile: unwrap_impl(isMobile), javaScriptEnabled: unwrap_impl(javaScriptEnabled), locale: unwrap_impl(locale), logger: unwrap_impl(logger), offline: unwrap_impl(offline), permissions: unwrap_impl(permissions), proxy: unwrap_impl(proxy), recordHar: unwrap_impl(recordHar), recordVideo: unwrap_impl(recordVideo), storageState: unwrap_impl(storageState), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), videoSize: unwrap_impl(videoSize), videosPath: unwrap_impl(videosPath), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
|
81
152
|
end
|
82
153
|
|
83
154
|
# Creates a new page in a new browser context. Closing this page will close the context as well.
|
84
|
-
#
|
155
|
+
#
|
156
|
+
# This is a convenience API that should only be used for the single-page scenarios and short snippets. Production code and
|
157
|
+
# testing frameworks should explicitly create [`method: Browser.newContext`] followed by the
|
158
|
+
# [`method: BrowserContext.newPage`] to control their exact life times.
|
85
159
|
def new_page(
|
86
160
|
acceptDownloads: nil,
|
87
|
-
ignoreHTTPSErrors: nil,
|
88
161
|
bypassCSP: nil,
|
89
|
-
|
90
|
-
userAgent: nil,
|
162
|
+
colorScheme: nil,
|
91
163
|
deviceScaleFactor: nil,
|
92
|
-
|
164
|
+
extraHTTPHeaders: nil,
|
165
|
+
geolocation: nil,
|
93
166
|
hasTouch: nil,
|
167
|
+
httpCredentials: nil,
|
168
|
+
ignoreHTTPSErrors: nil,
|
169
|
+
isMobile: nil,
|
94
170
|
javaScriptEnabled: nil,
|
95
|
-
timezoneId: nil,
|
96
|
-
geolocation: nil,
|
97
171
|
locale: nil,
|
98
|
-
permissions: nil,
|
99
|
-
extraHTTPHeaders: nil,
|
100
|
-
offline: nil,
|
101
|
-
httpCredentials: nil,
|
102
|
-
colorScheme: nil,
|
103
172
|
logger: nil,
|
104
|
-
|
105
|
-
|
173
|
+
offline: nil,
|
174
|
+
permissions: nil,
|
175
|
+
proxy: nil,
|
106
176
|
recordHar: nil,
|
107
177
|
recordVideo: nil,
|
108
|
-
|
109
|
-
|
110
|
-
|
178
|
+
storageState: nil,
|
179
|
+
timezoneId: nil,
|
180
|
+
userAgent: nil,
|
181
|
+
videoSize: nil,
|
182
|
+
videosPath: nil,
|
183
|
+
viewport: nil)
|
184
|
+
wrap_impl(@impl.new_page(acceptDownloads: unwrap_impl(acceptDownloads), bypassCSP: unwrap_impl(bypassCSP), colorScheme: unwrap_impl(colorScheme), deviceScaleFactor: unwrap_impl(deviceScaleFactor), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), geolocation: unwrap_impl(geolocation), hasTouch: unwrap_impl(hasTouch), httpCredentials: unwrap_impl(httpCredentials), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), isMobile: unwrap_impl(isMobile), javaScriptEnabled: unwrap_impl(javaScriptEnabled), locale: unwrap_impl(locale), logger: unwrap_impl(logger), offline: unwrap_impl(offline), permissions: unwrap_impl(permissions), proxy: unwrap_impl(proxy), recordHar: unwrap_impl(recordHar), recordVideo: unwrap_impl(recordVideo), storageState: unwrap_impl(storageState), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), videoSize: unwrap_impl(videoSize), videosPath: unwrap_impl(videosPath), viewport: unwrap_impl(viewport)))
|
111
185
|
end
|
112
186
|
|
113
187
|
# Returns the browser version.
|
114
188
|
def version
|
115
|
-
|
189
|
+
wrap_impl(@impl.version)
|
116
190
|
end
|
117
191
|
|
118
192
|
# @nodoc
|
119
193
|
def after_initialize
|
120
|
-
|
194
|
+
wrap_impl(@impl.after_initialize)
|
195
|
+
end
|
196
|
+
|
197
|
+
# -- inherited from EventEmitter --
|
198
|
+
# @nodoc
|
199
|
+
def on(event, callback)
|
200
|
+
wrap_impl(@impl.on(unwrap_impl(event), unwrap_impl(callback)))
|
201
|
+
end
|
202
|
+
|
203
|
+
# -- inherited from EventEmitter --
|
204
|
+
# @nodoc
|
205
|
+
def off(event, callback)
|
206
|
+
wrap_impl(@impl.off(unwrap_impl(event), unwrap_impl(callback)))
|
207
|
+
end
|
208
|
+
|
209
|
+
# -- inherited from EventEmitter --
|
210
|
+
# @nodoc
|
211
|
+
def once(event, callback)
|
212
|
+
wrap_impl(@impl.once(unwrap_impl(event), unwrap_impl(callback)))
|
121
213
|
end
|
122
214
|
end
|
123
215
|
end
|
@@ -1,7 +1,14 @@
|
|
1
1
|
module Playwright
|
2
|
+
# - extends: [EventEmitter]
|
3
|
+
#
|
2
4
|
# BrowserContexts provide a way to operate multiple independent browser sessions.
|
3
|
-
#
|
4
|
-
#
|
5
|
+
#
|
6
|
+
# If a page opens another page, e.g. with a `window.open` call, the popup will belong to the parent page's browser
|
7
|
+
# context.
|
8
|
+
#
|
9
|
+
# Playwright allows creation of "incognito" browser contexts with `browser.newContext()` method. "Incognito" browser
|
10
|
+
# contexts don't write any browsing data to disk.
|
11
|
+
#
|
5
12
|
#
|
6
13
|
# ```js
|
7
14
|
# // Create a new incognito browser context
|
@@ -12,29 +19,63 @@ module Playwright
|
|
12
19
|
# // Dispose context once it's no longer needed.
|
13
20
|
# await context.close();
|
14
21
|
# ```
|
22
|
+
#
|
23
|
+
# ```python async
|
24
|
+
# # create a new incognito browser context
|
25
|
+
# context = await browser.new_context()
|
26
|
+
# # create a new page inside context.
|
27
|
+
# page = await context.new_page()
|
28
|
+
# await page.goto("https://example.com")
|
29
|
+
# # dispose context once it"s no longer needed.
|
30
|
+
# await context.close()
|
31
|
+
# ```
|
32
|
+
#
|
33
|
+
# ```python sync
|
34
|
+
# # create a new incognito browser context
|
35
|
+
# context = browser.new_context()
|
36
|
+
# # create a new page inside context.
|
37
|
+
# page = context.new_page()
|
38
|
+
# page.goto("https://example.com")
|
39
|
+
# # dispose context once it"s no longer needed.
|
40
|
+
# context.close()
|
41
|
+
# ```
|
15
42
|
class BrowserContext < PlaywrightApi
|
16
43
|
|
17
|
-
# Adds cookies into this browser context. All pages within this context will have these cookies installed. Cookies can be
|
44
|
+
# Adds cookies into this browser context. All pages within this context will have these cookies installed. Cookies can be
|
45
|
+
# obtained via [`method: BrowserContext.cookies`].
|
46
|
+
#
|
18
47
|
#
|
19
48
|
# ```js
|
20
49
|
# await browserContext.addCookies([cookieObject1, cookieObject2]);
|
21
50
|
# ```
|
51
|
+
#
|
52
|
+
# ```python async
|
53
|
+
# await browser_context.add_cookies([cookie_object1, cookie_object2])
|
54
|
+
# ```
|
55
|
+
#
|
56
|
+
# ```python sync
|
57
|
+
# browser_context.add_cookies([cookie_object1, cookie_object2])
|
58
|
+
# ```
|
22
59
|
def add_cookies(cookies)
|
23
60
|
raise NotImplementedError.new('add_cookies is not implemented yet.')
|
24
61
|
end
|
25
62
|
|
26
63
|
# Adds a script which would be evaluated in one of the following scenarios:
|
64
|
+
# - Whenever a page is created in the browser context or is navigated.
|
65
|
+
# - Whenever a child frame is attached or navigated in any page in the browser context. In this case, the script is
|
66
|
+
# evaluated in the context of the newly attached frame.
|
27
67
|
#
|
28
|
-
#
|
29
|
-
#
|
68
|
+
# The script is evaluated after the document was created but before any of its scripts were run. This is useful to amend
|
69
|
+
# the JavaScript environment, e.g. to seed `Math.random`.
|
30
70
|
#
|
31
|
-
# The script is evaluated after the document was created but before any of its scripts were run. This is useful to amend the JavaScript environment, e.g. to seed `Math.random`.
|
32
71
|
# An example of overriding `Math.random` before the page loads:
|
72
|
+
#
|
33
73
|
#
|
34
|
-
# ```js
|
74
|
+
# ```js browser
|
35
75
|
# // preload.js
|
36
76
|
# Math.random = () => 42;
|
37
77
|
# ```
|
78
|
+
#
|
38
79
|
#
|
39
80
|
# ```js
|
40
81
|
# // In your playwright script, assuming the preload.js file is in same directory.
|
@@ -43,7 +84,18 @@ module Playwright
|
|
43
84
|
# });
|
44
85
|
# ```
|
45
86
|
#
|
46
|
-
#
|
87
|
+
# ```python async
|
88
|
+
# # in your playwright script, assuming the preload.js file is in same directory.
|
89
|
+
# await browser_context.add_init_script(path="preload.js")
|
90
|
+
# ```
|
91
|
+
#
|
92
|
+
# ```python sync
|
93
|
+
# # in your playwright script, assuming the preload.js file is in same directory.
|
94
|
+
# browser_context.add_init_script(path="preload.js")
|
95
|
+
# ```
|
96
|
+
#
|
97
|
+
# > NOTE: The order of evaluation of multiple scripts installed via [`method: BrowserContext.addInitScript`] and
|
98
|
+
# [`method: Page.addInitScript`] is not defined.
|
47
99
|
def add_init_script(script, arg: nil)
|
48
100
|
raise NotImplementedError.new('add_init_script is not implemented yet.')
|
49
101
|
end
|
@@ -59,6 +111,7 @@ module Playwright
|
|
59
111
|
end
|
60
112
|
|
61
113
|
# Clears all permission overrides for the browser context.
|
114
|
+
#
|
62
115
|
#
|
63
116
|
# ```js
|
64
117
|
# const context = await browser.newContext();
|
@@ -66,26 +119,48 @@ module Playwright
|
|
66
119
|
# // do stuff ..
|
67
120
|
# context.clearPermissions();
|
68
121
|
# ```
|
122
|
+
#
|
123
|
+
# ```python async
|
124
|
+
# context = await browser.new_context()
|
125
|
+
# await context.grant_permissions(["clipboard-read"])
|
126
|
+
# # do stuff ..
|
127
|
+
# context.clear_permissions()
|
128
|
+
# ```
|
129
|
+
#
|
130
|
+
# ```python sync
|
131
|
+
# context = browser.new_context()
|
132
|
+
# context.grant_permissions(["clipboard-read"])
|
133
|
+
# # do stuff ..
|
134
|
+
# context.clear_permissions()
|
135
|
+
# ```
|
69
136
|
def clear_permissions
|
70
137
|
raise NotImplementedError.new('clear_permissions is not implemented yet.')
|
71
138
|
end
|
72
139
|
|
73
140
|
# Closes the browser context. All the pages that belong to the browser context will be closed.
|
74
141
|
#
|
75
|
-
#
|
142
|
+
# > NOTE: The default browser context cannot be closed.
|
76
143
|
def close
|
77
|
-
|
144
|
+
wrap_impl(@impl.close)
|
78
145
|
end
|
79
146
|
|
80
|
-
# If no URLs are specified, this method returns all cookies. If URLs are specified, only cookies that affect those URLs
|
147
|
+
# If no URLs are specified, this method returns all cookies. If URLs are specified, only cookies that affect those URLs
|
148
|
+
# are returned.
|
81
149
|
def cookies(urls: nil)
|
82
150
|
raise NotImplementedError.new('cookies is not implemented yet.')
|
83
151
|
end
|
84
152
|
|
85
|
-
# The method adds a function called `name` on the `window` object of every frame in every page in the context. When
|
86
|
-
#
|
87
|
-
#
|
153
|
+
# The method adds a function called `name` on the `window` object of every frame in every page in the context. When
|
154
|
+
# called, the function executes `callback` and returns a [Promise] which resolves to the return value of `callback`. If
|
155
|
+
# the `callback` returns a [Promise], it will be awaited.
|
156
|
+
#
|
157
|
+
# The first argument of the `callback` function contains information about the caller: `{ browserContext: BrowserContext,
|
158
|
+
# page: Page, frame: Frame }`.
|
159
|
+
#
|
160
|
+
# See [`method: Page.exposeBinding`] for page-only version.
|
161
|
+
#
|
88
162
|
# An example of exposing page URL to all frames in all pages in the context:
|
163
|
+
#
|
89
164
|
#
|
90
165
|
# ```js
|
91
166
|
# const { webkit } = require('playwright'); // Or 'chromium' or 'firefox'.
|
@@ -107,7 +182,60 @@ module Playwright
|
|
107
182
|
# await page.click('button');
|
108
183
|
# })();
|
109
184
|
# ```
|
185
|
+
#
|
186
|
+
# ```python async
|
187
|
+
# import asyncio
|
188
|
+
# from playwright.async_api import async_playwright
|
189
|
+
#
|
190
|
+
# async def run(playwright):
|
191
|
+
# webkit = playwright.webkit
|
192
|
+
# browser = await webkit.launch(headless=false)
|
193
|
+
# context = await browser.new_context()
|
194
|
+
# await context.expose_binding("pageURL", lambda source: source["page"].url)
|
195
|
+
# page = await context.new_page()
|
196
|
+
# await page.set_content("""
|
197
|
+
# <script>
|
198
|
+
# async function onClick() {
|
199
|
+
# document.querySelector('div').textContent = await window.pageURL();
|
200
|
+
# }
|
201
|
+
# </script>
|
202
|
+
# <button onclick="onClick()">Click me</button>
|
203
|
+
# <div></div>
|
204
|
+
# """)
|
205
|
+
# await page.click("button")
|
206
|
+
#
|
207
|
+
# async def main():
|
208
|
+
# async with async_playwright() as playwright:
|
209
|
+
# await run(playwright)
|
210
|
+
# asyncio.run(main())
|
211
|
+
# ```
|
212
|
+
#
|
213
|
+
# ```python sync
|
214
|
+
# from playwright.sync_api import sync_playwright
|
215
|
+
#
|
216
|
+
# def run(playwright):
|
217
|
+
# webkit = playwright.webkit
|
218
|
+
# browser = webkit.launch(headless=false)
|
219
|
+
# context = browser.new_context()
|
220
|
+
# context.expose_binding("pageURL", lambda source: source["page"].url)
|
221
|
+
# page = context.new_page()
|
222
|
+
# page.set_content("""
|
223
|
+
# <script>
|
224
|
+
# async function onClick() {
|
225
|
+
# document.querySelector('div').textContent = await window.pageURL();
|
226
|
+
# }
|
227
|
+
# </script>
|
228
|
+
# <button onclick="onClick()">Click me</button>
|
229
|
+
# <div></div>
|
230
|
+
# """)
|
231
|
+
# page.click("button")
|
232
|
+
#
|
233
|
+
# with sync_playwright() as playwright:
|
234
|
+
# run(playwright)
|
235
|
+
# ```
|
236
|
+
#
|
110
237
|
# An example of passing an element handle:
|
238
|
+
#
|
111
239
|
#
|
112
240
|
# ```js
|
113
241
|
# await context.exposeBinding('clicked', async (source, element) => {
|
@@ -121,14 +249,47 @@ module Playwright
|
|
121
249
|
# <div>Or click me</div>
|
122
250
|
# `);
|
123
251
|
# ```
|
124
|
-
|
252
|
+
#
|
253
|
+
# ```python async
|
254
|
+
# async def print(source, element):
|
255
|
+
# print(await element.text_content())
|
256
|
+
#
|
257
|
+
# await context.expose_binding("clicked", print, handle=true)
|
258
|
+
# await page.set_content("""
|
259
|
+
# <script>
|
260
|
+
# document.addEventListener('click', event => window.clicked(event.target));
|
261
|
+
# </script>
|
262
|
+
# <div>Click me</div>
|
263
|
+
# <div>Or click me</div>
|
264
|
+
# """)
|
265
|
+
# ```
|
266
|
+
#
|
267
|
+
# ```python sync
|
268
|
+
# def print(source, element):
|
269
|
+
# print(element.text_content())
|
270
|
+
#
|
271
|
+
# context.expose_binding("clicked", print, handle=true)
|
272
|
+
# page.set_content("""
|
273
|
+
# <script>
|
274
|
+
# document.addEventListener('click', event => window.clicked(event.target));
|
275
|
+
# </script>
|
276
|
+
# <div>Click me</div>
|
277
|
+
# <div>Or click me</div>
|
278
|
+
# """)
|
279
|
+
# ```
|
280
|
+
def expose_binding(name, callback, handle: nil)
|
125
281
|
raise NotImplementedError.new('expose_binding is not implemented yet.')
|
126
282
|
end
|
127
283
|
|
128
|
-
# The method adds a function called `name` on the `window` object of every frame in every page in the context. When
|
129
|
-
#
|
130
|
-
#
|
284
|
+
# The method adds a function called `name` on the `window` object of every frame in every page in the context. When
|
285
|
+
# called, the function executes `callback` and returns a [Promise] which resolves to the return value of `callback`.
|
286
|
+
#
|
287
|
+
# If the `callback` returns a [Promise], it will be awaited.
|
288
|
+
#
|
289
|
+
# See [`method: Page.exposeFunction`] for page-only version.
|
290
|
+
#
|
131
291
|
# An example of adding an `md5` function to all pages in the context:
|
292
|
+
#
|
132
293
|
#
|
133
294
|
# ```js
|
134
295
|
# const { webkit } = require('playwright'); // Or 'chromium' or 'firefox'.
|
@@ -151,27 +312,98 @@ module Playwright
|
|
151
312
|
# await page.click('button');
|
152
313
|
# })();
|
153
314
|
# ```
|
154
|
-
|
315
|
+
#
|
316
|
+
# ```python async
|
317
|
+
# import asyncio
|
318
|
+
# import hashlib
|
319
|
+
# from playwright.async_api import async_playwright
|
320
|
+
#
|
321
|
+
# async def sha1(text):
|
322
|
+
# m = hashlib.sha1()
|
323
|
+
# m.update(bytes(text, "utf8"))
|
324
|
+
# return m.hexdigest()
|
325
|
+
#
|
326
|
+
#
|
327
|
+
# async def run(playwright):
|
328
|
+
# webkit = playwright.webkit
|
329
|
+
# browser = await webkit.launch(headless=False)
|
330
|
+
# context = await browser.new_context()
|
331
|
+
# await context.expose_function("sha1", sha1)
|
332
|
+
# page = await context.new_page()
|
333
|
+
# await page.set_content("""
|
334
|
+
# <script>
|
335
|
+
# async function onClick() {
|
336
|
+
# document.querySelector('div').textContent = await window.sha1('PLAYWRIGHT');
|
337
|
+
# }
|
338
|
+
# </script>
|
339
|
+
# <button onclick="onClick()">Click me</button>
|
340
|
+
# <div></div>
|
341
|
+
# """)
|
342
|
+
# await page.click("button")
|
343
|
+
#
|
344
|
+
# async def main():
|
345
|
+
# async with async_playwright() as playwright:
|
346
|
+
# await run(playwright)
|
347
|
+
# asyncio.run(main())
|
348
|
+
# ```
|
349
|
+
#
|
350
|
+
# ```python sync
|
351
|
+
# import hashlib
|
352
|
+
# from playwright.sync_api import sync_playwright
|
353
|
+
#
|
354
|
+
# def sha1(text):
|
355
|
+
# m = hashlib.sha1()
|
356
|
+
# m.update(bytes(text, "utf8"))
|
357
|
+
# return m.hexdigest()
|
358
|
+
#
|
359
|
+
#
|
360
|
+
# def run(playwright):
|
361
|
+
# webkit = playwright.webkit
|
362
|
+
# browser = webkit.launch(headless=False)
|
363
|
+
# context = browser.new_context()
|
364
|
+
# context.expose_function("sha1", sha1)
|
365
|
+
# page = context.new_page()
|
366
|
+
# page.expose_function("sha1", sha1)
|
367
|
+
# page.set_content("""
|
368
|
+
# <script>
|
369
|
+
# async function onClick() {
|
370
|
+
# document.querySelector('div').textContent = await window.sha1('PLAYWRIGHT');
|
371
|
+
# }
|
372
|
+
# </script>
|
373
|
+
# <button onclick="onClick()">Click me</button>
|
374
|
+
# <div></div>
|
375
|
+
# """)
|
376
|
+
# page.click("button")
|
377
|
+
#
|
378
|
+
# with sync_playwright() as playwright:
|
379
|
+
# run(playwright)
|
380
|
+
# ```
|
381
|
+
def expose_function(name, callback)
|
155
382
|
raise NotImplementedError.new('expose_function is not implemented yet.')
|
156
383
|
end
|
157
384
|
|
158
|
-
# Grants specified permissions to the browser context. Only grants corresponding permissions to the given origin if
|
385
|
+
# Grants specified permissions to the browser context. Only grants corresponding permissions to the given origin if
|
386
|
+
# specified.
|
159
387
|
def grant_permissions(permissions, origin: nil)
|
160
388
|
raise NotImplementedError.new('grant_permissions is not implemented yet.')
|
161
389
|
end
|
162
390
|
|
163
391
|
# Creates a new page in the browser context.
|
164
392
|
def new_page
|
165
|
-
|
393
|
+
wrap_impl(@impl.new_page)
|
166
394
|
end
|
167
395
|
|
168
|
-
# Returns all open pages in the context. Non visible pages, such as `"background_page"`, will not be listed here. You can
|
396
|
+
# Returns all open pages in the context. Non visible pages, such as `"background_page"`, will not be listed here. You can
|
397
|
+
# find them using [`method: ChromiumBrowserContext.backgroundPages`].
|
169
398
|
def pages
|
170
|
-
|
399
|
+
wrap_impl(@impl.pages)
|
171
400
|
end
|
172
401
|
|
173
|
-
# Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
|
402
|
+
# Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
|
403
|
+
# is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
|
404
|
+
#
|
174
405
|
# An example of a naïve handler that aborts all image requests:
|
406
|
+
#
|
175
407
|
#
|
176
408
|
# ```js
|
177
409
|
# const context = await browser.newContext();
|
@@ -180,7 +412,25 @@ module Playwright
|
|
180
412
|
# await page.goto('https://example.com');
|
181
413
|
# await browser.close();
|
182
414
|
# ```
|
415
|
+
#
|
416
|
+
# ```python async
|
417
|
+
# context = await browser.new_context()
|
418
|
+
# page = await context.new_page()
|
419
|
+
# await context.route("**/*.{png,jpg,jpeg}", lambda route: route.abort())
|
420
|
+
# await page.goto("https://example.com")
|
421
|
+
# await browser.close()
|
422
|
+
# ```
|
423
|
+
#
|
424
|
+
# ```python sync
|
425
|
+
# context = browser.new_context()
|
426
|
+
# page = context.new_page()
|
427
|
+
# context.route("**/*.{png,jpg,jpeg}", lambda route: route.abort())
|
428
|
+
# page.goto("https://example.com")
|
429
|
+
# browser.close()
|
430
|
+
# ```
|
431
|
+
#
|
183
432
|
# or the same snippet using a regex pattern instead:
|
433
|
+
#
|
184
434
|
#
|
185
435
|
# ```js
|
186
436
|
# const context = await browser.newContext();
|
@@ -189,97 +439,174 @@ module Playwright
|
|
189
439
|
# await page.goto('https://example.com');
|
190
440
|
# await browser.close();
|
191
441
|
# ```
|
192
|
-
# Page routes (set up with `page.route(url, handler)`) take precedence over browser context routes when request matches both handlers.
|
193
442
|
#
|
194
|
-
#
|
443
|
+
# ```python async
|
444
|
+
# context = await browser.new_context()
|
445
|
+
# page = await context.new_page()
|
446
|
+
# await context.route(re.compile(r"(\.png$)|(\.jpg$)"), lambda route: route.abort())
|
447
|
+
# page = await context.new_page()
|
448
|
+
# await page.goto("https://example.com")
|
449
|
+
# await browser.close()
|
450
|
+
# ```
|
451
|
+
#
|
452
|
+
# ```python sync
|
453
|
+
# context = browser.new_context()
|
454
|
+
# page = context.new_page()
|
455
|
+
# context.route(re.compile(r"(\.png$)|(\.jpg$)"), lambda route: route.abort())
|
456
|
+
# page = await context.new_page()
|
457
|
+
# page = context.new_page()
|
458
|
+
# page.goto("https://example.com")
|
459
|
+
# browser.close()
|
460
|
+
# ```
|
461
|
+
#
|
462
|
+
# Page routes (set up with [`method: Page.route`]) take precedence over browser context routes when request matches both
|
463
|
+
# handlers.
|
464
|
+
#
|
465
|
+
# > NOTE: Enabling routing disables http cache.
|
195
466
|
def route(url, handler)
|
196
467
|
raise NotImplementedError.new('route is not implemented yet.')
|
197
468
|
end
|
198
469
|
|
199
470
|
# This setting will change the default maximum navigation time for the following methods and related shortcuts:
|
471
|
+
# - [`method: Page.goBack`]
|
472
|
+
# - [`method: Page.goForward`]
|
473
|
+
# - [`method: Page.goto`]
|
474
|
+
# - [`method: Page.reload`]
|
475
|
+
# - [`method: Page.setContent`]
|
476
|
+
# - [`method: Page.waitForNavigation`]
|
200
477
|
#
|
201
|
-
# `
|
202
|
-
# `
|
203
|
-
# `page.goto(url[, options])`
|
204
|
-
# `page.reload([options])`
|
205
|
-
# `page.setContent(html[, options])`
|
206
|
-
# `page.waitForNavigation([options])`
|
207
|
-
#
|
208
|
-
#
|
209
|
-
# **NOTE** `page.setDefaultNavigationTimeout(timeout)` and `page.setDefaultTimeout(timeout)` take priority over `browserContext.setDefaultNavigationTimeout(timeout)`.
|
478
|
+
# > NOTE: [`method: Page.setDefaultNavigationTimeout`] and [`method: Page.setDefaultTimeout`] take priority over
|
479
|
+
# [`method: BrowserContext.setDefaultNavigationTimeout`].
|
210
480
|
def set_default_navigation_timeout(timeout)
|
211
481
|
raise NotImplementedError.new('set_default_navigation_timeout is not implemented yet.')
|
212
482
|
end
|
483
|
+
alias_method :default_navigation_timeout=, :set_default_navigation_timeout
|
213
484
|
|
214
485
|
# This setting will change the default maximum time for all the methods accepting `timeout` option.
|
215
486
|
#
|
216
|
-
#
|
487
|
+
# > NOTE: [`method: Page.setDefaultNavigationTimeout`], [`method: Page.setDefaultTimeout`] and
|
488
|
+
# [`method: BrowserContext.setDefaultNavigationTimeout`] take priority over [`method: BrowserContext.setDefaultTimeout`].
|
217
489
|
def set_default_timeout(timeout)
|
218
490
|
raise NotImplementedError.new('set_default_timeout is not implemented yet.')
|
219
491
|
end
|
492
|
+
alias_method :default_timeout=, :set_default_timeout
|
220
493
|
|
221
|
-
# The extra HTTP headers will be sent with every request initiated by any page in the context. These headers are merged
|
494
|
+
# The extra HTTP headers will be sent with every request initiated by any page in the context. These headers are merged
|
495
|
+
# with page-specific extra HTTP headers set with [`method: Page.setExtraHTTPHeaders`]. If page overrides a particular
|
496
|
+
# header, page-specific header value will be used instead of the browser context header value.
|
222
497
|
#
|
223
|
-
#
|
498
|
+
# > NOTE: [`method: BrowserContext.setExtraHTTPHeaders`] does not guarantee the order of headers in the outgoing requests.
|
224
499
|
def set_extra_http_headers(headers)
|
225
500
|
raise NotImplementedError.new('set_extra_http_headers is not implemented yet.')
|
226
501
|
end
|
502
|
+
alias_method :extra_http_headers=, :set_extra_http_headers
|
227
503
|
|
228
504
|
# Sets the context's geolocation. Passing `null` or `undefined` emulates position unavailable.
|
505
|
+
#
|
229
506
|
#
|
230
507
|
# ```js
|
231
508
|
# await browserContext.setGeolocation({latitude: 59.95, longitude: 30.31667});
|
232
509
|
# ```
|
233
510
|
#
|
234
|
-
#
|
511
|
+
# ```python async
|
512
|
+
# await browser_context.set_geolocation({"latitude": 59.95, "longitude": 30.31667})
|
513
|
+
# ```
|
514
|
+
#
|
515
|
+
# ```python sync
|
516
|
+
# browser_context.set_geolocation({"latitude": 59.95, "longitude": 30.31667})
|
517
|
+
# ```
|
518
|
+
#
|
519
|
+
# > NOTE: Consider using [`method: BrowserContext.grantPermissions`] to grant permissions for the browser context pages to
|
520
|
+
# read its geolocation.
|
235
521
|
def set_geolocation(geolocation)
|
236
522
|
raise NotImplementedError.new('set_geolocation is not implemented yet.')
|
237
523
|
end
|
524
|
+
alias_method :geolocation=, :set_geolocation
|
238
525
|
|
239
|
-
#
|
240
|
-
#
|
241
|
-
# **NOTE** Browsers may cache credentials after successful authentication. Passing different credentials or passing `null` to disable authentication will be unreliable. To remove or replace credentials, create a new browser context instead.
|
526
|
+
# **DEPRECATED** Browsers may cache credentials after successful authentication. Create a new browser context instead.
|
242
527
|
def set_http_credentials(httpCredentials)
|
243
528
|
raise NotImplementedError.new('set_http_credentials is not implemented yet.')
|
244
529
|
end
|
530
|
+
alias_method :http_credentials=, :set_http_credentials
|
245
531
|
|
246
532
|
def set_offline(offline)
|
247
533
|
raise NotImplementedError.new('set_offline is not implemented yet.')
|
248
534
|
end
|
535
|
+
alias_method :offline=, :set_offline
|
249
536
|
|
250
537
|
# Returns storage state for this browser context, contains current cookies and local storage snapshot.
|
251
538
|
def storage_state(path: nil)
|
252
539
|
raise NotImplementedError.new('storage_state is not implemented yet.')
|
253
540
|
end
|
254
541
|
|
255
|
-
# Removes a route created with `
|
542
|
+
# Removes a route created with [`method: BrowserContext.route`]. When `handler` is not specified, removes all routes for
|
543
|
+
# the `url`.
|
256
544
|
def unroute(url, handler: nil)
|
257
545
|
raise NotImplementedError.new('unroute is not implemented yet.')
|
258
546
|
end
|
259
547
|
|
260
|
-
# Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy
|
548
|
+
# Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy
|
549
|
+
# value. Will throw an error if the context closes before the event is fired. Returns the event data value.
|
550
|
+
#
|
261
551
|
#
|
262
552
|
# ```js
|
263
|
-
# const
|
264
|
-
#
|
553
|
+
# const [page, _] = await Promise.all([
|
554
|
+
# context.waitForEvent('page'),
|
555
|
+
# page.click('button')
|
556
|
+
# ]);
|
557
|
+
# ```
|
558
|
+
#
|
559
|
+
# ```python async
|
560
|
+
# async with context.expect_event("page") as event_info:
|
561
|
+
# await page.click("button")
|
562
|
+
# page = await event_info.value
|
265
563
|
# ```
|
266
|
-
|
267
|
-
|
564
|
+
#
|
565
|
+
# ```python sync
|
566
|
+
# with context.expect_event("page") as event_info:
|
567
|
+
# page.click("button")
|
568
|
+
# page = event_info.value
|
569
|
+
# ```
|
570
|
+
def expect_event(event, optionsOrPredicate: nil)
|
571
|
+
raise NotImplementedError.new('expect_event is not implemented yet.')
|
268
572
|
end
|
269
573
|
|
270
574
|
# @nodoc
|
271
575
|
def browser=(req)
|
272
|
-
|
576
|
+
wrap_impl(@impl.browser=(unwrap_impl(req)))
|
577
|
+
end
|
578
|
+
|
579
|
+
# @nodoc
|
580
|
+
def after_initialize
|
581
|
+
wrap_impl(@impl.after_initialize)
|
273
582
|
end
|
274
583
|
|
275
584
|
# @nodoc
|
276
585
|
def owner_page=(req)
|
277
|
-
|
586
|
+
wrap_impl(@impl.owner_page=(unwrap_impl(req)))
|
278
587
|
end
|
279
588
|
|
280
589
|
# @nodoc
|
281
590
|
def options=(req)
|
282
|
-
|
591
|
+
wrap_impl(@impl.options=(unwrap_impl(req)))
|
592
|
+
end
|
593
|
+
|
594
|
+
# -- inherited from EventEmitter --
|
595
|
+
# @nodoc
|
596
|
+
def on(event, callback)
|
597
|
+
wrap_impl(@impl.on(unwrap_impl(event), unwrap_impl(callback)))
|
598
|
+
end
|
599
|
+
|
600
|
+
# -- inherited from EventEmitter --
|
601
|
+
# @nodoc
|
602
|
+
def off(event, callback)
|
603
|
+
wrap_impl(@impl.off(unwrap_impl(event), unwrap_impl(callback)))
|
604
|
+
end
|
605
|
+
|
606
|
+
# -- inherited from EventEmitter --
|
607
|
+
# @nodoc
|
608
|
+
def once(event, callback)
|
609
|
+
wrap_impl(@impl.once(unwrap_impl(event), unwrap_impl(callback)))
|
283
610
|
end
|
284
611
|
end
|
285
612
|
end
|