playwright-ruby-client 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +49 -0
- data/Rakefile +3 -0
- data/bin/console +11 -0
- data/bin/setup +8 -0
- data/lib/playwright.rb +39 -0
- data/lib/playwright/channel.rb +28 -0
- data/lib/playwright/channel_owner.rb +80 -0
- data/lib/playwright/channel_owners/android.rb +3 -0
- data/lib/playwright/channel_owners/binding_call.rb +4 -0
- data/lib/playwright/channel_owners/browser.rb +80 -0
- data/lib/playwright/channel_owners/browser_context.rb +13 -0
- data/lib/playwright/channel_owners/browser_type.rb +26 -0
- data/lib/playwright/channel_owners/chromium_browser.rb +8 -0
- data/lib/playwright/channel_owners/chromium_browser_context.rb +8 -0
- data/lib/playwright/channel_owners/electron.rb +3 -0
- data/lib/playwright/channel_owners/firefox_browser.rb +8 -0
- data/lib/playwright/channel_owners/frame.rb +44 -0
- data/lib/playwright/channel_owners/page.rb +53 -0
- data/lib/playwright/channel_owners/playwright.rb +57 -0
- data/lib/playwright/channel_owners/request.rb +5 -0
- data/lib/playwright/channel_owners/response.rb +5 -0
- data/lib/playwright/channel_owners/selectors.rb +4 -0
- data/lib/playwright/channel_owners/webkit_browser.rb +8 -0
- data/lib/playwright/connection.rb +238 -0
- data/lib/playwright/errors.rb +35 -0
- data/lib/playwright/event_emitter.rb +62 -0
- data/lib/playwright/events.rb +86 -0
- data/lib/playwright/playwright_api.rb +75 -0
- data/lib/playwright/transport.rb +86 -0
- data/lib/playwright/version.rb +5 -0
- data/lib/playwright_api/accessibility.rb +39 -0
- data/lib/playwright_api/binding_call.rb +5 -0
- data/lib/playwright_api/browser.rb +123 -0
- data/lib/playwright_api/browser_context.rb +285 -0
- data/lib/playwright_api/browser_type.rb +144 -0
- data/lib/playwright_api/cdp_session.rb +34 -0
- data/lib/playwright_api/chromium_browser_context.rb +26 -0
- data/lib/playwright_api/console_message.rb +22 -0
- data/lib/playwright_api/dialog.rb +46 -0
- data/lib/playwright_api/download.rb +54 -0
- data/lib/playwright_api/element_handle.rb +361 -0
- data/lib/playwright_api/file_chooser.rb +31 -0
- data/lib/playwright_api/frame.rb +526 -0
- data/lib/playwright_api/js_handle.rb +69 -0
- data/lib/playwright_api/keyboard.rb +101 -0
- data/lib/playwright_api/mouse.rb +47 -0
- data/lib/playwright_api/page.rb +986 -0
- data/lib/playwright_api/playwright.rb +35 -0
- data/lib/playwright_api/request.rb +119 -0
- data/lib/playwright_api/response.rb +61 -0
- data/lib/playwright_api/route.rb +53 -0
- data/lib/playwright_api/selectors.rb +51 -0
- data/lib/playwright_api/touchscreen.rb +10 -0
- data/lib/playwright_api/video.rb +14 -0
- data/lib/playwright_api/web_socket.rb +21 -0
- data/lib/playwright_api/worker.rb +34 -0
- data/playwright.gemspec +35 -0
- metadata +216 -0
@@ -0,0 +1,285 @@
|
|
1
|
+
module Playwright
|
2
|
+
# BrowserContexts provide a way to operate multiple independent browser sessions.
|
3
|
+
# If a page opens another page, e.g. with a `window.open` call, the popup will belong to the parent page's browser context.
|
4
|
+
# Playwright allows creation of "incognito" browser contexts with `browser.newContext()` method. "Incognito" browser contexts don't write any browsing data to disk.
|
5
|
+
#
|
6
|
+
# ```js
|
7
|
+
# // Create a new incognito browser context
|
8
|
+
# const context = await browser.newContext();
|
9
|
+
# // Create a new page inside context.
|
10
|
+
# const page = await context.newPage();
|
11
|
+
# await page.goto('https://example.com');
|
12
|
+
# // Dispose context once it's no longer needed.
|
13
|
+
# await context.close();
|
14
|
+
# ```
|
15
|
+
class BrowserContext < PlaywrightApi
|
16
|
+
|
17
|
+
# Adds cookies into this browser context. All pages within this context will have these cookies installed. Cookies can be obtained via `browserContext.cookies([urls])`.
|
18
|
+
#
|
19
|
+
# ```js
|
20
|
+
# await browserContext.addCookies([cookieObject1, cookieObject2]);
|
21
|
+
# ```
|
22
|
+
def add_cookies(cookies)
|
23
|
+
raise NotImplementedError.new('add_cookies is not implemented yet.')
|
24
|
+
end
|
25
|
+
|
26
|
+
# Adds a script which would be evaluated in one of the following scenarios:
|
27
|
+
#
|
28
|
+
# Whenever a page is created in the browser context or is navigated.
|
29
|
+
# Whenever a child frame is attached or navigated in any page in the browser context. In this case, the script is evaluated in the context of the newly attached frame.
|
30
|
+
#
|
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
|
+
# An example of overriding `Math.random` before the page loads:
|
33
|
+
#
|
34
|
+
# ```js
|
35
|
+
# // preload.js
|
36
|
+
# Math.random = () => 42;
|
37
|
+
# ```
|
38
|
+
#
|
39
|
+
# ```js
|
40
|
+
# // In your playwright script, assuming the preload.js file is in same directory.
|
41
|
+
# await browserContext.addInitScript({
|
42
|
+
# path: 'preload.js'
|
43
|
+
# });
|
44
|
+
# ```
|
45
|
+
#
|
46
|
+
# **NOTE** The order of evaluation of multiple scripts installed via `browserContext.addInitScript(script[, arg])` and `page.addInitScript(script[, arg])` is not defined.
|
47
|
+
def add_init_script(script, arg: nil)
|
48
|
+
raise NotImplementedError.new('add_init_script is not implemented yet.')
|
49
|
+
end
|
50
|
+
|
51
|
+
# Returns the browser instance of the context. If it was launched as a persistent context null gets returned.
|
52
|
+
def browser
|
53
|
+
raise NotImplementedError.new('browser is not implemented yet.')
|
54
|
+
end
|
55
|
+
|
56
|
+
# Clears context cookies.
|
57
|
+
def clear_cookies
|
58
|
+
raise NotImplementedError.new('clear_cookies is not implemented yet.')
|
59
|
+
end
|
60
|
+
|
61
|
+
# Clears all permission overrides for the browser context.
|
62
|
+
#
|
63
|
+
# ```js
|
64
|
+
# const context = await browser.newContext();
|
65
|
+
# await context.grantPermissions(['clipboard-read']);
|
66
|
+
# // do stuff ..
|
67
|
+
# context.clearPermissions();
|
68
|
+
# ```
|
69
|
+
def clear_permissions
|
70
|
+
raise NotImplementedError.new('clear_permissions is not implemented yet.')
|
71
|
+
end
|
72
|
+
|
73
|
+
# Closes the browser context. All the pages that belong to the browser context will be closed.
|
74
|
+
#
|
75
|
+
# **NOTE** the default browser context cannot be closed.
|
76
|
+
def close
|
77
|
+
raise NotImplementedError.new('close is not implemented yet.')
|
78
|
+
end
|
79
|
+
|
80
|
+
# If no URLs are specified, this method returns all cookies. If URLs are specified, only cookies that affect those URLs are returned.
|
81
|
+
def cookies(urls: nil)
|
82
|
+
raise NotImplementedError.new('cookies is not implemented yet.')
|
83
|
+
end
|
84
|
+
|
85
|
+
# The method adds a function called `name` on the `window` object of every frame in every page in the context. When called, the function executes `playwrightBinding` and returns a Promise which resolves to the return value of `playwrightBinding`. If the `playwrightBinding` returns a Promise, it will be awaited.
|
86
|
+
# The first argument of the `playwrightBinding` function contains information about the caller: `{ browserContext: BrowserContext, page: Page, frame: Frame }`.
|
87
|
+
# See `page.exposeBinding(name, playwrightBinding[, options])` for page-only version.
|
88
|
+
# An example of exposing page URL to all frames in all pages in the context:
|
89
|
+
#
|
90
|
+
# ```js
|
91
|
+
# const { webkit } = require('playwright'); // Or 'chromium' or 'firefox'.
|
92
|
+
#
|
93
|
+
# (async () => {
|
94
|
+
# const browser = await webkit.launch({ headless: false });
|
95
|
+
# const context = await browser.newContext();
|
96
|
+
# await context.exposeBinding('pageURL', ({ page }) => page.url());
|
97
|
+
# const page = await context.newPage();
|
98
|
+
# await page.setContent(`
|
99
|
+
# <script>
|
100
|
+
# async function onClick() {
|
101
|
+
# document.querySelector('div').textContent = await window.pageURL();
|
102
|
+
# }
|
103
|
+
# </script>
|
104
|
+
# <button onclick="onClick()">Click me</button>
|
105
|
+
# <div></div>
|
106
|
+
# `);
|
107
|
+
# await page.click('button');
|
108
|
+
# })();
|
109
|
+
# ```
|
110
|
+
# An example of passing an element handle:
|
111
|
+
#
|
112
|
+
# ```js
|
113
|
+
# await context.exposeBinding('clicked', async (source, element) => {
|
114
|
+
# console.log(await element.textContent());
|
115
|
+
# }, { handle: true });
|
116
|
+
# await page.setContent(`
|
117
|
+
# <script>
|
118
|
+
# document.addEventListener('click', event => window.clicked(event.target));
|
119
|
+
# </script>
|
120
|
+
# <div>Click me</div>
|
121
|
+
# <div>Or click me</div>
|
122
|
+
# `);
|
123
|
+
# ```
|
124
|
+
def expose_binding(name, playwrightBinding, handle: nil)
|
125
|
+
raise NotImplementedError.new('expose_binding is not implemented yet.')
|
126
|
+
end
|
127
|
+
|
128
|
+
# The method adds a function called `name` on the `window` object of every frame in every page in the context. When called, the function executes `playwrightFunction` and returns a Promise which resolves to the return value of `playwrightFunction`.
|
129
|
+
# If the `playwrightFunction` returns a Promise, it will be awaited.
|
130
|
+
# See `page.exposeFunction(name, playwrightFunction)` for page-only version.
|
131
|
+
# An example of adding an `md5` function to all pages in the context:
|
132
|
+
#
|
133
|
+
# ```js
|
134
|
+
# const { webkit } = require('playwright'); // Or 'chromium' or 'firefox'.
|
135
|
+
# const crypto = require('crypto');
|
136
|
+
#
|
137
|
+
# (async () => {
|
138
|
+
# const browser = await webkit.launch({ headless: false });
|
139
|
+
# const context = await browser.newContext();
|
140
|
+
# await context.exposeFunction('md5', text => crypto.createHash('md5').update(text).digest('hex'));
|
141
|
+
# const page = await context.newPage();
|
142
|
+
# await page.setContent(`
|
143
|
+
# <script>
|
144
|
+
# async function onClick() {
|
145
|
+
# document.querySelector('div').textContent = await window.md5('PLAYWRIGHT');
|
146
|
+
# }
|
147
|
+
# </script>
|
148
|
+
# <button onclick="onClick()">Click me</button>
|
149
|
+
# <div></div>
|
150
|
+
# `);
|
151
|
+
# await page.click('button');
|
152
|
+
# })();
|
153
|
+
# ```
|
154
|
+
def expose_function(name, playwrightFunction)
|
155
|
+
raise NotImplementedError.new('expose_function is not implemented yet.')
|
156
|
+
end
|
157
|
+
|
158
|
+
# Grants specified permissions to the browser context. Only grants corresponding permissions to the given origin if specified.
|
159
|
+
def grant_permissions(permissions, origin: nil)
|
160
|
+
raise NotImplementedError.new('grant_permissions is not implemented yet.')
|
161
|
+
end
|
162
|
+
|
163
|
+
# Creates a new page in the browser context.
|
164
|
+
def new_page
|
165
|
+
wrap_channel_owner(@channel_owner.new_page)
|
166
|
+
end
|
167
|
+
|
168
|
+
# Returns all open pages in the context. Non visible pages, such as `"background_page"`, will not be listed here. You can find them using `chromiumBrowserContext.backgroundPages()`.
|
169
|
+
def pages
|
170
|
+
raise NotImplementedError.new('pages is not implemented yet.')
|
171
|
+
end
|
172
|
+
|
173
|
+
# Routing provides the capability to modify network requests that are made by any page in the browser context. Once route is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
|
174
|
+
# An example of a naïve handler that aborts all image requests:
|
175
|
+
#
|
176
|
+
# ```js
|
177
|
+
# const context = await browser.newContext();
|
178
|
+
# await context.route('**/*.{png,jpg,jpeg}', route => route.abort());
|
179
|
+
# const page = await context.newPage();
|
180
|
+
# await page.goto('https://example.com');
|
181
|
+
# await browser.close();
|
182
|
+
# ```
|
183
|
+
# or the same snippet using a regex pattern instead:
|
184
|
+
#
|
185
|
+
# ```js
|
186
|
+
# const context = await browser.newContext();
|
187
|
+
# await context.route(/(\.png$)|(\.jpg$)/, route => route.abort());
|
188
|
+
# const page = await context.newPage();
|
189
|
+
# await page.goto('https://example.com');
|
190
|
+
# await browser.close();
|
191
|
+
# ```
|
192
|
+
# Page routes (set up with `page.route(url, handler)`) take precedence over browser context routes when request matches both handlers.
|
193
|
+
#
|
194
|
+
# **NOTE** Enabling routing disables http cache.
|
195
|
+
def route(url, handler)
|
196
|
+
raise NotImplementedError.new('route is not implemented yet.')
|
197
|
+
end
|
198
|
+
|
199
|
+
# This setting will change the default maximum navigation time for the following methods and related shortcuts:
|
200
|
+
#
|
201
|
+
# `page.goBack([options])`
|
202
|
+
# `page.goForward([options])`
|
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)`.
|
210
|
+
def set_default_navigation_timeout(timeout)
|
211
|
+
raise NotImplementedError.new('set_default_navigation_timeout is not implemented yet.')
|
212
|
+
end
|
213
|
+
|
214
|
+
# This setting will change the default maximum time for all the methods accepting `timeout` option.
|
215
|
+
#
|
216
|
+
# **NOTE** `page.setDefaultNavigationTimeout(timeout)`, `page.setDefaultTimeout(timeout)` and `browserContext.setDefaultNavigationTimeout(timeout)` take priority over `browserContext.setDefaultTimeout(timeout)`.
|
217
|
+
def set_default_timeout(timeout)
|
218
|
+
raise NotImplementedError.new('set_default_timeout is not implemented yet.')
|
219
|
+
end
|
220
|
+
|
221
|
+
# The extra HTTP headers will be sent with every request initiated by any page in the context. These headers are merged with page-specific extra HTTP headers set with `page.setExtraHTTPHeaders(headers)`. If page overrides a particular header, page-specific header value will be used instead of the browser context header value.
|
222
|
+
#
|
223
|
+
# **NOTE** `browserContext.setExtraHTTPHeaders` does not guarantee the order of headers in the outgoing requests.
|
224
|
+
def set_extra_http_headers(headers)
|
225
|
+
raise NotImplementedError.new('set_extra_http_headers is not implemented yet.')
|
226
|
+
end
|
227
|
+
|
228
|
+
# Sets the context's geolocation. Passing `null` or `undefined` emulates position unavailable.
|
229
|
+
#
|
230
|
+
# ```js
|
231
|
+
# await browserContext.setGeolocation({latitude: 59.95, longitude: 30.31667});
|
232
|
+
# ```
|
233
|
+
#
|
234
|
+
# **NOTE** Consider using `browserContext.grantPermissions(permissions[, options])` to grant permissions for the browser context pages to read its geolocation.
|
235
|
+
def set_geolocation(geolocation)
|
236
|
+
raise NotImplementedError.new('set_geolocation is not implemented yet.')
|
237
|
+
end
|
238
|
+
|
239
|
+
# Provide credentials for HTTP authentication.
|
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.
|
242
|
+
def set_http_credentials(httpCredentials)
|
243
|
+
raise NotImplementedError.new('set_http_credentials is not implemented yet.')
|
244
|
+
end
|
245
|
+
|
246
|
+
def set_offline(offline)
|
247
|
+
raise NotImplementedError.new('set_offline is not implemented yet.')
|
248
|
+
end
|
249
|
+
|
250
|
+
# Returns storage state for this browser context, contains current cookies and local storage snapshot.
|
251
|
+
def storage_state(path: nil)
|
252
|
+
raise NotImplementedError.new('storage_state is not implemented yet.')
|
253
|
+
end
|
254
|
+
|
255
|
+
# Removes a route created with `browserContext.route(url, handler)`. When `handler` is not specified, removes all routes for the `url`.
|
256
|
+
def unroute(url, handler: nil)
|
257
|
+
raise NotImplementedError.new('unroute is not implemented yet.')
|
258
|
+
end
|
259
|
+
|
260
|
+
# Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy value. Will throw an error if the context closes before the event is fired. Returns the event data value.
|
261
|
+
#
|
262
|
+
# ```js
|
263
|
+
# const context = await browser.newContext();
|
264
|
+
# await context.grantPermissions(['geolocation']);
|
265
|
+
# ```
|
266
|
+
def wait_for_event(event, optionsOrPredicate: nil)
|
267
|
+
raise NotImplementedError.new('wait_for_event is not implemented yet.')
|
268
|
+
end
|
269
|
+
|
270
|
+
# @nodoc
|
271
|
+
def browser=(req)
|
272
|
+
wrap_channel_owner(@channel_owner.browser=(req))
|
273
|
+
end
|
274
|
+
|
275
|
+
# @nodoc
|
276
|
+
def owner_page=(req)
|
277
|
+
wrap_channel_owner(@channel_owner.owner_page=(req))
|
278
|
+
end
|
279
|
+
|
280
|
+
# @nodoc
|
281
|
+
def options=(req)
|
282
|
+
wrap_channel_owner(@channel_owner.options=(req))
|
283
|
+
end
|
284
|
+
end
|
285
|
+
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
module Playwright
|
2
|
+
# BrowserType provides methods to launch a specific browser instance or connect to an existing one. The following is a typical example of using Playwright to drive automation:
|
3
|
+
#
|
4
|
+
# ```js
|
5
|
+
# const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.
|
6
|
+
#
|
7
|
+
# (async () => {
|
8
|
+
# const browser = await chromium.launch();
|
9
|
+
# const page = await browser.newPage();
|
10
|
+
# await page.goto('https://example.com');
|
11
|
+
# // other actions...
|
12
|
+
# await browser.close();
|
13
|
+
# })();
|
14
|
+
# ```
|
15
|
+
class BrowserType < PlaywrightApi
|
16
|
+
|
17
|
+
# This methods attaches Playwright to an existing browser instance.
|
18
|
+
def connect(params)
|
19
|
+
raise NotImplementedError.new('connect is not implemented yet.')
|
20
|
+
end
|
21
|
+
|
22
|
+
# A path where Playwright expects to find a bundled browser executable.
|
23
|
+
def executable_path
|
24
|
+
wrap_channel_owner(@channel_owner.executable_path)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Returns the browser instance.
|
28
|
+
# You can use `ignoreDefaultArgs` to filter out `--mute-audio` from default arguments:
|
29
|
+
#
|
30
|
+
# ```js
|
31
|
+
# const browser = await chromium.launch({ // Or 'firefox' or 'webkit'.
|
32
|
+
# ignoreDefaultArgs: ['--mute-audio']
|
33
|
+
# });
|
34
|
+
# ```
|
35
|
+
#
|
36
|
+
# **Chromium-only** Playwright can also be used to control the Chrome browser, but it works best with the version of Chromium it is bundled with. There is no guarantee it will work with any other version. Use `executablePath` option with extreme caution.
|
37
|
+
# If Google Chrome (rather than Chromium) is preferred, a Chrome Canary or Dev Channel build is suggested.
|
38
|
+
# In `browserType.launch([options])` above, any mention of Chromium also applies to Chrome.
|
39
|
+
# See `this article` for a description of the differences between Chromium and Chrome. `This article` describes some differences for Linux users.
|
40
|
+
def launch(
|
41
|
+
headless: nil,
|
42
|
+
executablePath: nil,
|
43
|
+
args: nil,
|
44
|
+
ignoreDefaultArgs: nil,
|
45
|
+
proxy: nil,
|
46
|
+
downloadsPath: nil,
|
47
|
+
chromiumSandbox: nil,
|
48
|
+
firefoxUserPrefs: nil,
|
49
|
+
handleSIGINT: nil,
|
50
|
+
handleSIGTERM: nil,
|
51
|
+
handleSIGHUP: nil,
|
52
|
+
logger: nil,
|
53
|
+
timeout: nil,
|
54
|
+
env: nil,
|
55
|
+
devtools: nil,
|
56
|
+
slowMo: nil,
|
57
|
+
&block)
|
58
|
+
wrap_channel_owner(@channel_owner.launch(headless: headless, executablePath: executablePath, args: args, ignoreDefaultArgs: ignoreDefaultArgs, proxy: proxy, downloadsPath: downloadsPath, chromiumSandbox: chromiumSandbox, firefoxUserPrefs: firefoxUserPrefs, handleSIGINT: handleSIGINT, handleSIGTERM: handleSIGTERM, handleSIGHUP: handleSIGHUP, logger: logger, timeout: timeout, env: env, devtools: devtools, slowMo: slowMo, &wrap_block_call(block)))
|
59
|
+
end
|
60
|
+
|
61
|
+
# Returns the persistent browser context instance.
|
62
|
+
# Launches browser that uses persistent storage located at `userDataDir` and returns the only context. Closing this context will automatically close the browser.
|
63
|
+
def launch_persistent_context(
|
64
|
+
userDataDir,
|
65
|
+
headless: nil,
|
66
|
+
executablePath: nil,
|
67
|
+
args: nil,
|
68
|
+
ignoreDefaultArgs: nil,
|
69
|
+
proxy: nil,
|
70
|
+
downloadsPath: nil,
|
71
|
+
chromiumSandbox: nil,
|
72
|
+
handleSIGINT: nil,
|
73
|
+
handleSIGTERM: nil,
|
74
|
+
handleSIGHUP: nil,
|
75
|
+
timeout: nil,
|
76
|
+
env: nil,
|
77
|
+
devtools: nil,
|
78
|
+
slowMo: nil,
|
79
|
+
acceptDownloads: nil,
|
80
|
+
ignoreHTTPSErrors: nil,
|
81
|
+
bypassCSP: nil,
|
82
|
+
viewport: nil,
|
83
|
+
userAgent: nil,
|
84
|
+
deviceScaleFactor: nil,
|
85
|
+
isMobile: nil,
|
86
|
+
hasTouch: nil,
|
87
|
+
javaScriptEnabled: nil,
|
88
|
+
timezoneId: nil,
|
89
|
+
geolocation: nil,
|
90
|
+
locale: nil,
|
91
|
+
permissions: nil,
|
92
|
+
extraHTTPHeaders: nil,
|
93
|
+
offline: nil,
|
94
|
+
httpCredentials: nil,
|
95
|
+
colorScheme: nil,
|
96
|
+
logger: nil,
|
97
|
+
videosPath: nil,
|
98
|
+
videoSize: nil,
|
99
|
+
recordHar: nil,
|
100
|
+
recordVideo: nil)
|
101
|
+
raise NotImplementedError.new('launch_persistent_context is not implemented yet.')
|
102
|
+
end
|
103
|
+
|
104
|
+
# Returns the browser app instance.
|
105
|
+
# Launches browser server that client can connect to. An example of launching a browser executable and connecting to it later:
|
106
|
+
#
|
107
|
+
# ```js
|
108
|
+
# const { chromium } = require('playwright'); // Or 'webkit' or 'firefox'.
|
109
|
+
#
|
110
|
+
# (async () => {
|
111
|
+
# const browserServer = await chromium.launchServer();
|
112
|
+
# const wsEndpoint = browserServer.wsEndpoint();
|
113
|
+
# // Use web socket endpoint later to establish a connection.
|
114
|
+
# const browser = await chromium.connect({ wsEndpoint });
|
115
|
+
# // Close browser instance.
|
116
|
+
# await browserServer.close();
|
117
|
+
# })();
|
118
|
+
# ```
|
119
|
+
def launch_server(
|
120
|
+
headless: nil,
|
121
|
+
port: nil,
|
122
|
+
executablePath: nil,
|
123
|
+
args: nil,
|
124
|
+
ignoreDefaultArgs: nil,
|
125
|
+
proxy: nil,
|
126
|
+
downloadsPath: nil,
|
127
|
+
chromiumSandbox: nil,
|
128
|
+
firefoxUserPrefs: nil,
|
129
|
+
handleSIGINT: nil,
|
130
|
+
handleSIGTERM: nil,
|
131
|
+
handleSIGHUP: nil,
|
132
|
+
logger: nil,
|
133
|
+
timeout: nil,
|
134
|
+
env: nil,
|
135
|
+
devtools: nil)
|
136
|
+
raise NotImplementedError.new('launch_server is not implemented yet.')
|
137
|
+
end
|
138
|
+
|
139
|
+
# Returns browser name. For example: `'chromium'`, `'webkit'` or `'firefox'`.
|
140
|
+
def name
|
141
|
+
wrap_channel_owner(@channel_owner.name)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Playwright
|
2
|
+
# The `CDPSession` instances are used to talk raw Chrome Devtools Protocol:
|
3
|
+
#
|
4
|
+
# protocol methods can be called with `session.send` method.
|
5
|
+
# protocol events can be subscribed to with `session.on` method.
|
6
|
+
#
|
7
|
+
# Useful links:
|
8
|
+
#
|
9
|
+
# Documentation on DevTools Protocol can be found here: DevTools Protocol Viewer.
|
10
|
+
# Getting Started with DevTools Protocol: https://github.com/aslushnikov/getting-started-with-cdp/blob/master/README.md
|
11
|
+
#
|
12
|
+
#
|
13
|
+
# ```js
|
14
|
+
# const client = await page.context().newCDPSession(page);
|
15
|
+
# await client.send('Animation.enable');
|
16
|
+
# client.on('Animation.animationCreated', () => console.log('Animation created!'));
|
17
|
+
# const response = await client.send('Animation.getPlaybackRate');
|
18
|
+
# console.log('playback rate is ' + response.playbackRate);
|
19
|
+
# await client.send('Animation.setPlaybackRate', {
|
20
|
+
# playbackRate: response.playbackRate / 2
|
21
|
+
# });
|
22
|
+
# ```
|
23
|
+
class CDPSession < PlaywrightApi
|
24
|
+
|
25
|
+
# Detaches the CDPSession from the target. Once detached, the CDPSession object won't emit any events and can't be used to send messages.
|
26
|
+
def detach
|
27
|
+
raise NotImplementedError.new('detach is not implemented yet.')
|
28
|
+
end
|
29
|
+
|
30
|
+
def send_message(method, params: nil)
|
31
|
+
raise NotImplementedError.new('send_message is not implemented yet.')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|