venetian 0.1.0-aarch64-linux
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 +7 -0
- data/CODE_OF_CONDUCT.md +10 -0
- data/LICENSE.txt +21 -0
- data/README.md +52 -0
- data/Rakefile +14 -0
- data/exe/aarch64-linux/LICENSE +2946 -0
- data/exe/aarch64-linux/node +0 -0
- data/exe/aarch64-linux/package/LICENSE +202 -0
- data/exe/aarch64-linux/package/NOTICE +5 -0
- data/exe/aarch64-linux/package/README.md +3 -0
- data/exe/aarch64-linux/package/ThirdPartyNotices.txt +13 -0
- data/exe/aarch64-linux/package/api.json +1 -0
- data/exe/aarch64-linux/package/bin/install_media_pack.ps1 +5 -0
- data/exe/aarch64-linux/package/bin/install_webkit_wsl.ps1 +33 -0
- data/exe/aarch64-linux/package/bin/reinstall_chrome_beta_linux.sh +42 -0
- data/exe/aarch64-linux/package/bin/reinstall_chrome_beta_mac.sh +13 -0
- data/exe/aarch64-linux/package/bin/reinstall_chrome_beta_win.ps1 +24 -0
- data/exe/aarch64-linux/package/bin/reinstall_chrome_stable_linux.sh +42 -0
- data/exe/aarch64-linux/package/bin/reinstall_chrome_stable_mac.sh +12 -0
- data/exe/aarch64-linux/package/bin/reinstall_chrome_stable_win.ps1 +24 -0
- data/exe/aarch64-linux/package/bin/reinstall_msedge_beta_linux.sh +48 -0
- data/exe/aarch64-linux/package/bin/reinstall_msedge_beta_mac.sh +11 -0
- data/exe/aarch64-linux/package/bin/reinstall_msedge_beta_win.ps1 +23 -0
- data/exe/aarch64-linux/package/bin/reinstall_msedge_dev_linux.sh +48 -0
- data/exe/aarch64-linux/package/bin/reinstall_msedge_dev_mac.sh +11 -0
- data/exe/aarch64-linux/package/bin/reinstall_msedge_dev_win.ps1 +23 -0
- data/exe/aarch64-linux/package/bin/reinstall_msedge_stable_linux.sh +48 -0
- data/exe/aarch64-linux/package/bin/reinstall_msedge_stable_mac.sh +11 -0
- data/exe/aarch64-linux/package/bin/reinstall_msedge_stable_win.ps1 +24 -0
- data/exe/aarch64-linux/package/browsers.json +81 -0
- data/exe/aarch64-linux/package/cli.js +21 -0
- data/exe/aarch64-linux/package/index.d.ts +17 -0
- data/exe/aarch64-linux/package/index.js +32 -0
- data/exe/aarch64-linux/package/index.mjs +28 -0
- data/exe/aarch64-linux/package/lib/bootstrap.js +77 -0
- data/exe/aarch64-linux/package/lib/coreBundle.js +69799 -0
- data/exe/aarch64-linux/package/lib/entry/cliDaemon.js +5 -0
- data/exe/aarch64-linux/package/lib/entry/dashboardApp.js +3 -0
- data/exe/aarch64-linux/package/lib/entry/mcp.js +10 -0
- data/exe/aarch64-linux/package/lib/entry/oopBrowserDownload.js +3 -0
- data/exe/aarch64-linux/package/lib/package.js +50 -0
- data/exe/aarch64-linux/package/lib/server/chromium/appIcon.png +0 -0
- data/exe/aarch64-linux/package/lib/server/deviceDescriptorsSource.json +1779 -0
- data/exe/aarch64-linux/package/lib/server/electron/loader.js +115 -0
- data/exe/aarch64-linux/package/lib/serverRegistry.js +7343 -0
- data/exe/aarch64-linux/package/lib/serverRegistry.js.LICENSE +354 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/channelSessions.js +141 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/cli.js +6 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/help.json +679 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/minimist.js +128 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/output.js +343 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/program.js +380 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/registry.js +176 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/session.js +265 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/skill/SKILL.md +388 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/skill/references/element-attributes.md +23 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/skill/references/playwright-tests.md +39 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/skill/references/request-mocking.md +87 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/skill/references/running-code.md +241 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/skill/references/session-management.md +225 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/skill/references/spec-driven-testing.md +305 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/skill/references/storage-state.md +275 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/skill/references/test-generation.md +134 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/skill/references/tracing.md +139 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/skill/references/video-recording.md +143 -0
- data/exe/aarch64-linux/package/lib/tools/dashboard/appIcon.png +0 -0
- data/exe/aarch64-linux/package/lib/tools/trace/SKILL.md +171 -0
- data/exe/aarch64-linux/package/lib/tools/utils/extension.js +78 -0
- data/exe/aarch64-linux/package/lib/tools/utils/socketConnection.js +108 -0
- data/exe/aarch64-linux/package/lib/utilsBundle.js +85418 -0
- data/exe/aarch64-linux/package/lib/utilsBundle.js.LICENSE +2002 -0
- data/exe/aarch64-linux/package/lib/vite/dashboard/assets/codicon-DCmgc-ay.ttf +0 -0
- data/exe/aarch64-linux/package/lib/vite/dashboard/assets/firefox-1bWoP6pv.svg +1 -0
- data/exe/aarch64-linux/package/lib/vite/dashboard/assets/firefox-beta-k3eOH_eK.svg +1 -0
- data/exe/aarch64-linux/package/lib/vite/dashboard/assets/firefox-nightly-Cp5nfeDT.svg +1 -0
- data/exe/aarch64-linux/package/lib/vite/dashboard/assets/index-BY2S1tHT.css +1 -0
- data/exe/aarch64-linux/package/lib/vite/dashboard/assets/index-DpEq2p62.js +52 -0
- data/exe/aarch64-linux/package/lib/vite/dashboard/assets/safari-na3_-uQk.svg +1 -0
- data/exe/aarch64-linux/package/lib/vite/dashboard/index.html +29 -0
- data/exe/aarch64-linux/package/lib/vite/dashboard/playwright-logo.svg +24 -0
- data/exe/aarch64-linux/package/lib/vite/htmlReport/index.html +16 -0
- data/exe/aarch64-linux/package/lib/vite/htmlReport/report.css +1 -0
- data/exe/aarch64-linux/package/lib/vite/htmlReport/report.js +72 -0
- data/exe/aarch64-linux/package/lib/vite/recorder/assets/codeMirrorModule-BHYmBp6h.js +32 -0
- data/exe/aarch64-linux/package/lib/vite/recorder/assets/codeMirrorModule-DYBRYzYX.css +1 -0
- data/exe/aarch64-linux/package/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
- data/exe/aarch64-linux/package/lib/vite/recorder/assets/index-4ZiSSCmn.css +1 -0
- data/exe/aarch64-linux/package/lib/vite/recorder/assets/index-DA10QRaq.js +193 -0
- data/exe/aarch64-linux/package/lib/vite/recorder/index.html +29 -0
- data/exe/aarch64-linux/package/lib/vite/recorder/playwright-logo.svg +9 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/assets/codeMirrorModule-Ds_H_9Yq.js +32 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/assets/defaultSettingsView-D31xz8zv.js +262 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/assets/urlMatch-BYQrIQwR.js +1 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/assets/xtermModule-CsJ4vdCR.js +9 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/codeMirrorModule.DYBRYzYX.css +1 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/defaultSettingsView.BDKsFU3c.css +1 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/index.BCnMPevh.js +2 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/index.CzXZzn5A.css +1 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/index.html +44 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/manifest.webmanifest +16 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/playwright-logo.svg +9 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/snapshot.html +10 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/snapshot.v8KI4P3m.js +2 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/sw.bundle.js +5 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/uiMode.Btcz36p_.css +1 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/uiMode.C2Efnu2P.js +6 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/uiMode.html +18 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/xtermModule.DYP7pi_n.css +32 -0
- data/exe/aarch64-linux/package/lib/xdg-open +1066 -0
- data/exe/aarch64-linux/package/package.json +34 -0
- data/exe/aarch64-linux/package/protocol.yml +4884 -0
- data/exe/aarch64-linux/package/types/protocol.d.ts +24565 -0
- data/exe/aarch64-linux/package/types/structs.d.ts +45 -0
- data/exe/aarch64-linux/package/types/types.d.ts +24518 -0
- data/exe/playwright +11 -0
- data/lib/tasks/venetian.rake +11 -0
- data/lib/venetian/browser_installer.rb +26 -0
- data/lib/venetian/browser_runner_extensions.rb +17 -0
- data/lib/venetian/executable.rb +154 -0
- data/lib/venetian/gemspec.rb +7 -0
- data/lib/venetian/playwright_create_extensions.rb +11 -0
- data/lib/venetian/railtie.rb +9 -0
- data/lib/venetian/tasks.rb +3 -0
- data/lib/venetian/upstream.rb +45 -0
- data/lib/venetian/version.rb +5 -0
- data/lib/venetian.rb +29 -0
- metadata +185 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Running Playwright Tests
|
|
2
|
+
|
|
3
|
+
To run Playwright tests, use the `npx playwright test` command, or a package manager script. To avoid opening the interactive html report, use `PLAYWRIGHT_HTML_OPEN=never` environment variable.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
# Run all tests
|
|
7
|
+
PLAYWRIGHT_HTML_OPEN=never npx playwright test
|
|
8
|
+
|
|
9
|
+
# Run all tests through a custom npm script
|
|
10
|
+
PLAYWRIGHT_HTML_OPEN=never npm run special-test-command
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
# Debugging Playwright Tests
|
|
14
|
+
|
|
15
|
+
To debug a failing Playwright test, run it with `--debug=cli` option. This command will pause the test at the start and print the debugging instructions.
|
|
16
|
+
|
|
17
|
+
**IMPORTANT**: run the command in the background and check the output until "Debugging Instructions" is printed. Make sure to stop the command after you have finished.
|
|
18
|
+
|
|
19
|
+
Once instructions containing a session name are printed, use `playwright-cli` to attach the session and explore the page.
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Run the test
|
|
23
|
+
PLAYWRIGHT_HTML_OPEN=never npx playwright test --debug=cli
|
|
24
|
+
# ...
|
|
25
|
+
# ... debugging instructions for "tw-abcdef" session ...
|
|
26
|
+
# ...
|
|
27
|
+
|
|
28
|
+
# Attach to the test
|
|
29
|
+
playwright-cli attach tw-abcdef
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Keep the test running in the background while you explore and look for a fix.
|
|
33
|
+
The test is paused at the start, so you should step over or pause at a particular location
|
|
34
|
+
where the problem is most likely to be.
|
|
35
|
+
|
|
36
|
+
Every action you perform with `playwright-cli` generates corresponding Playwright TypeScript code.
|
|
37
|
+
This code appears in the output and can be copied directly into the test. Most of the time, a specific locator or an expectation should be updated, but it could also be a bug in the app. Use your judgement.
|
|
38
|
+
|
|
39
|
+
After fixing the test, stop the background test run. Rerun to check that test passes.
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Request Mocking
|
|
2
|
+
|
|
3
|
+
Intercept, mock, modify, and block network requests.
|
|
4
|
+
|
|
5
|
+
## CLI Route Commands
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Mock with custom status
|
|
9
|
+
playwright-cli route "**/*.jpg" --status=404
|
|
10
|
+
|
|
11
|
+
# Mock with JSON body
|
|
12
|
+
playwright-cli route "**/api/users" --body='[{"id":1,"name":"Alice"}]' --content-type=application/json
|
|
13
|
+
|
|
14
|
+
# Mock with custom headers
|
|
15
|
+
playwright-cli route "**/api/data" --body='{"ok":true}' --header="X-Custom: value"
|
|
16
|
+
|
|
17
|
+
# Remove headers from requests
|
|
18
|
+
playwright-cli route "**/*" --remove-header=cookie,authorization
|
|
19
|
+
|
|
20
|
+
# List active routes
|
|
21
|
+
playwright-cli route-list
|
|
22
|
+
|
|
23
|
+
# Remove a route or all routes
|
|
24
|
+
playwright-cli unroute "**/*.jpg"
|
|
25
|
+
playwright-cli unroute
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## URL Patterns
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
**/api/users - Exact path match
|
|
32
|
+
**/api/*/details - Wildcard in path
|
|
33
|
+
**/*.{png,jpg,jpeg} - Match file extensions
|
|
34
|
+
**/search?q=* - Match query parameters
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Advanced Mocking with run-code
|
|
38
|
+
|
|
39
|
+
For conditional responses, request body inspection, response modification, or delays:
|
|
40
|
+
|
|
41
|
+
### Conditional Response Based on Request
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
playwright-cli run-code "async page => {
|
|
45
|
+
await page.route('**/api/login', route => {
|
|
46
|
+
const body = route.request().postDataJSON();
|
|
47
|
+
if (body.username === 'admin') {
|
|
48
|
+
route.fulfill({ body: JSON.stringify({ token: 'mock-token' }) });
|
|
49
|
+
} else {
|
|
50
|
+
route.fulfill({ status: 401, body: JSON.stringify({ error: 'Invalid' }) });
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Modify Real Response
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
playwright-cli run-code "async page => {
|
|
60
|
+
await page.route('**/api/user', async route => {
|
|
61
|
+
const response = await route.fetch();
|
|
62
|
+
const json = await response.json();
|
|
63
|
+
json.isPremium = true;
|
|
64
|
+
await route.fulfill({ response, json });
|
|
65
|
+
});
|
|
66
|
+
}"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Simulate Network Failures
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
playwright-cli run-code "async page => {
|
|
73
|
+
await page.route('**/api/offline', route => route.abort('internetdisconnected'));
|
|
74
|
+
}"
|
|
75
|
+
# Options: connectionrefused, timedout, connectionreset, internetdisconnected
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Delayed Response
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
playwright-cli run-code "async page => {
|
|
82
|
+
await page.route('**/api/slow', async route => {
|
|
83
|
+
await new Promise(r => setTimeout(r, 3000));
|
|
84
|
+
route.fulfill({ body: JSON.stringify({ data: 'loaded' }) });
|
|
85
|
+
});
|
|
86
|
+
}"
|
|
87
|
+
```
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
# Running Custom Playwright Code
|
|
2
|
+
|
|
3
|
+
Use `run-code` to execute arbitrary Playwright code for advanced scenarios not covered by CLI commands.
|
|
4
|
+
|
|
5
|
+
## Syntax
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
playwright-cli run-code "async page => {
|
|
9
|
+
// Your Playwright code here
|
|
10
|
+
// Access page.context() for browser context operations
|
|
11
|
+
}"
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
You can also load the function from a file:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
playwright-cli run-code --filename=./my-script.js
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
The code must be a single function expression, it is wrapped in `(...)` and evaluated.
|
|
22
|
+
import/export/require syntax is not supported.
|
|
23
|
+
|
|
24
|
+
## Geolocation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Grant geolocation permission and set location
|
|
28
|
+
playwright-cli run-code "async page => {
|
|
29
|
+
await page.context().grantPermissions(['geolocation']);
|
|
30
|
+
await page.context().setGeolocation({ latitude: 37.7749, longitude: -122.4194 });
|
|
31
|
+
}"
|
|
32
|
+
|
|
33
|
+
# Set location to London
|
|
34
|
+
playwright-cli run-code "async page => {
|
|
35
|
+
await page.context().grantPermissions(['geolocation']);
|
|
36
|
+
await page.context().setGeolocation({ latitude: 51.5074, longitude: -0.1278 });
|
|
37
|
+
}"
|
|
38
|
+
|
|
39
|
+
# Clear geolocation override
|
|
40
|
+
playwright-cli run-code "async page => {
|
|
41
|
+
await page.context().clearPermissions();
|
|
42
|
+
}"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Permissions
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# Grant multiple permissions
|
|
49
|
+
playwright-cli run-code "async page => {
|
|
50
|
+
await page.context().grantPermissions([
|
|
51
|
+
'geolocation',
|
|
52
|
+
'notifications',
|
|
53
|
+
'camera',
|
|
54
|
+
'microphone'
|
|
55
|
+
]);
|
|
56
|
+
}"
|
|
57
|
+
|
|
58
|
+
# Grant permissions for specific origin
|
|
59
|
+
playwright-cli run-code "async page => {
|
|
60
|
+
await page.context().grantPermissions(['clipboard-read'], {
|
|
61
|
+
origin: 'https://example.com'
|
|
62
|
+
});
|
|
63
|
+
}"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Media Emulation
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# Emulate dark color scheme
|
|
70
|
+
playwright-cli run-code "async page => {
|
|
71
|
+
await page.emulateMedia({ colorScheme: 'dark' });
|
|
72
|
+
}"
|
|
73
|
+
|
|
74
|
+
# Emulate light color scheme
|
|
75
|
+
playwright-cli run-code "async page => {
|
|
76
|
+
await page.emulateMedia({ colorScheme: 'light' });
|
|
77
|
+
}"
|
|
78
|
+
|
|
79
|
+
# Emulate reduced motion
|
|
80
|
+
playwright-cli run-code "async page => {
|
|
81
|
+
await page.emulateMedia({ reducedMotion: 'reduce' });
|
|
82
|
+
}"
|
|
83
|
+
|
|
84
|
+
# Emulate print media
|
|
85
|
+
playwright-cli run-code "async page => {
|
|
86
|
+
await page.emulateMedia({ media: 'print' });
|
|
87
|
+
}"
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Wait Strategies
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# Wait for network idle
|
|
94
|
+
playwright-cli run-code "async page => {
|
|
95
|
+
await page.waitForLoadState('networkidle');
|
|
96
|
+
}"
|
|
97
|
+
|
|
98
|
+
# Wait for specific element
|
|
99
|
+
playwright-cli run-code "async page => {
|
|
100
|
+
await page.locator('.loading').waitFor({ state: 'hidden' });
|
|
101
|
+
}"
|
|
102
|
+
|
|
103
|
+
# Wait for function to return true
|
|
104
|
+
playwright-cli run-code "async page => {
|
|
105
|
+
await page.waitForFunction(() => window.appReady === true);
|
|
106
|
+
}"
|
|
107
|
+
|
|
108
|
+
# Wait with timeout
|
|
109
|
+
playwright-cli run-code "async page => {
|
|
110
|
+
await page.locator('.result').waitFor({ timeout: 10000 });
|
|
111
|
+
}"
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Frames and Iframes
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# Work with iframe
|
|
118
|
+
playwright-cli run-code "async page => {
|
|
119
|
+
const frame = page.locator('iframe#my-iframe').contentFrame();
|
|
120
|
+
await frame.locator('button').click();
|
|
121
|
+
}"
|
|
122
|
+
|
|
123
|
+
# Get all frames
|
|
124
|
+
playwright-cli run-code "async page => {
|
|
125
|
+
const frames = page.frames();
|
|
126
|
+
return frames.map(f => f.url());
|
|
127
|
+
}"
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## File Downloads
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# Handle file download
|
|
134
|
+
playwright-cli run-code "async page => {
|
|
135
|
+
const downloadPromise = page.waitForEvent('download');
|
|
136
|
+
await page.getByRole('link', { name: 'Download' }).click();
|
|
137
|
+
const download = await downloadPromise;
|
|
138
|
+
await download.saveAs('./downloaded-file.pdf');
|
|
139
|
+
return download.suggestedFilename();
|
|
140
|
+
}"
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Clipboard
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
# Read clipboard (requires permission)
|
|
147
|
+
playwright-cli run-code "async page => {
|
|
148
|
+
await page.context().grantPermissions(['clipboard-read']);
|
|
149
|
+
return await page.evaluate(() => navigator.clipboard.readText());
|
|
150
|
+
}"
|
|
151
|
+
|
|
152
|
+
# Write to clipboard
|
|
153
|
+
playwright-cli run-code "async page => {
|
|
154
|
+
await page.evaluate(text => navigator.clipboard.writeText(text), 'Hello clipboard!');
|
|
155
|
+
}"
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Page Information
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
# Get page title
|
|
162
|
+
playwright-cli run-code "async page => {
|
|
163
|
+
return await page.title();
|
|
164
|
+
}"
|
|
165
|
+
|
|
166
|
+
# Get current URL
|
|
167
|
+
playwright-cli run-code "async page => {
|
|
168
|
+
return page.url();
|
|
169
|
+
}"
|
|
170
|
+
|
|
171
|
+
# Get page content
|
|
172
|
+
playwright-cli run-code "async page => {
|
|
173
|
+
return await page.content();
|
|
174
|
+
}"
|
|
175
|
+
|
|
176
|
+
# Get viewport size
|
|
177
|
+
playwright-cli run-code "async page => {
|
|
178
|
+
return page.viewportSize();
|
|
179
|
+
}"
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## JavaScript Execution
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
# Execute JavaScript and return result
|
|
186
|
+
playwright-cli run-code "async page => {
|
|
187
|
+
return await page.evaluate(() => {
|
|
188
|
+
return {
|
|
189
|
+
userAgent: navigator.userAgent,
|
|
190
|
+
language: navigator.language,
|
|
191
|
+
cookiesEnabled: navigator.cookieEnabled
|
|
192
|
+
};
|
|
193
|
+
});
|
|
194
|
+
}"
|
|
195
|
+
|
|
196
|
+
# Pass arguments to evaluate
|
|
197
|
+
playwright-cli run-code "async page => {
|
|
198
|
+
const multiplier = 5;
|
|
199
|
+
return await page.evaluate(m => document.querySelectorAll('li').length * m, multiplier);
|
|
200
|
+
}"
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Error Handling
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
# Try-catch in run-code
|
|
207
|
+
playwright-cli run-code "async page => {
|
|
208
|
+
try {
|
|
209
|
+
await page.getByRole('button', { name: 'Submit' }).click({ timeout: 1000 });
|
|
210
|
+
return 'clicked';
|
|
211
|
+
} catch (e) {
|
|
212
|
+
return 'element not found';
|
|
213
|
+
}
|
|
214
|
+
}"
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Complex Workflows
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
# Login and save state
|
|
221
|
+
playwright-cli run-code "async page => {
|
|
222
|
+
await page.goto('https://example.com/login');
|
|
223
|
+
await page.getByRole('textbox', { name: 'Email' }).fill('user@example.com');
|
|
224
|
+
await page.getByRole('textbox', { name: 'Password' }).fill('secret');
|
|
225
|
+
await page.getByRole('button', { name: 'Sign in' }).click();
|
|
226
|
+
await page.waitForURL('**/dashboard');
|
|
227
|
+
await page.context().storageState({ path: 'auth.json' });
|
|
228
|
+
return 'Login successful';
|
|
229
|
+
}"
|
|
230
|
+
|
|
231
|
+
# Scrape data from multiple pages
|
|
232
|
+
playwright-cli run-code "async page => {
|
|
233
|
+
const results = [];
|
|
234
|
+
for (let i = 1; i <= 3; i++) {
|
|
235
|
+
await page.goto(\`https://example.com/page/\${i}\`);
|
|
236
|
+
const items = await page.locator('.item').allTextContents();
|
|
237
|
+
results.push(...items);
|
|
238
|
+
}
|
|
239
|
+
return results;
|
|
240
|
+
}"
|
|
241
|
+
```
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
# Browser Session Management
|
|
2
|
+
|
|
3
|
+
Run multiple isolated browser sessions concurrently with state persistence.
|
|
4
|
+
|
|
5
|
+
## Named Browser Sessions
|
|
6
|
+
|
|
7
|
+
Use `-s` flag to isolate browser contexts:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Browser 1: Authentication flow
|
|
11
|
+
playwright-cli -s=auth open https://app.example.com/login
|
|
12
|
+
|
|
13
|
+
# Browser 2: Public browsing (separate cookies, storage)
|
|
14
|
+
playwright-cli -s=public open https://example.com
|
|
15
|
+
|
|
16
|
+
# Commands are isolated by browser session
|
|
17
|
+
playwright-cli -s=auth fill e1 "user@example.com"
|
|
18
|
+
playwright-cli -s=public snapshot
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Browser Session Isolation Properties
|
|
22
|
+
|
|
23
|
+
Each browser session has independent:
|
|
24
|
+
- Cookies
|
|
25
|
+
- LocalStorage / SessionStorage
|
|
26
|
+
- IndexedDB
|
|
27
|
+
- Cache
|
|
28
|
+
- Browsing history
|
|
29
|
+
- Open tabs
|
|
30
|
+
|
|
31
|
+
## Browser Session Commands
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# List all browser sessions
|
|
35
|
+
playwright-cli list
|
|
36
|
+
|
|
37
|
+
# Stop a browser session (close the browser)
|
|
38
|
+
playwright-cli close # stop the default browser
|
|
39
|
+
playwright-cli -s=mysession close # stop a named browser
|
|
40
|
+
|
|
41
|
+
# Stop all browser sessions
|
|
42
|
+
playwright-cli close-all
|
|
43
|
+
|
|
44
|
+
# Forcefully kill all daemon processes (for stale/zombie processes)
|
|
45
|
+
playwright-cli kill-all
|
|
46
|
+
|
|
47
|
+
# Delete browser session user data (profile directory)
|
|
48
|
+
playwright-cli delete-data # delete default browser data
|
|
49
|
+
playwright-cli -s=mysession delete-data # delete named browser data
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Environment Variable
|
|
53
|
+
|
|
54
|
+
Set a default browser session name via environment variable:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
export PLAYWRIGHT_CLI_SESSION="mysession"
|
|
58
|
+
playwright-cli open example.com # Uses "mysession" automatically
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Common Patterns
|
|
62
|
+
|
|
63
|
+
### Concurrent Scraping
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
#!/bin/bash
|
|
67
|
+
# Scrape multiple sites concurrently
|
|
68
|
+
|
|
69
|
+
# Start all browsers
|
|
70
|
+
playwright-cli -s=site1 open https://site1.com &
|
|
71
|
+
playwright-cli -s=site2 open https://site2.com &
|
|
72
|
+
playwright-cli -s=site3 open https://site3.com &
|
|
73
|
+
wait
|
|
74
|
+
|
|
75
|
+
# Take snapshots from each
|
|
76
|
+
playwright-cli -s=site1 snapshot
|
|
77
|
+
playwright-cli -s=site2 snapshot
|
|
78
|
+
playwright-cli -s=site3 snapshot
|
|
79
|
+
|
|
80
|
+
# Cleanup
|
|
81
|
+
playwright-cli close-all
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### A/B Testing Sessions
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Test different user experiences
|
|
88
|
+
playwright-cli -s=variant-a open "https://app.com?variant=a"
|
|
89
|
+
playwright-cli -s=variant-b open "https://app.com?variant=b"
|
|
90
|
+
|
|
91
|
+
# Compare
|
|
92
|
+
playwright-cli -s=variant-a screenshot
|
|
93
|
+
playwright-cli -s=variant-b screenshot
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Persistent Profile
|
|
97
|
+
|
|
98
|
+
By default, browser profile is kept in memory only. Use `--persistent` flag on `open` to persist the browser profile to disk:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# Use persistent profile (auto-generated location)
|
|
102
|
+
playwright-cli open https://example.com --persistent
|
|
103
|
+
|
|
104
|
+
# Use persistent profile with custom directory
|
|
105
|
+
playwright-cli open https://example.com --profile=/path/to/profile
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Attaching to a Running Browser
|
|
109
|
+
|
|
110
|
+
Use `attach` to connect to a browser that is already running, instead of launching a new one.
|
|
111
|
+
|
|
112
|
+
### Attach by channel name
|
|
113
|
+
|
|
114
|
+
Connect to a running Chrome or Edge instance by its channel name. The browser must have remote debugging enabled — navigate to `chrome://inspect/#remote-debugging` in the target browser and check "Allow remote debugging for this browser instance".
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# Attach to Chrome
|
|
118
|
+
playwright-cli attach --cdp=chrome
|
|
119
|
+
|
|
120
|
+
# Attach to Chrome Canary
|
|
121
|
+
playwright-cli attach --cdp=chrome-canary
|
|
122
|
+
|
|
123
|
+
# Attach to Microsoft Edge
|
|
124
|
+
playwright-cli attach --cdp=msedge
|
|
125
|
+
|
|
126
|
+
# Attach to Edge Dev
|
|
127
|
+
playwright-cli attach --cdp=msedge-dev
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Supported channels: `chrome`, `chrome-beta`, `chrome-dev`, `chrome-canary`, `msedge`, `msedge-beta`, `msedge-dev`, `msedge-canary`.
|
|
131
|
+
|
|
132
|
+
When `--session` is not provided, the session is named after the channel (e.g. `--cdp=msedge` creates a session called `msedge`), so parallel attaches to Chrome and Edge don't collide on `default`. Pass `--session=<name>` to override.
|
|
133
|
+
|
|
134
|
+
### Attach via CDP endpoint
|
|
135
|
+
|
|
136
|
+
Connect to a browser that exposes a Chrome DevTools Protocol endpoint:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
playwright-cli attach --cdp=http://localhost:9222
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Attach via browser extension
|
|
143
|
+
|
|
144
|
+
Connect to a browser with the Playwright extension installed:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
playwright-cli attach --extension
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Detach
|
|
151
|
+
|
|
152
|
+
Tear down an attached session without affecting the external browser:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
# Detach the default attached session
|
|
156
|
+
playwright-cli detach
|
|
157
|
+
|
|
158
|
+
# Detach a specific attached session
|
|
159
|
+
playwright-cli -s=msedge detach
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
`detach` only works on sessions created via `attach`. For sessions created via `open`, use `close`.
|
|
163
|
+
|
|
164
|
+
## Default Browser Session
|
|
165
|
+
|
|
166
|
+
When `-s` is omitted, commands use the default browser session:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
# These use the same default browser session
|
|
170
|
+
playwright-cli open https://example.com
|
|
171
|
+
playwright-cli snapshot
|
|
172
|
+
playwright-cli close # Stops default browser
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Browser Session Configuration
|
|
176
|
+
|
|
177
|
+
Configure a browser session with specific settings when opening:
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
# Open with config file
|
|
181
|
+
playwright-cli open https://example.com --config=.playwright/my-cli.json
|
|
182
|
+
|
|
183
|
+
# Open with specific browser
|
|
184
|
+
playwright-cli open https://example.com --browser=firefox
|
|
185
|
+
|
|
186
|
+
# Open in headed mode
|
|
187
|
+
playwright-cli open https://example.com --headed
|
|
188
|
+
|
|
189
|
+
# Open with persistent profile
|
|
190
|
+
playwright-cli open https://example.com --persistent
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Best Practices
|
|
194
|
+
|
|
195
|
+
### 1. Name Browser Sessions Semantically
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
# GOOD: Clear purpose
|
|
199
|
+
playwright-cli -s=github-auth open https://github.com
|
|
200
|
+
playwright-cli -s=docs-scrape open https://docs.example.com
|
|
201
|
+
|
|
202
|
+
# AVOID: Generic names
|
|
203
|
+
playwright-cli -s=s1 open https://github.com
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### 2. Always Clean Up
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
# Stop browsers when done
|
|
210
|
+
playwright-cli -s=auth close
|
|
211
|
+
playwright-cli -s=scrape close
|
|
212
|
+
|
|
213
|
+
# Or stop all at once
|
|
214
|
+
playwright-cli close-all
|
|
215
|
+
|
|
216
|
+
# If browsers become unresponsive or zombie processes remain
|
|
217
|
+
playwright-cli kill-all
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### 3. Delete Stale Browser Data
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
# Remove old browser data to free disk space
|
|
224
|
+
playwright-cli -s=oldsession delete-data
|
|
225
|
+
```
|