playwright-ruby-client 0.0.8 → 1.58.1.alpha1
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/AGENTS.md +4 -0
- data/CLAUDE/api_generation.md +28 -0
- data/CLAUDE/ci_expectations.md +23 -0
- data/CLAUDE/gem_release_flow.md +39 -0
- data/CLAUDE/past_upgrade_pr_patterns.md +42 -0
- data/CLAUDE/playwright_upgrade_workflow.md +35 -0
- data/CLAUDE/rspec_debugging.md +30 -0
- data/CLAUDE/unimplemented_examples.md +18 -0
- data/CLAUDE.md +32 -0
- data/CONTRIBUTING.md +5 -0
- data/README.md +60 -16
- data/documentation/README.md +33 -0
- data/documentation/babel.config.js +3 -0
- data/documentation/docs/api/api_request.md +7 -0
- data/documentation/docs/api/api_request_context.md +298 -0
- data/documentation/docs/api/api_response.md +114 -0
- data/documentation/docs/api/browser.md +237 -0
- data/documentation/docs/api/browser_context.md +503 -0
- data/documentation/docs/api/browser_type.md +184 -0
- data/documentation/docs/api/cdp_session.md +44 -0
- data/documentation/docs/api/clock.md +154 -0
- data/documentation/docs/api/console_message.md +85 -0
- data/documentation/docs/api/dialog.md +84 -0
- data/documentation/docs/api/download.md +111 -0
- data/documentation/docs/api/element_handle.md +694 -0
- data/documentation/docs/api/experimental/_category_.yml +3 -0
- data/documentation/docs/api/experimental/android.md +42 -0
- data/documentation/docs/api/experimental/android_device.md +109 -0
- data/documentation/docs/api/experimental/android_input.md +43 -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 +53 -0
- data/documentation/docs/api/frame.md +1218 -0
- data/documentation/docs/api/frame_locator.md +348 -0
- data/documentation/docs/api/js_handle.md +121 -0
- data/documentation/docs/api/keyboard.md +170 -0
- data/documentation/docs/api/locator.md +1495 -0
- data/documentation/docs/api/locator_assertions.md +827 -0
- data/documentation/docs/api/mouse.md +86 -0
- data/documentation/docs/api/page.md +1946 -0
- data/documentation/docs/api/page_assertions.md +65 -0
- data/documentation/docs/api/playwright.md +66 -0
- data/documentation/docs/api/request.md +255 -0
- data/documentation/docs/api/response.md +176 -0
- data/documentation/docs/api/route.md +205 -0
- data/documentation/docs/api/selectors.md +63 -0
- data/documentation/docs/api/touchscreen.md +22 -0
- data/documentation/docs/api/tracing.md +129 -0
- data/documentation/docs/api/web_socket.md +51 -0
- data/documentation/docs/api/worker.md +83 -0
- data/documentation/docs/article/api_coverage.mdx +11 -0
- data/documentation/docs/article/getting_started.md +161 -0
- data/documentation/docs/article/guides/_category_.yml +3 -0
- data/documentation/docs/article/guides/download_playwright_driver.md +55 -0
- data/documentation/docs/article/guides/inspector.md +31 -0
- data/documentation/docs/article/guides/launch_browser.md +121 -0
- data/documentation/docs/article/guides/playwright_on_alpine_linux.md +112 -0
- data/documentation/docs/article/guides/rails_integration.md +278 -0
- data/documentation/docs/article/guides/rails_integration_with_null_driver.md +145 -0
- data/documentation/docs/article/guides/recording_video.md +79 -0
- data/documentation/docs/article/guides/rspec_integration.md +59 -0
- data/documentation/docs/article/guides/semi_automation.md +71 -0
- data/documentation/docs/article/guides/use_storage_state.md +78 -0
- data/documentation/docs/include/api_coverage.md +671 -0
- data/documentation/docusaurus.config.js +114 -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 +49 -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/playwright-ruby-client.png +0 -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 +9005 -0
- data/lib/playwright/{input_types/android_input.rb → android_input_impl.rb} +5 -1
- data/lib/playwright/api_implementation.rb +18 -0
- data/lib/playwright/api_response_impl.rb +77 -0
- data/lib/playwright/channel.rb +62 -1
- data/lib/playwright/channel_owner.rb +70 -7
- data/lib/playwright/channel_owners/android.rb +16 -3
- data/lib/playwright/channel_owners/android_device.rb +22 -66
- data/lib/playwright/channel_owners/api_request_context.rb +247 -0
- data/lib/playwright/channel_owners/artifact.rb +40 -0
- data/lib/playwright/channel_owners/binding_call.rb +70 -0
- data/lib/playwright/channel_owners/browser.rb +114 -22
- data/lib/playwright/channel_owners/browser_context.rb +589 -15
- data/lib/playwright/channel_owners/browser_type.rb +90 -1
- data/lib/playwright/channel_owners/cdp_session.rb +19 -0
- data/lib/playwright/channel_owners/dialog.rb +32 -0
- data/lib/playwright/channel_owners/element_handle.rb +107 -43
- data/lib/playwright/channel_owners/fetch_request.rb +8 -0
- data/lib/playwright/channel_owners/frame.rb +334 -104
- data/lib/playwright/channel_owners/js_handle.rb +9 -13
- data/lib/playwright/channel_owners/local_utils.rb +82 -0
- data/lib/playwright/channel_owners/page.rb +778 -95
- data/lib/playwright/channel_owners/playwright.rb +25 -30
- data/lib/playwright/channel_owners/request.rb +120 -18
- data/lib/playwright/channel_owners/response.rb +113 -0
- data/lib/playwright/channel_owners/route.rb +181 -0
- data/lib/playwright/channel_owners/stream.rb +30 -0
- data/lib/playwright/channel_owners/tracing.rb +117 -0
- data/lib/playwright/channel_owners/web_socket.rb +96 -0
- data/lib/playwright/channel_owners/worker.rb +46 -0
- data/lib/playwright/channel_owners/writable_stream.rb +14 -0
- data/lib/playwright/clock_impl.rb +67 -0
- data/lib/playwright/connection.rb +111 -63
- data/lib/playwright/console_message_impl.rb +29 -0
- data/lib/playwright/download_impl.rb +32 -0
- data/lib/playwright/errors.rb +42 -5
- data/lib/playwright/event_emitter.rb +17 -3
- data/lib/playwright/event_emitter_proxy.rb +49 -0
- data/lib/playwright/events.rb +10 -5
- data/lib/playwright/file_chooser_impl.rb +24 -0
- data/lib/playwright/frame_locator_impl.rb +66 -0
- data/lib/playwright/har_router.rb +89 -0
- data/lib/playwright/http_headers.rb +14 -0
- data/lib/playwright/input_files.rb +102 -15
- data/lib/playwright/javascript/expression.rb +7 -11
- data/lib/playwright/javascript/regex.rb +23 -0
- data/lib/playwright/javascript/source_url.rb +16 -0
- data/lib/playwright/javascript/value_parser.rb +108 -19
- data/lib/playwright/javascript/value_serializer.rb +47 -8
- data/lib/playwright/javascript/visitor_info.rb +26 -0
- data/lib/playwright/javascript.rb +2 -10
- data/lib/playwright/{input_types/keyboard.rb → keyboard_impl.rb} +6 -2
- data/lib/playwright/locator_assertions_impl.rb +571 -0
- data/lib/playwright/locator_impl.rb +544 -0
- data/lib/playwright/locator_utils.rb +136 -0
- data/lib/playwright/mouse_impl.rb +57 -0
- data/lib/playwright/page_assertions_impl.rb +154 -0
- data/lib/playwright/playwright_api.rb +102 -30
- data/lib/playwright/raw_headers.rb +61 -0
- data/lib/playwright/route_handler.rb +78 -0
- data/lib/playwright/select_option_values.rb +34 -13
- data/lib/playwright/selectors_impl.rb +45 -0
- data/lib/playwright/test.rb +102 -0
- data/lib/playwright/timeout_settings.rb +9 -4
- data/lib/playwright/touchscreen_impl.rb +14 -0
- data/lib/playwright/transport.rb +61 -10
- data/lib/playwright/url_matcher.rb +24 -2
- data/lib/playwright/utils.rb +48 -13
- data/lib/playwright/version.rb +2 -1
- data/lib/playwright/video.rb +54 -0
- data/lib/playwright/waiter.rb +166 -0
- data/lib/playwright/web_socket_client.rb +167 -0
- data/lib/playwright/web_socket_transport.rb +116 -0
- data/lib/playwright.rb +188 -11
- data/lib/playwright_api/android.rb +46 -11
- data/lib/playwright_api/android_device.rb +182 -31
- data/lib/playwright_api/android_input.rb +22 -13
- data/lib/playwright_api/android_socket.rb +18 -0
- data/lib/playwright_api/android_web_view.rb +24 -0
- data/lib/playwright_api/api_request.rb +26 -0
- data/lib/playwright_api/api_request_context.rb +311 -0
- data/lib/playwright_api/api_response.rb +92 -0
- data/lib/playwright_api/browser.rb +116 -103
- data/lib/playwright_api/browser_context.rb +290 -389
- data/lib/playwright_api/browser_type.rb +96 -118
- data/lib/playwright_api/cdp_session.rb +36 -39
- data/lib/playwright_api/clock.rb +121 -0
- data/lib/playwright_api/console_message.rb +35 -19
- data/lib/playwright_api/dialog.rb +53 -50
- data/lib/playwright_api/download.rb +49 -43
- data/lib/playwright_api/element_handle.rb +354 -402
- data/lib/playwright_api/file_chooser.rb +15 -18
- data/lib/playwright_api/frame.rb +703 -603
- data/lib/playwright_api/frame_locator.rb +285 -0
- data/lib/playwright_api/js_handle.rb +50 -76
- data/lib/playwright_api/keyboard.rb +67 -146
- data/lib/playwright_api/locator.rb +1304 -0
- data/lib/playwright_api/locator_assertions.rb +704 -0
- data/lib/playwright_api/mouse.rb +23 -29
- data/lib/playwright_api/page.rb +1196 -1176
- data/lib/playwright_api/page_assertions.rb +60 -0
- data/lib/playwright_api/playwright.rb +54 -122
- data/lib/playwright_api/request.rb +112 -74
- data/lib/playwright_api/response.rb +92 -20
- data/lib/playwright_api/route.rb +152 -62
- data/lib/playwright_api/selectors.rb +47 -61
- data/lib/playwright_api/touchscreen.rb +8 -2
- data/lib/playwright_api/tracing.rb +128 -0
- data/lib/playwright_api/web_socket.rb +43 -5
- data/lib/playwright_api/worker.rb +74 -34
- data/playwright.gemspec +14 -9
- data/sig/playwright.rbs +658 -0
- metadata +216 -50
- data/docs/api_coverage.md +0 -354
- data/lib/playwright/channel_owners/chromium_browser.rb +0 -8
- data/lib/playwright/channel_owners/chromium_browser_context.rb +0 -8
- data/lib/playwright/channel_owners/console_message.rb +0 -21
- data/lib/playwright/channel_owners/firefox_browser.rb +0 -8
- data/lib/playwright/channel_owners/selectors.rb +0 -4
- data/lib/playwright/channel_owners/webkit_browser.rb +0 -8
- data/lib/playwright/input_type.rb +0 -19
- data/lib/playwright/input_types/mouse.rb +0 -4
- data/lib/playwright/input_types/touchscreen.rb +0 -4
- data/lib/playwright/javascript/function.rb +0 -67
- data/lib/playwright/wait_helper.rb +0 -73
- data/lib/playwright_api/accessibility.rb +0 -93
- data/lib/playwright_api/binding_call.rb +0 -23
- data/lib/playwright_api/chromium_browser_context.rb +0 -57
- data/lib/playwright_api/video.rb +0 -24
|
@@ -1,105 +1,101 @@
|
|
|
1
1
|
module Playwright
|
|
2
|
+
#
|
|
2
3
|
# BrowserType provides methods to launch a specific browser instance or connect to an existing one. The following is a
|
|
3
4
|
# typical example of using Playwright to drive automation:
|
|
4
|
-
#
|
|
5
5
|
#
|
|
6
|
-
# ```js
|
|
7
|
-
# const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.
|
|
8
|
-
#
|
|
9
|
-
# (async () => {
|
|
10
|
-
# const browser = await chromium.launch();
|
|
11
|
-
# const page = await browser.newPage();
|
|
12
|
-
# await page.goto('https://example.com');
|
|
13
|
-
# // other actions...
|
|
14
|
-
# await browser.close();
|
|
15
|
-
# })();
|
|
16
|
-
# ```
|
|
17
|
-
#
|
|
18
|
-
# ```python async
|
|
19
|
-
# import asyncio
|
|
20
|
-
# from playwright.async_api import async_playwright
|
|
21
|
-
#
|
|
22
|
-
# async def run(playwright):
|
|
23
|
-
# chromium = playwright.chromium
|
|
24
|
-
# browser = await chromium.launch()
|
|
25
|
-
# page = await browser.new_page()
|
|
26
|
-
# await page.goto("https://example.com")
|
|
27
|
-
# # other actions...
|
|
28
|
-
# await browser.close()
|
|
29
|
-
#
|
|
30
|
-
# async def main():
|
|
31
|
-
# async with async_playwright() as playwright:
|
|
32
|
-
# await run(playwright)
|
|
33
|
-
# asyncio.run(main())
|
|
34
|
-
# ```
|
|
35
|
-
#
|
|
36
6
|
# ```python sync
|
|
37
|
-
# from playwright.sync_api import sync_playwright
|
|
38
|
-
#
|
|
39
|
-
# def run(playwright):
|
|
7
|
+
# from playwright.sync_api import sync_playwright, Playwright
|
|
8
|
+
#
|
|
9
|
+
# def run(playwright: Playwright):
|
|
40
10
|
# chromium = playwright.chromium
|
|
41
11
|
# browser = chromium.launch()
|
|
42
12
|
# page = browser.new_page()
|
|
43
13
|
# page.goto("https://example.com")
|
|
44
14
|
# # other actions...
|
|
45
15
|
# browser.close()
|
|
46
|
-
#
|
|
16
|
+
#
|
|
47
17
|
# with sync_playwright() as playwright:
|
|
48
18
|
# run(playwright)
|
|
49
19
|
# ```
|
|
50
20
|
class BrowserType < PlaywrightApi
|
|
51
21
|
|
|
52
|
-
#
|
|
53
|
-
|
|
22
|
+
#
|
|
23
|
+
# This method attaches Playwright to an existing browser instance created via `BrowserType.launchServer` in Node.js.
|
|
24
|
+
#
|
|
25
|
+
# **NOTE**: The major and minor version of the Playwright instance that connects needs to match the version of Playwright that launches the browser (1.2.3 → is compatible with 1.2.x).
|
|
26
|
+
def connect(
|
|
27
|
+
wsEndpoint,
|
|
28
|
+
exposeNetwork: nil,
|
|
29
|
+
headers: nil,
|
|
30
|
+
slowMo: nil,
|
|
31
|
+
timeout: nil)
|
|
54
32
|
raise NotImplementedError.new('connect is not implemented yet.')
|
|
55
33
|
end
|
|
56
34
|
|
|
35
|
+
#
|
|
36
|
+
# This method attaches Playwright to an existing browser instance using the Chrome DevTools Protocol.
|
|
37
|
+
#
|
|
38
|
+
# The default browser context is accessible via [`method: Browser.contexts`].
|
|
39
|
+
#
|
|
40
|
+
# **NOTE**: Connecting over the Chrome DevTools Protocol is only supported for Chromium-based browsers.
|
|
41
|
+
#
|
|
42
|
+
# **NOTE**: This connection is significantly lower fidelity than the Playwright protocol connection via [`method: BrowserType.connect`]. If you are experiencing issues or attempting to use advanced functionality, you probably want to use [`method: BrowserType.connect`].
|
|
43
|
+
#
|
|
44
|
+
# **Usage**
|
|
45
|
+
#
|
|
46
|
+
# ```python sync
|
|
47
|
+
# browser = playwright.chromium.connect_over_cdp("http://localhost:9222")
|
|
48
|
+
# default_context = browser.contexts[0]
|
|
49
|
+
# page = default_context.pages[0]
|
|
50
|
+
# ```
|
|
51
|
+
def connect_over_cdp(
|
|
52
|
+
endpointURL,
|
|
53
|
+
headers: nil,
|
|
54
|
+
isLocal: nil,
|
|
55
|
+
slowMo: nil,
|
|
56
|
+
timeout: nil,
|
|
57
|
+
&block)
|
|
58
|
+
wrap_impl(@impl.connect_over_cdp(unwrap_impl(endpointURL), headers: unwrap_impl(headers), isLocal: unwrap_impl(isLocal), slowMo: unwrap_impl(slowMo), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
#
|
|
57
62
|
# A path where Playwright expects to find a bundled browser executable.
|
|
58
63
|
def executable_path
|
|
59
64
|
wrap_impl(@impl.executable_path)
|
|
60
65
|
end
|
|
61
66
|
|
|
67
|
+
#
|
|
62
68
|
# Returns the browser instance.
|
|
63
|
-
#
|
|
69
|
+
#
|
|
70
|
+
# **Usage**
|
|
71
|
+
#
|
|
64
72
|
# You can use `ignoreDefaultArgs` to filter out `--mute-audio` from default arguments:
|
|
65
|
-
#
|
|
66
73
|
#
|
|
67
|
-
# ```js
|
|
68
|
-
# const browser = await chromium.launch({ // Or 'firefox' or 'webkit'.
|
|
69
|
-
# ignoreDefaultArgs: ['--mute-audio']
|
|
70
|
-
# });
|
|
71
|
-
# ```
|
|
72
|
-
#
|
|
73
|
-
# ```python async
|
|
74
|
-
# browser = await playwright.chromium.launch( # or "firefox" or "webkit".
|
|
75
|
-
# ignore_default_args=["--mute-audio"]
|
|
76
|
-
# )
|
|
77
|
-
# ```
|
|
78
|
-
#
|
|
79
74
|
# ```python sync
|
|
80
75
|
# browser = playwright.chromium.launch( # or "firefox" or "webkit".
|
|
81
76
|
# ignore_default_args=["--mute-audio"]
|
|
82
77
|
# )
|
|
83
78
|
# ```
|
|
84
|
-
#
|
|
85
|
-
# > **Chromium-only** Playwright can also be used to control the Chrome
|
|
86
|
-
# Chromium it is bundled with. There is no guarantee it will work with any other version. Use `executablePath`
|
|
87
|
-
# extreme caution.
|
|
79
|
+
#
|
|
80
|
+
# > **Chromium-only** Playwright can also be used to control the Google Chrome or Microsoft Edge browsers, but it works best with the version of
|
|
81
|
+
# Chromium it is bundled with. There is no guarantee it will work with any other version. Use `executablePath`
|
|
82
|
+
# option with extreme caution.
|
|
83
|
+
#
|
|
88
84
|
# >
|
|
85
|
+
#
|
|
89
86
|
# > If Google Chrome (rather than Chromium) is preferred, a
|
|
90
87
|
# [Chrome Canary](https://www.google.com/chrome/browser/canary.html) or
|
|
91
88
|
# [Dev Channel](https://www.chromium.org/getting-involved/dev-channel) build is suggested.
|
|
89
|
+
#
|
|
92
90
|
# >
|
|
93
|
-
#
|
|
94
|
-
# >
|
|
95
|
-
#
|
|
96
|
-
# a description of the differences between Chromium and Chrome.
|
|
97
|
-
# [`This article`](https://chromium.googlesource.com/chromium/src/+/lkgr/docs/chromium_browser_vs_google_chrome.md)
|
|
91
|
+
#
|
|
92
|
+
# > Stock browsers like Google Chrome and Microsoft Edge are suitable for tests that require proprietary media codecs for video playback. See [this article](https://www.howtogeek.com/202825/what%E2%80%99s-the-difference-between-chromium-and-chrome/) for other differences between Chromium and Chrome.
|
|
93
|
+
# [This article](https://chromium.googlesource.com/chromium/src/+/lkgr/docs/chromium_browser_vs_google_chrome.md)
|
|
98
94
|
# describes some differences for Linux users.
|
|
99
95
|
def launch(
|
|
100
96
|
args: nil,
|
|
97
|
+
channel: nil,
|
|
101
98
|
chromiumSandbox: nil,
|
|
102
|
-
devtools: nil,
|
|
103
99
|
downloadsPath: nil,
|
|
104
100
|
env: nil,
|
|
105
101
|
executablePath: nil,
|
|
@@ -109,31 +105,37 @@ module Playwright
|
|
|
109
105
|
handleSIGTERM: nil,
|
|
110
106
|
headless: nil,
|
|
111
107
|
ignoreDefaultArgs: nil,
|
|
112
|
-
logger: nil,
|
|
113
108
|
proxy: nil,
|
|
114
109
|
slowMo: nil,
|
|
115
110
|
timeout: nil,
|
|
111
|
+
tracesDir: nil,
|
|
116
112
|
&block)
|
|
117
|
-
wrap_impl(@impl.launch(args: unwrap_impl(args),
|
|
113
|
+
wrap_impl(@impl.launch(args: unwrap_impl(args), channel: unwrap_impl(channel), chromiumSandbox: unwrap_impl(chromiumSandbox), downloadsPath: unwrap_impl(downloadsPath), env: unwrap_impl(env), executablePath: unwrap_impl(executablePath), firefoxUserPrefs: unwrap_impl(firefoxUserPrefs), handleSIGHUP: unwrap_impl(handleSIGHUP), handleSIGINT: unwrap_impl(handleSIGINT), handleSIGTERM: unwrap_impl(handleSIGTERM), headless: unwrap_impl(headless), ignoreDefaultArgs: unwrap_impl(ignoreDefaultArgs), proxy: unwrap_impl(proxy), slowMo: unwrap_impl(slowMo), timeout: unwrap_impl(timeout), tracesDir: unwrap_impl(tracesDir), &wrap_block_call(block)))
|
|
118
114
|
end
|
|
119
115
|
|
|
116
|
+
#
|
|
120
117
|
# Returns the persistent browser context instance.
|
|
121
|
-
#
|
|
122
|
-
# Launches browser that uses persistent storage located at `userDataDir` and returns the only context. Closing
|
|
123
|
-
# context will automatically close the browser.
|
|
118
|
+
#
|
|
119
|
+
# Launches browser that uses persistent storage located at `userDataDir` and returns the only context. Closing
|
|
120
|
+
# this context will automatically close the browser.
|
|
124
121
|
def launch_persistent_context(
|
|
125
122
|
userDataDir,
|
|
126
123
|
acceptDownloads: nil,
|
|
127
124
|
args: nil,
|
|
125
|
+
baseURL: nil,
|
|
128
126
|
bypassCSP: nil,
|
|
127
|
+
channel: nil,
|
|
129
128
|
chromiumSandbox: nil,
|
|
129
|
+
clientCertificates: nil,
|
|
130
130
|
colorScheme: nil,
|
|
131
|
+
contrast: nil,
|
|
131
132
|
deviceScaleFactor: nil,
|
|
132
|
-
devtools: nil,
|
|
133
133
|
downloadsPath: nil,
|
|
134
134
|
env: nil,
|
|
135
135
|
executablePath: nil,
|
|
136
136
|
extraHTTPHeaders: nil,
|
|
137
|
+
firefoxUserPrefs: nil,
|
|
138
|
+
forcedColors: nil,
|
|
137
139
|
geolocation: nil,
|
|
138
140
|
handleSIGHUP: nil,
|
|
139
141
|
handleSIGINT: nil,
|
|
@@ -146,60 +148,32 @@ module Playwright
|
|
|
146
148
|
isMobile: nil,
|
|
147
149
|
javaScriptEnabled: nil,
|
|
148
150
|
locale: nil,
|
|
149
|
-
|
|
151
|
+
noViewport: nil,
|
|
150
152
|
offline: nil,
|
|
151
153
|
permissions: nil,
|
|
152
154
|
proxy: nil,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
+
record_har_content: nil,
|
|
156
|
+
record_har_mode: nil,
|
|
157
|
+
record_har_omit_content: nil,
|
|
158
|
+
record_har_path: nil,
|
|
159
|
+
record_har_url_filter: nil,
|
|
160
|
+
record_video_dir: nil,
|
|
161
|
+
record_video_size: nil,
|
|
162
|
+
reducedMotion: nil,
|
|
163
|
+
screen: nil,
|
|
164
|
+
serviceWorkers: nil,
|
|
155
165
|
slowMo: nil,
|
|
166
|
+
strictSelectors: nil,
|
|
156
167
|
timeout: nil,
|
|
157
168
|
timezoneId: nil,
|
|
169
|
+
tracesDir: nil,
|
|
158
170
|
userAgent: nil,
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
raise NotImplementedError.new('launch_persistent_context is not implemented yet.')
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
# Returns the browser app instance.
|
|
166
|
-
#
|
|
167
|
-
# Launches browser server that client can connect to. An example of launching a browser executable and connecting to it
|
|
168
|
-
# later:
|
|
169
|
-
#
|
|
170
|
-
#
|
|
171
|
-
# ```js
|
|
172
|
-
# const { chromium } = require('playwright'); // Or 'webkit' or 'firefox'.
|
|
173
|
-
#
|
|
174
|
-
# (async () => {
|
|
175
|
-
# const browserServer = await chromium.launchServer();
|
|
176
|
-
# const wsEndpoint = browserServer.wsEndpoint();
|
|
177
|
-
# // Use web socket endpoint later to establish a connection.
|
|
178
|
-
# const browser = await chromium.connect({ wsEndpoint });
|
|
179
|
-
# // Close browser instance.
|
|
180
|
-
# await browserServer.close();
|
|
181
|
-
# })();
|
|
182
|
-
# ```
|
|
183
|
-
def launch_server(
|
|
184
|
-
args: nil,
|
|
185
|
-
chromiumSandbox: nil,
|
|
186
|
-
devtools: nil,
|
|
187
|
-
downloadsPath: nil,
|
|
188
|
-
env: nil,
|
|
189
|
-
executablePath: nil,
|
|
190
|
-
firefoxUserPrefs: nil,
|
|
191
|
-
handleSIGHUP: nil,
|
|
192
|
-
handleSIGINT: nil,
|
|
193
|
-
handleSIGTERM: nil,
|
|
194
|
-
headless: nil,
|
|
195
|
-
ignoreDefaultArgs: nil,
|
|
196
|
-
logger: nil,
|
|
197
|
-
port: nil,
|
|
198
|
-
proxy: nil,
|
|
199
|
-
timeout: nil)
|
|
200
|
-
raise NotImplementedError.new('launch_server is not implemented yet.')
|
|
171
|
+
viewport: nil,
|
|
172
|
+
&block)
|
|
173
|
+
wrap_impl(@impl.launch_persistent_context(unwrap_impl(userDataDir), acceptDownloads: unwrap_impl(acceptDownloads), args: unwrap_impl(args), baseURL: unwrap_impl(baseURL), bypassCSP: unwrap_impl(bypassCSP), channel: unwrap_impl(channel), chromiumSandbox: unwrap_impl(chromiumSandbox), clientCertificates: unwrap_impl(clientCertificates), colorScheme: unwrap_impl(colorScheme), contrast: unwrap_impl(contrast), deviceScaleFactor: unwrap_impl(deviceScaleFactor), downloadsPath: unwrap_impl(downloadsPath), env: unwrap_impl(env), executablePath: unwrap_impl(executablePath), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), firefoxUserPrefs: unwrap_impl(firefoxUserPrefs), forcedColors: unwrap_impl(forcedColors), geolocation: unwrap_impl(geolocation), handleSIGHUP: unwrap_impl(handleSIGHUP), handleSIGINT: unwrap_impl(handleSIGINT), handleSIGTERM: unwrap_impl(handleSIGTERM), hasTouch: unwrap_impl(hasTouch), headless: unwrap_impl(headless), httpCredentials: unwrap_impl(httpCredentials), ignoreDefaultArgs: unwrap_impl(ignoreDefaultArgs), 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_content: unwrap_impl(record_har_content), record_har_mode: unwrap_impl(record_har_mode), record_har_omit_content: unwrap_impl(record_har_omit_content), record_har_path: unwrap_impl(record_har_path), record_har_url_filter: unwrap_impl(record_har_url_filter), record_video_dir: unwrap_impl(record_video_dir), record_video_size: unwrap_impl(record_video_size), reducedMotion: unwrap_impl(reducedMotion), screen: unwrap_impl(screen), serviceWorkers: unwrap_impl(serviceWorkers), slowMo: unwrap_impl(slowMo), strictSelectors: unwrap_impl(strictSelectors), timeout: unwrap_impl(timeout), timezoneId: unwrap_impl(timezoneId), tracesDir: unwrap_impl(tracesDir), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
|
|
201
174
|
end
|
|
202
175
|
|
|
176
|
+
#
|
|
203
177
|
# Returns browser name. For example: `'chromium'`, `'webkit'` or `'firefox'`.
|
|
204
178
|
def name
|
|
205
179
|
wrap_impl(@impl.name)
|
|
@@ -207,20 +181,24 @@ module Playwright
|
|
|
207
181
|
|
|
208
182
|
# -- inherited from EventEmitter --
|
|
209
183
|
# @nodoc
|
|
210
|
-
def
|
|
211
|
-
|
|
184
|
+
def once(event, callback)
|
|
185
|
+
event_emitter_proxy.once(event, callback)
|
|
212
186
|
end
|
|
213
187
|
|
|
214
188
|
# -- inherited from EventEmitter --
|
|
215
189
|
# @nodoc
|
|
216
|
-
def
|
|
217
|
-
|
|
190
|
+
def on(event, callback)
|
|
191
|
+
event_emitter_proxy.on(event, callback)
|
|
218
192
|
end
|
|
219
193
|
|
|
220
194
|
# -- inherited from EventEmitter --
|
|
221
195
|
# @nodoc
|
|
222
|
-
def
|
|
223
|
-
|
|
196
|
+
def off(event, callback)
|
|
197
|
+
event_emitter_proxy.off(event, callback)
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
private def event_emitter_proxy
|
|
201
|
+
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
|
224
202
|
end
|
|
225
203
|
end
|
|
226
204
|
end
|
|
@@ -1,59 +1,56 @@
|
|
|
1
1
|
module Playwright
|
|
2
|
-
#
|
|
3
|
-
#
|
|
2
|
+
#
|
|
4
3
|
# The `CDPSession` instances are used to talk raw Chrome Devtools Protocol:
|
|
5
4
|
# - protocol methods can be called with `session.send` method.
|
|
6
5
|
# - protocol events can be subscribed to with `session.on` method.
|
|
7
|
-
#
|
|
6
|
+
#
|
|
8
7
|
# Useful links:
|
|
9
|
-
# - Documentation on DevTools Protocol can be found here:
|
|
10
|
-
#
|
|
11
|
-
# - Getting Started with DevTools Protocol:
|
|
12
|
-
# https://github.com/aslushnikov/getting-started-with-cdp/blob/master/README.md
|
|
13
|
-
#
|
|
8
|
+
# - Documentation on DevTools Protocol can be found here: [DevTools Protocol Viewer](https://chromedevtools.github.io/devtools-protocol/).
|
|
9
|
+
# - Getting Started with DevTools Protocol: https://github.com/aslushnikov/getting-started-with-cdp/blob/master/README.md
|
|
14
10
|
#
|
|
15
|
-
# ```js
|
|
16
|
-
# const client = await page.context().newCDPSession(page);
|
|
17
|
-
# await client.send('Animation.enable');
|
|
18
|
-
# client.on('Animation.animationCreated', () => console.log('Animation created!'));
|
|
19
|
-
# const response = await client.send('Animation.getPlaybackRate');
|
|
20
|
-
# console.log('playback rate is ' + response.playbackRate);
|
|
21
|
-
# await client.send('Animation.setPlaybackRate', {
|
|
22
|
-
# playbackRate: response.playbackRate / 2
|
|
23
|
-
# });
|
|
24
|
-
# ```
|
|
25
|
-
#
|
|
26
|
-
# ```python async
|
|
27
|
-
# client = await page.context().new_cdp_session(page)
|
|
28
|
-
# await client.send("animation.enable")
|
|
29
|
-
# client.on("animation.animation_created", lambda: print("animation created!"))
|
|
30
|
-
# response = await client.send("animation.get_playback_rate")
|
|
31
|
-
# print("playback rate is " + response["playback_rate"])
|
|
32
|
-
# await client.send("animation.set_playback_rate", {
|
|
33
|
-
# playback_rate: response["playback_rate"] / 2
|
|
34
|
-
# })
|
|
35
|
-
# ```
|
|
36
|
-
#
|
|
37
11
|
# ```python sync
|
|
38
|
-
# client = page.context
|
|
39
|
-
# client.send("
|
|
40
|
-
# client.on("
|
|
41
|
-
# response = client.send("
|
|
42
|
-
# print("playback rate is " + response["
|
|
43
|
-
# client.send("
|
|
44
|
-
#
|
|
12
|
+
# client = page.context.new_cdp_session(page)
|
|
13
|
+
# client.send("Animation.enable")
|
|
14
|
+
# client.on("Animation.animationCreated", lambda: print("animation created!"))
|
|
15
|
+
# response = client.send("Animation.getPlaybackRate")
|
|
16
|
+
# print("playback rate is " + str(response["playbackRate"]))
|
|
17
|
+
# client.send("Animation.setPlaybackRate", {
|
|
18
|
+
# "playbackRate": response["playbackRate"] / 2
|
|
45
19
|
# })
|
|
46
20
|
# ```
|
|
47
21
|
class CDPSession < PlaywrightApi
|
|
48
22
|
|
|
23
|
+
#
|
|
49
24
|
# Detaches the CDPSession from the target. Once detached, the CDPSession object won't emit any events and can't be used to
|
|
50
25
|
# send messages.
|
|
51
26
|
def detach
|
|
52
|
-
|
|
27
|
+
wrap_impl(@impl.detach)
|
|
53
28
|
end
|
|
54
29
|
|
|
55
30
|
def send_message(method, params: nil)
|
|
56
|
-
|
|
31
|
+
wrap_impl(@impl.send_message(unwrap_impl(method), params: unwrap_impl(params)))
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# -- inherited from EventEmitter --
|
|
35
|
+
# @nodoc
|
|
36
|
+
def once(event, callback)
|
|
37
|
+
event_emitter_proxy.once(event, callback)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# -- inherited from EventEmitter --
|
|
41
|
+
# @nodoc
|
|
42
|
+
def on(event, callback)
|
|
43
|
+
event_emitter_proxy.on(event, callback)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# -- inherited from EventEmitter --
|
|
47
|
+
# @nodoc
|
|
48
|
+
def off(event, callback)
|
|
49
|
+
event_emitter_proxy.off(event, callback)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
private def event_emitter_proxy
|
|
53
|
+
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
|
57
54
|
end
|
|
58
55
|
end
|
|
59
56
|
end
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
module Playwright
|
|
2
|
+
#
|
|
3
|
+
# Accurately simulating time-dependent behavior is essential for verifying the correctness of applications. Learn more about [clock emulation](../clock.md).
|
|
4
|
+
#
|
|
5
|
+
# Note that clock is installed for the entire `BrowserContext`, so the time
|
|
6
|
+
# in all the pages and iframes is controlled by the same clock.
|
|
7
|
+
class Clock < PlaywrightApi
|
|
8
|
+
|
|
9
|
+
#
|
|
10
|
+
# Advance the clock by jumping forward in time. Only fires due timers at most once. This is equivalent to user closing the laptop lid for a while and
|
|
11
|
+
# reopening it later, after given time.
|
|
12
|
+
#
|
|
13
|
+
# **Usage**
|
|
14
|
+
#
|
|
15
|
+
# ```python sync
|
|
16
|
+
# page.clock.fast_forward(1000)
|
|
17
|
+
# page.clock.fast_forward("30:00")
|
|
18
|
+
# ```
|
|
19
|
+
def fast_forward(ticks)
|
|
20
|
+
wrap_impl(@impl.fast_forward(unwrap_impl(ticks)))
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
#
|
|
24
|
+
# Install fake implementations for the following time-related functions:
|
|
25
|
+
# - `Date`
|
|
26
|
+
# - `setTimeout`
|
|
27
|
+
# - `clearTimeout`
|
|
28
|
+
# - `setInterval`
|
|
29
|
+
# - `clearInterval`
|
|
30
|
+
# - `requestAnimationFrame`
|
|
31
|
+
# - `cancelAnimationFrame`
|
|
32
|
+
# - `requestIdleCallback`
|
|
33
|
+
# - `cancelIdleCallback`
|
|
34
|
+
# - `performance`
|
|
35
|
+
#
|
|
36
|
+
# Fake timers are used to manually control the flow of time in tests. They allow you to advance time, fire timers, and control the behavior of time-dependent functions. See [`method: Clock.runFor`] and [`method: Clock.fastForward`] for more information.
|
|
37
|
+
def install(time: nil)
|
|
38
|
+
wrap_impl(@impl.install(time: unwrap_impl(time)))
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
#
|
|
42
|
+
# Advance the clock, firing all the time-related callbacks.
|
|
43
|
+
#
|
|
44
|
+
# **Usage**
|
|
45
|
+
#
|
|
46
|
+
# ```python sync
|
|
47
|
+
# page.clock.run_for(1000);
|
|
48
|
+
# page.clock.run_for("30:00")
|
|
49
|
+
# ```
|
|
50
|
+
def run_for(ticks)
|
|
51
|
+
wrap_impl(@impl.run_for(unwrap_impl(ticks)))
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
#
|
|
55
|
+
# Advance the clock by jumping forward in time and pause the time. Once this method is called, no timers
|
|
56
|
+
# are fired unless [`method: Clock.runFor`], [`method: Clock.fastForward`], [`method: Clock.pauseAt`] or [`method: Clock.resume`] is called.
|
|
57
|
+
#
|
|
58
|
+
# Only fires due timers at most once.
|
|
59
|
+
# This is equivalent to user closing the laptop lid for a while and reopening it at the specified time and
|
|
60
|
+
# pausing.
|
|
61
|
+
#
|
|
62
|
+
# **Usage**
|
|
63
|
+
#
|
|
64
|
+
# ```python sync
|
|
65
|
+
# page.clock.pause_at(datetime.datetime(2020, 2, 2))
|
|
66
|
+
# page.clock.pause_at("2020-02-02")
|
|
67
|
+
# ```
|
|
68
|
+
#
|
|
69
|
+
# For best results, install the clock before navigating the page and set it to a time slightly before the intended test time. This ensures that all timers run normally during page loading, preventing the page from getting stuck. Once the page has fully loaded, you can safely use [`method: Clock.pauseAt`] to pause the clock.
|
|
70
|
+
#
|
|
71
|
+
# ```python sync
|
|
72
|
+
# # Initialize clock with some time before the test time and let the page load
|
|
73
|
+
# # naturally. `Date.now` will progress as the timers fire.
|
|
74
|
+
# page.clock.install(time=datetime.datetime(2024, 12, 10, 8, 0, 0))
|
|
75
|
+
# page.goto("http://localhost:3333")
|
|
76
|
+
# page.clock.pause_at(datetime.datetime(2024, 12, 10, 10, 0, 0))
|
|
77
|
+
# ```
|
|
78
|
+
def pause_at(time)
|
|
79
|
+
wrap_impl(@impl.pause_at(unwrap_impl(time)))
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
#
|
|
83
|
+
# Resumes timers. Once this method is called, time resumes flowing, timers are fired as usual.
|
|
84
|
+
def resume
|
|
85
|
+
wrap_impl(@impl.resume)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
#
|
|
89
|
+
# Makes `Date.now` and `new Date()` return fixed fake time at all times,
|
|
90
|
+
# keeps all the timers running.
|
|
91
|
+
#
|
|
92
|
+
# Use this method for simple scenarios where you only need to test with a predefined time. For more advanced scenarios, use [`method: Clock.install`] instead. Read docs on [clock emulation](../clock.md) to learn more.
|
|
93
|
+
#
|
|
94
|
+
# **Usage**
|
|
95
|
+
#
|
|
96
|
+
# ```python sync
|
|
97
|
+
# page.clock.set_fixed_time(datetime.datetime.now())
|
|
98
|
+
# page.clock.set_fixed_time(datetime.datetime(2020, 2, 2))
|
|
99
|
+
# page.clock.set_fixed_time("2020-02-02")
|
|
100
|
+
# ```
|
|
101
|
+
def set_fixed_time(time)
|
|
102
|
+
wrap_impl(@impl.set_fixed_time(unwrap_impl(time)))
|
|
103
|
+
end
|
|
104
|
+
alias_method :fixed_time=, :set_fixed_time
|
|
105
|
+
|
|
106
|
+
#
|
|
107
|
+
# Sets system time, but does not trigger any timers. Use this to test how the web page reacts to a time shift, for example switching from summer to winter time, or changing time zones.
|
|
108
|
+
#
|
|
109
|
+
# **Usage**
|
|
110
|
+
#
|
|
111
|
+
# ```python sync
|
|
112
|
+
# page.clock.set_system_time(datetime.datetime.now())
|
|
113
|
+
# page.clock.set_system_time(datetime.datetime(2020, 2, 2))
|
|
114
|
+
# page.clock.set_system_time("2020-02-02")
|
|
115
|
+
# ```
|
|
116
|
+
def set_system_time(time)
|
|
117
|
+
wrap_impl(@impl.set_system_time(unwrap_impl(time)))
|
|
118
|
+
end
|
|
119
|
+
alias_method :system_time=, :set_system_time
|
|
120
|
+
end
|
|
121
|
+
end
|
|
@@ -1,7 +1,30 @@
|
|
|
1
1
|
module Playwright
|
|
2
|
+
#
|
|
2
3
|
# `ConsoleMessage` objects are dispatched by page via the [`event: Page.console`] event.
|
|
4
|
+
# For each console message logged in the page there will be corresponding event in the Playwright
|
|
5
|
+
# context.
|
|
6
|
+
#
|
|
7
|
+
# ```python sync
|
|
8
|
+
# # Listen for all console logs
|
|
9
|
+
# page.on("console", lambda msg: print(msg.text))
|
|
10
|
+
#
|
|
11
|
+
# # Listen for all console events and handle errors
|
|
12
|
+
# page.on("console", lambda msg: print(f"error: {msg.text}") if msg.type == "error" else None)
|
|
13
|
+
#
|
|
14
|
+
# # Get the next console log
|
|
15
|
+
# with page.expect_console_message() as msg_info:
|
|
16
|
+
# # Issue console.log inside the page
|
|
17
|
+
# page.evaluate("console.log('hello', 42, { foo: 'bar' })")
|
|
18
|
+
# msg = msg_info.value
|
|
19
|
+
#
|
|
20
|
+
# # Deconstruct print arguments
|
|
21
|
+
# msg.args[0].json_value() # hello
|
|
22
|
+
# msg.args[1].json_value() # 42
|
|
23
|
+
# ```
|
|
3
24
|
class ConsoleMessage < PlaywrightApi
|
|
4
25
|
|
|
26
|
+
#
|
|
27
|
+
# List of arguments passed to a `console` function call. See also [`event: Page.console`].
|
|
5
28
|
def args
|
|
6
29
|
wrap_impl(@impl.args)
|
|
7
30
|
end
|
|
@@ -10,33 +33,26 @@ module Playwright
|
|
|
10
33
|
wrap_impl(@impl.location)
|
|
11
34
|
end
|
|
12
35
|
|
|
36
|
+
#
|
|
37
|
+
# The page that produced this console message, if any.
|
|
38
|
+
def page
|
|
39
|
+
wrap_impl(@impl.page)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
#
|
|
43
|
+
# The text of the console message.
|
|
13
44
|
def text
|
|
14
45
|
wrap_impl(@impl.text)
|
|
15
46
|
end
|
|
16
47
|
|
|
17
|
-
# One of the following values: `'log'`, `'debug'`, `'info'`, `'error'`, `'warning'`, `'dir'`, `'dirxml'`, `'table'`,
|
|
18
|
-
# `'trace'`, `'clear'`, `'startGroup'`, `'startGroupCollapsed'`, `'endGroup'`, `'assert'`, `'profile'`, `'profileEnd'`,
|
|
19
|
-
# `'count'`, `'timeEnd'`.
|
|
20
48
|
def type
|
|
21
49
|
wrap_impl(@impl.type)
|
|
22
50
|
end
|
|
23
51
|
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
def
|
|
27
|
-
wrap_impl(@impl.
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
# -- inherited from EventEmitter --
|
|
31
|
-
# @nodoc
|
|
32
|
-
def off(event, callback)
|
|
33
|
-
wrap_impl(@impl.off(unwrap_impl(event), unwrap_impl(callback)))
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# -- inherited from EventEmitter --
|
|
37
|
-
# @nodoc
|
|
38
|
-
def once(event, callback)
|
|
39
|
-
wrap_impl(@impl.once(unwrap_impl(event), unwrap_impl(callback)))
|
|
52
|
+
#
|
|
53
|
+
# The web worker or service worker that produced this console message, if any. Note that console messages from web workers also have non-null [`method: ConsoleMessage.page`].
|
|
54
|
+
def worker
|
|
55
|
+
wrap_impl(@impl.worker)
|
|
40
56
|
end
|
|
41
57
|
end
|
|
42
58
|
end
|