playwright-ruby-client 0.5.9 → 0.6.3
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 +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 +187 -0
- data/documentation/docs/api/browser_context.md +397 -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 +71 -0
- data/documentation/docs/api/element_handle.md +618 -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 +92 -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 +50 -0
- data/documentation/docs/api/frame.md +866 -0
- data/documentation/docs/api/js_handle.md +113 -0
- data/documentation/docs/api/keyboard.md +157 -0
- data/documentation/docs/api/mouse.md +69 -0
- data/documentation/docs/api/page.md +1402 -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 +24 -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 +162 -0
- data/{docs → documentation/docs/include}/api_coverage.md +12 -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_owners/binding_call.rb +33 -0
- data/lib/playwright/channel_owners/browser.rb +11 -2
- data/lib/playwright/channel_owners/browser_context.rb +58 -6
- 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 +24 -34
- data/lib/playwright/channel_owners/js_handle.rb +2 -10
- data/lib/playwright/channel_owners/page.rb +37 -52
- data/lib/playwright/channel_owners/worker.rb +4 -0
- 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 +16 -1
- 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 +2 -59
- data/lib/playwright_api/android_device.rb +6 -5
- data/lib/playwright_api/browser.rb +13 -122
- data/lib/playwright_api/browser_context.rb +66 -433
- data/lib/playwright_api/browser_type.rb +28 -78
- data/lib/playwright_api/cdp_session.rb +2 -25
- data/lib/playwright_api/console_message.rb +2 -0
- data/lib/playwright_api/dialog.rb +5 -63
- data/lib/playwright_api/element_handle.rb +96 -294
- data/lib/playwright_api/file_chooser.rb +0 -21
- data/lib/playwright_api/frame.rb +98 -564
- data/lib/playwright_api/js_handle.rb +10 -67
- data/lib/playwright_api/keyboard.rb +22 -166
- data/lib/playwright_api/mouse.rb +1 -45
- data/lib/playwright_api/page.rb +223 -1224
- data/lib/playwright_api/playwright.rb +8 -93
- data/lib/playwright_api/request.rb +9 -87
- data/lib/playwright_api/response.rb +1 -1
- data/lib/playwright_api/route.rb +3 -80
- data/lib/playwright_api/selectors.rb +0 -66
- data/lib/playwright_api/tracing.rb +39 -0
- data/lib/playwright_api/web_socket.rb +1 -1
- data/lib/playwright_api/worker.rb +28 -42
- data/playwright.gemspec +2 -2
- metadata +60 -20
- data/lib/playwright/javascript/function.rb +0 -67
data/lib/playwright/version.rb
CHANGED
|
@@ -2,13 +2,13 @@ module Playwright
|
|
|
2
2
|
# The Accessibility class provides methods for inspecting Chromium's accessibility tree. The accessibility tree is used by
|
|
3
3
|
# assistive technology such as [screen readers](https://en.wikipedia.org/wiki/Screen_reader) or
|
|
4
4
|
# [switches](https://en.wikipedia.org/wiki/Switch_access).
|
|
5
|
-
#
|
|
5
|
+
#
|
|
6
6
|
# Accessibility is a very platform-specific thing. On different platforms, there are different screen readers that might
|
|
7
7
|
# have wildly different output.
|
|
8
|
-
#
|
|
8
|
+
#
|
|
9
9
|
# Rendering engines of Chromium, Firefox and WebKit have a concept of "accessibility tree", which is then translated into
|
|
10
10
|
# different platform-specific APIs. Accessibility namespace gives access to this Accessibility Tree.
|
|
11
|
-
#
|
|
11
|
+
#
|
|
12
12
|
# Most of the accessibility tree gets filtered out when converting from internal browser AX Tree to Platform-specific
|
|
13
13
|
# AX-Tree or by assistive technologies themselves. By default, Playwright tries to approximate this filtering, exposing
|
|
14
14
|
# only the "interesting" nodes of the tree.
|
|
@@ -16,100 +16,19 @@ module Playwright
|
|
|
16
16
|
|
|
17
17
|
# Captures the current state of the accessibility tree. The returned object represents the root accessible node of the
|
|
18
18
|
# page.
|
|
19
|
-
#
|
|
19
|
+
#
|
|
20
20
|
# > NOTE: The Chromium accessibility tree contains nodes that go unused on most platforms and by most screen readers.
|
|
21
21
|
# Playwright will discard them as well for an easier to process tree, unless `interestingOnly` is set to `false`.
|
|
22
|
-
#
|
|
22
|
+
#
|
|
23
23
|
# An example of dumping the entire accessibility tree:
|
|
24
|
-
#
|
|
25
24
|
#
|
|
26
|
-
# ```js
|
|
27
|
-
# const snapshot = await page.accessibility.snapshot();
|
|
28
|
-
# console.log(snapshot);
|
|
29
|
-
# ```
|
|
30
|
-
#
|
|
31
|
-
# ```java
|
|
32
|
-
# String snapshot = page.accessibility().snapshot();
|
|
33
|
-
# System.out.println(snapshot);
|
|
34
|
-
# ```
|
|
35
|
-
#
|
|
36
|
-
# ```python async
|
|
37
|
-
# snapshot = await page.accessibility.snapshot()
|
|
38
|
-
# print(snapshot)
|
|
39
|
-
# ```
|
|
40
|
-
#
|
|
41
25
|
# ```python sync
|
|
42
26
|
# snapshot = page.accessibility.snapshot()
|
|
43
27
|
# print(snapshot)
|
|
44
28
|
# ```
|
|
45
|
-
#
|
|
46
|
-
# ```csharp
|
|
47
|
-
# var accessibilitySnapshot = await Page.Accessibility.SnapshotAsync();
|
|
48
|
-
# Console.WriteLine(accessibilitySnapshot);
|
|
49
|
-
# ```
|
|
50
|
-
#
|
|
29
|
+
#
|
|
51
30
|
# An example of logging the focused node's name:
|
|
52
|
-
#
|
|
53
31
|
#
|
|
54
|
-
# ```js
|
|
55
|
-
# const snapshot = await page.accessibility.snapshot();
|
|
56
|
-
# const node = findFocusedNode(snapshot);
|
|
57
|
-
# console.log(node && node.name);
|
|
58
|
-
#
|
|
59
|
-
# function findFocusedNode(node) {
|
|
60
|
-
# if (node.focused)
|
|
61
|
-
# return node;
|
|
62
|
-
# for (const child of node.children || []) {
|
|
63
|
-
# const foundNode = findFocusedNode(child);
|
|
64
|
-
# return foundNode;
|
|
65
|
-
# }
|
|
66
|
-
# return null;
|
|
67
|
-
# }
|
|
68
|
-
# ```
|
|
69
|
-
#
|
|
70
|
-
# ```csharp
|
|
71
|
-
# Func<AccessibilitySnapshotResult, AccessibilitySnapshotResult> findFocusedNode = root =>
|
|
72
|
-
# {
|
|
73
|
-
# var nodes = new Stack<AccessibilitySnapshotResult>(new[] { root });
|
|
74
|
-
# while (nodes.Count > 0)
|
|
75
|
-
# {
|
|
76
|
-
# var node = nodes.Pop();
|
|
77
|
-
# if (node.Focused) return node;
|
|
78
|
-
# foreach (var innerNode in node.Children)
|
|
79
|
-
# {
|
|
80
|
-
# nodes.Push(innerNode);
|
|
81
|
-
# }
|
|
82
|
-
# }
|
|
83
|
-
#
|
|
84
|
-
# return null;
|
|
85
|
-
# };
|
|
86
|
-
#
|
|
87
|
-
# var accessibilitySnapshot = await Page.Accessibility.SnapshotAsync();
|
|
88
|
-
# var focusedNode = findFocusedNode(accessibilitySnapshot);
|
|
89
|
-
# if(focusedNode != null)
|
|
90
|
-
# Console.WriteLine(focusedNode.Name);
|
|
91
|
-
# ```
|
|
92
|
-
#
|
|
93
|
-
# ```java
|
|
94
|
-
# // FIXME
|
|
95
|
-
# String snapshot = page.accessibility().snapshot();
|
|
96
|
-
# ```
|
|
97
|
-
#
|
|
98
|
-
# ```python async
|
|
99
|
-
# def find_focused_node(node):
|
|
100
|
-
# if (node.get("focused"))
|
|
101
|
-
# return node
|
|
102
|
-
# for child in (node.get("children") or []):
|
|
103
|
-
# found_node = find_focused_node(child)
|
|
104
|
-
# return found_node
|
|
105
|
-
# return None
|
|
106
|
-
#
|
|
107
|
-
# snapshot = await page.accessibility.snapshot()
|
|
108
|
-
# node = find_focused_node(snapshot)
|
|
109
|
-
# if node:
|
|
110
|
-
# print(node["name"])
|
|
111
|
-
# ```
|
|
112
|
-
#
|
|
113
32
|
# ```python sync
|
|
114
33
|
# def find_focused_node(node):
|
|
115
34
|
# if (node.get("focused"))
|
|
@@ -118,7 +37,7 @@ module Playwright
|
|
|
118
37
|
# found_node = find_focused_node(child)
|
|
119
38
|
# return found_node
|
|
120
39
|
# return None
|
|
121
|
-
#
|
|
40
|
+
#
|
|
122
41
|
# snapshot = page.accessibility.snapshot()
|
|
123
42
|
# node = find_focused_node(snapshot)
|
|
124
43
|
# if node:
|
|
@@ -1,70 +1,13 @@
|
|
|
1
1
|
module Playwright
|
|
2
2
|
# Playwright has **experimental** support for Android automation. You can access android namespace via:
|
|
3
|
-
#
|
|
4
3
|
#
|
|
5
|
-
# ```js
|
|
6
|
-
# const { _android: android } = require('playwright');
|
|
7
|
-
# ```
|
|
8
|
-
#
|
|
9
4
|
# An example of the Android automation script would be:
|
|
10
|
-
#
|
|
11
5
|
#
|
|
12
|
-
# ```js
|
|
13
|
-
# const { _android: android } = require('playwright');
|
|
14
|
-
#
|
|
15
|
-
# (async () => {
|
|
16
|
-
# // Connect to the device.
|
|
17
|
-
# const [device] = await android.devices();
|
|
18
|
-
# console.log(`Model: ${device.model()}`);
|
|
19
|
-
# console.log(`Serial: ${device.serial()}`);
|
|
20
|
-
# // Take screenshot of the whole device.
|
|
21
|
-
# await device.screenshot({ path: 'device.png' });
|
|
22
|
-
#
|
|
23
|
-
# {
|
|
24
|
-
# // --------------------- WebView -----------------------
|
|
25
|
-
#
|
|
26
|
-
# // Launch an application with WebView.
|
|
27
|
-
# await device.shell('am force-stop org.chromium.webview_shell');
|
|
28
|
-
# await device.shell('am start org.chromium.webview_shell/.WebViewBrowserActivity');
|
|
29
|
-
# // Get the WebView.
|
|
30
|
-
# const webview = await device.webView({ pkg: 'org.chromium.webview_shell' });
|
|
31
|
-
#
|
|
32
|
-
# // Fill the input box.
|
|
33
|
-
# await device.fill({ res: 'org.chromium.webview_shell:id/url_field' }, 'github.com/microsoft/playwright');
|
|
34
|
-
# await device.press({ res: 'org.chromium.webview_shell:id/url_field' }, 'Enter');
|
|
35
|
-
#
|
|
36
|
-
# // Work with WebView's page as usual.
|
|
37
|
-
# const page = await webview.page();
|
|
38
|
-
# await page.waitForNavigation({ url: /.*microsoft\/playwright.*/ });
|
|
39
|
-
# console.log(await page.title());
|
|
40
|
-
# }
|
|
41
|
-
#
|
|
42
|
-
# {
|
|
43
|
-
# // --------------------- Browser -----------------------
|
|
44
|
-
#
|
|
45
|
-
# // Launch Chrome browser.
|
|
46
|
-
# await device.shell('am force-stop com.android.chrome');
|
|
47
|
-
# const context = await device.launchBrowser();
|
|
48
|
-
#
|
|
49
|
-
# // Use BrowserContext as usual.
|
|
50
|
-
# const page = await context.newPage();
|
|
51
|
-
# await page.goto('https://webkit.org/');
|
|
52
|
-
# console.log(await page.evaluate(() => window.location.href));
|
|
53
|
-
# await page.screenshot({ path: 'page.png' });
|
|
54
|
-
#
|
|
55
|
-
# await context.close();
|
|
56
|
-
# }
|
|
57
|
-
#
|
|
58
|
-
# // Close the device.
|
|
59
|
-
# await device.close();
|
|
60
|
-
# })();
|
|
61
|
-
# ```
|
|
62
|
-
#
|
|
63
6
|
# Note that since you don't need Playwright to install web browsers when testing Android, you can omit browser download
|
|
64
7
|
# via setting the following environment variable when installing Playwright:
|
|
65
|
-
#
|
|
8
|
+
#
|
|
66
9
|
# ```sh js
|
|
67
|
-
#
|
|
10
|
+
# PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright
|
|
68
11
|
# ```
|
|
69
12
|
class Android < PlaywrightApi
|
|
70
13
|
|
|
@@ -59,12 +59,13 @@ module Playwright
|
|
|
59
59
|
record_har_path: nil,
|
|
60
60
|
record_video_dir: nil,
|
|
61
61
|
record_video_size: nil,
|
|
62
|
+
reducedMotion: nil,
|
|
62
63
|
screen: nil,
|
|
63
64
|
timezoneId: nil,
|
|
64
65
|
userAgent: nil,
|
|
65
66
|
viewport: nil,
|
|
66
67
|
&block)
|
|
67
|
-
wrap_impl(@impl.launch_browser(acceptDownloads: unwrap_impl(acceptDownloads), bypassCSP: unwrap_impl(bypassCSP), colorScheme: unwrap_impl(colorScheme), command: unwrap_impl(command), 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), noViewport: unwrap_impl(noViewport), offline: unwrap_impl(offline), permissions: unwrap_impl(permissions), record_har_omit_content: unwrap_impl(record_har_omit_content), record_har_path: unwrap_impl(record_har_path), record_video_dir: unwrap_impl(record_video_dir), record_video_size: unwrap_impl(record_video_size), screen: unwrap_impl(screen), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
|
|
68
|
+
wrap_impl(@impl.launch_browser(acceptDownloads: unwrap_impl(acceptDownloads), bypassCSP: unwrap_impl(bypassCSP), colorScheme: unwrap_impl(colorScheme), command: unwrap_impl(command), 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), noViewport: unwrap_impl(noViewport), offline: unwrap_impl(offline), permissions: unwrap_impl(permissions), record_har_omit_content: unwrap_impl(record_har_omit_content), record_har_path: unwrap_impl(record_har_path), record_video_dir: unwrap_impl(record_video_dir), record_video_size: unwrap_impl(record_video_size), reducedMotion: unwrap_impl(reducedMotion), screen: unwrap_impl(screen), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
|
|
68
69
|
end
|
|
69
70
|
|
|
70
71
|
# Performs a long tap on the widget defined by `selector`.
|
|
@@ -161,13 +162,13 @@ module Playwright
|
|
|
161
162
|
end
|
|
162
163
|
|
|
163
164
|
# @nodoc
|
|
164
|
-
def
|
|
165
|
-
wrap_impl(@impl.
|
|
165
|
+
def tree
|
|
166
|
+
wrap_impl(@impl.tree)
|
|
166
167
|
end
|
|
167
168
|
|
|
168
169
|
# @nodoc
|
|
169
|
-
def
|
|
170
|
-
wrap_impl(@impl.
|
|
170
|
+
def tap_on(selector, duration: nil, timeout: nil)
|
|
171
|
+
wrap_impl(@impl.tap_on(unwrap_impl(selector), duration: unwrap_impl(duration), timeout: unwrap_impl(timeout)))
|
|
171
172
|
end
|
|
172
173
|
|
|
173
174
|
# -- inherited from EventEmitter --
|
|
@@ -1,63 +1,18 @@
|
|
|
1
1
|
module Playwright
|
|
2
2
|
# - extends: [EventEmitter]
|
|
3
|
-
#
|
|
3
|
+
#
|
|
4
4
|
# A Browser is created via [`method: BrowserType.launch`]. An example of using a `Browser` to create a `Page`:
|
|
5
|
-
#
|
|
6
5
|
#
|
|
7
|
-
# ```js
|
|
8
|
-
# const { firefox } = require('playwright'); // Or 'chromium' or 'webkit'.
|
|
9
|
-
#
|
|
10
|
-
# (async () => {
|
|
11
|
-
# const browser = await firefox.launch();
|
|
12
|
-
# const page = await browser.newPage();
|
|
13
|
-
# await page.goto('https://example.com');
|
|
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 firefox = playwright.firefox()
|
|
25
|
-
# Browser browser = firefox.launch();
|
|
26
|
-
# Page page = browser.newPage();
|
|
27
|
-
# page.navigate('https://example.com');
|
|
28
|
-
# browser.close();
|
|
29
|
-
# }
|
|
30
|
-
# }
|
|
31
|
-
# }
|
|
32
|
-
# ```
|
|
33
|
-
#
|
|
34
|
-
# ```python async
|
|
35
|
-
# import asyncio
|
|
36
|
-
# from playwright.async_api import async_playwright
|
|
37
|
-
#
|
|
38
|
-
# async def run(playwright):
|
|
39
|
-
# firefox = playwright.firefox
|
|
40
|
-
# browser = await firefox.launch()
|
|
41
|
-
# page = await browser.new_page()
|
|
42
|
-
# await page.goto("https://example.com")
|
|
43
|
-
# await browser.close()
|
|
44
|
-
#
|
|
45
|
-
# async def main():
|
|
46
|
-
# async with async_playwright() as playwright:
|
|
47
|
-
# await run(playwright)
|
|
48
|
-
# asyncio.run(main())
|
|
49
|
-
# ```
|
|
50
|
-
#
|
|
51
6
|
# ```python sync
|
|
52
7
|
# from playwright.sync_api import sync_playwright
|
|
53
|
-
#
|
|
8
|
+
#
|
|
54
9
|
# def run(playwright):
|
|
55
10
|
# firefox = playwright.firefox
|
|
56
11
|
# browser = firefox.launch()
|
|
57
12
|
# page = browser.new_page()
|
|
58
13
|
# page.goto("https://example.com")
|
|
59
14
|
# browser.close()
|
|
60
|
-
#
|
|
15
|
+
#
|
|
61
16
|
# with sync_playwright() as playwright:
|
|
62
17
|
# run(playwright)
|
|
63
18
|
# ```
|
|
@@ -65,40 +20,17 @@ module Playwright
|
|
|
65
20
|
|
|
66
21
|
# In case this browser is obtained using [`method: BrowserType.launch`], closes the browser and all of its pages (if any
|
|
67
22
|
# were opened).
|
|
68
|
-
#
|
|
23
|
+
#
|
|
69
24
|
# In case this browser is connected to, clears all created contexts belonging to this browser and disconnects from the
|
|
70
25
|
# browser server.
|
|
71
|
-
#
|
|
26
|
+
#
|
|
72
27
|
# The `Browser` object itself is considered to be disposed and cannot be used anymore.
|
|
73
28
|
def close
|
|
74
29
|
wrap_impl(@impl.close)
|
|
75
30
|
end
|
|
76
31
|
|
|
77
32
|
# Returns an array of all open browser contexts. In a newly created browser, this will return zero browser contexts.
|
|
78
|
-
#
|
|
79
33
|
#
|
|
80
|
-
# ```js
|
|
81
|
-
# const browser = await pw.webkit.launch();
|
|
82
|
-
# console.log(browser.contexts().length); // prints `0`
|
|
83
|
-
#
|
|
84
|
-
# const context = await browser.newContext();
|
|
85
|
-
# console.log(browser.contexts().length); // prints `1`
|
|
86
|
-
# ```
|
|
87
|
-
#
|
|
88
|
-
# ```java
|
|
89
|
-
# Browser browser = pw.webkit().launch();
|
|
90
|
-
# System.out.println(browser.contexts().size()); // prints "0"
|
|
91
|
-
# BrowserContext context = browser.newContext();
|
|
92
|
-
# System.out.println(browser.contexts().size()); // prints "1"
|
|
93
|
-
# ```
|
|
94
|
-
#
|
|
95
|
-
# ```python async
|
|
96
|
-
# browser = await pw.webkit.launch()
|
|
97
|
-
# print(len(browser.contexts())) # prints `0`
|
|
98
|
-
# context = await browser.new_context()
|
|
99
|
-
# print(len(browser.contexts())) # prints `1`
|
|
100
|
-
# ```
|
|
101
|
-
#
|
|
102
34
|
# ```python sync
|
|
103
35
|
# browser = pw.webkit.launch()
|
|
104
36
|
# print(len(browser.contexts())) # prints `0`
|
|
@@ -115,44 +47,14 @@ module Playwright
|
|
|
115
47
|
end
|
|
116
48
|
|
|
117
49
|
# > NOTE: CDP Sessions are only supported on Chromium-based browsers.
|
|
118
|
-
#
|
|
50
|
+
#
|
|
119
51
|
# Returns the newly created browser session.
|
|
120
52
|
def new_browser_cdp_session
|
|
121
53
|
raise NotImplementedError.new('new_browser_cdp_session is not implemented yet.')
|
|
122
54
|
end
|
|
123
55
|
|
|
124
56
|
# Creates a new browser context. It won't share cookies/cache with other browser contexts.
|
|
125
|
-
#
|
|
126
57
|
#
|
|
127
|
-
# ```js
|
|
128
|
-
# (async () => {
|
|
129
|
-
# const browser = await playwright.firefox.launch(); // Or 'chromium' or 'webkit'.
|
|
130
|
-
# // Create a new incognito browser context.
|
|
131
|
-
# const context = await browser.newContext();
|
|
132
|
-
# // Create a new page in a pristine context.
|
|
133
|
-
# const page = await context.newPage();
|
|
134
|
-
# await page.goto('https://example.com');
|
|
135
|
-
# })();
|
|
136
|
-
# ```
|
|
137
|
-
#
|
|
138
|
-
# ```java
|
|
139
|
-
# Browser browser = playwright.firefox().launch(); // Or 'chromium' or 'webkit'.
|
|
140
|
-
# // Create a new incognito browser context.
|
|
141
|
-
# BrowserContext context = browser.newContext();
|
|
142
|
-
# // Create a new page in a pristine context.
|
|
143
|
-
# Page page = context.newPage();
|
|
144
|
-
# page.navigate('https://example.com');
|
|
145
|
-
# ```
|
|
146
|
-
#
|
|
147
|
-
# ```python async
|
|
148
|
-
# browser = await playwright.firefox.launch() # or "chromium" or "webkit".
|
|
149
|
-
# # create a new incognito browser context.
|
|
150
|
-
# context = await browser.new_context()
|
|
151
|
-
# # create a new page in a pristine context.
|
|
152
|
-
# page = await context.new_page()
|
|
153
|
-
# await page.goto("https://example.com")
|
|
154
|
-
# ```
|
|
155
|
-
#
|
|
156
58
|
# ```python sync
|
|
157
59
|
# browser = playwright.firefox.launch() # or "chromium" or "webkit".
|
|
158
60
|
# # create a new incognito browser context.
|
|
@@ -182,17 +84,18 @@ module Playwright
|
|
|
182
84
|
record_har_path: nil,
|
|
183
85
|
record_video_dir: nil,
|
|
184
86
|
record_video_size: nil,
|
|
87
|
+
reducedMotion: nil,
|
|
185
88
|
screen: nil,
|
|
186
89
|
storageState: nil,
|
|
187
90
|
timezoneId: nil,
|
|
188
91
|
userAgent: nil,
|
|
189
92
|
viewport: nil,
|
|
190
93
|
&block)
|
|
191
|
-
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), noViewport: unwrap_impl(noViewport), offline: unwrap_impl(offline), permissions: unwrap_impl(permissions), proxy: unwrap_impl(proxy), record_har_omit_content: unwrap_impl(record_har_omit_content), record_har_path: unwrap_impl(record_har_path), record_video_dir: unwrap_impl(record_video_dir), record_video_size: unwrap_impl(record_video_size), screen: unwrap_impl(screen), storageState: unwrap_impl(storageState), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
|
|
94
|
+
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), noViewport: unwrap_impl(noViewport), offline: unwrap_impl(offline), permissions: unwrap_impl(permissions), proxy: unwrap_impl(proxy), record_har_omit_content: unwrap_impl(record_har_omit_content), record_har_path: unwrap_impl(record_har_path), record_video_dir: unwrap_impl(record_video_dir), record_video_size: unwrap_impl(record_video_size), reducedMotion: unwrap_impl(reducedMotion), screen: unwrap_impl(screen), storageState: unwrap_impl(storageState), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
|
|
192
95
|
end
|
|
193
96
|
|
|
194
97
|
# Creates a new page in a new browser context. Closing this page will close the context as well.
|
|
195
|
-
#
|
|
98
|
+
#
|
|
196
99
|
# This is a convenience API that should only be used for the single-page scenarios and short snippets. Production code and
|
|
197
100
|
# testing frameworks should explicitly create [`method: Browser.newContext`] followed by the
|
|
198
101
|
# [`method: BrowserContext.newPage`] to control their exact life times.
|
|
@@ -217,32 +120,20 @@ module Playwright
|
|
|
217
120
|
record_har_path: nil,
|
|
218
121
|
record_video_dir: nil,
|
|
219
122
|
record_video_size: nil,
|
|
123
|
+
reducedMotion: nil,
|
|
220
124
|
screen: nil,
|
|
221
125
|
storageState: nil,
|
|
222
126
|
timezoneId: nil,
|
|
223
127
|
userAgent: nil,
|
|
224
128
|
viewport: nil)
|
|
225
|
-
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), noViewport: unwrap_impl(noViewport), offline: unwrap_impl(offline), permissions: unwrap_impl(permissions), proxy: unwrap_impl(proxy), record_har_omit_content: unwrap_impl(record_har_omit_content), record_har_path: unwrap_impl(record_har_path), record_video_dir: unwrap_impl(record_video_dir), record_video_size: unwrap_impl(record_video_size), screen: unwrap_impl(screen), storageState: unwrap_impl(storageState), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport)))
|
|
129
|
+
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), noViewport: unwrap_impl(noViewport), offline: unwrap_impl(offline), permissions: unwrap_impl(permissions), proxy: unwrap_impl(proxy), record_har_omit_content: unwrap_impl(record_har_omit_content), record_har_path: unwrap_impl(record_har_path), record_video_dir: unwrap_impl(record_video_dir), record_video_size: unwrap_impl(record_video_size), reducedMotion: unwrap_impl(reducedMotion), screen: unwrap_impl(screen), storageState: unwrap_impl(storageState), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport)))
|
|
226
130
|
end
|
|
227
131
|
|
|
228
132
|
# > NOTE: Tracing is only supported on Chromium-based browsers.
|
|
229
|
-
#
|
|
133
|
+
#
|
|
230
134
|
# You can use [`method: Browser.startTracing`] and [`method: Browser.stopTracing`] to create a trace file that can be
|
|
231
135
|
# opened in Chrome DevTools performance panel.
|
|
232
|
-
#
|
|
233
136
|
#
|
|
234
|
-
# ```js
|
|
235
|
-
# await browser.startTracing(page, {path: 'trace.json'});
|
|
236
|
-
# await page.goto('https://www.google.com');
|
|
237
|
-
# await browser.stopTracing();
|
|
238
|
-
# ```
|
|
239
|
-
#
|
|
240
|
-
# ```python async
|
|
241
|
-
# await browser.start_tracing(page, path="trace.json")
|
|
242
|
-
# await page.goto("https://www.google.com")
|
|
243
|
-
# await browser.stop_tracing()
|
|
244
|
-
# ```
|
|
245
|
-
#
|
|
246
137
|
# ```python sync
|
|
247
138
|
# browser.start_tracing(page, path="trace.json")
|
|
248
139
|
# page.goto("https://www.google.com")
|
|
@@ -253,7 +144,7 @@ module Playwright
|
|
|
253
144
|
end
|
|
254
145
|
|
|
255
146
|
# > NOTE: Tracing is only supported on Chromium-based browsers.
|
|
256
|
-
#
|
|
147
|
+
#
|
|
257
148
|
# Returns the buffer with trace data.
|
|
258
149
|
def stop_tracing
|
|
259
150
|
wrap_impl(@impl.stop_tracing)
|