@willbooster/agent-skills 1.21.0 → 1.21.2
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.
- package/dist/cli.js +3 -3
- package/package.json +2 -2
- package/skills/playwright-cli/SKILL.md +157 -150
- package/skills/playwright-cli/references/element-attributes.md +6 -6
- package/skills/playwright-cli/references/playwright-tests.md +1 -1
- package/skills/playwright-cli/references/request-mocking.md +11 -11
- package/skills/playwright-cli/references/running-code.md +28 -28
- package/skills/playwright-cli/references/session-management.md +80 -40
- package/skills/playwright-cli/references/storage-state.md +41 -41
- package/skills/playwright-cli/references/test-generation.md +8 -8
- package/skills/playwright-cli/references/tracing.md +22 -22
- package/skills/playwright-cli/references/video-recording.md +13 -13
|
@@ -5,7 +5,7 @@ Use `run-code` to execute arbitrary Playwright code for advanced scenarios not c
|
|
|
5
5
|
## Syntax
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
bunx @playwright/cli@
|
|
8
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
9
9
|
// Your Playwright code here
|
|
10
10
|
// Access page.context() for browser context operations
|
|
11
11
|
}"
|
|
@@ -15,19 +15,19 @@ bunx @playwright/cli@latest run-code "async page => {
|
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
17
|
# Grant geolocation permission and set location
|
|
18
|
-
bunx @playwright/cli@
|
|
18
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
19
19
|
await page.context().grantPermissions(['geolocation']);
|
|
20
20
|
await page.context().setGeolocation({ latitude: 37.7749, longitude: -122.4194 });
|
|
21
21
|
}"
|
|
22
22
|
|
|
23
23
|
# Set location to London
|
|
24
|
-
bunx @playwright/cli@
|
|
24
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
25
25
|
await page.context().grantPermissions(['geolocation']);
|
|
26
26
|
await page.context().setGeolocation({ latitude: 51.5074, longitude: -0.1278 });
|
|
27
27
|
}"
|
|
28
28
|
|
|
29
29
|
# Clear geolocation override
|
|
30
|
-
bunx @playwright/cli@
|
|
30
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
31
31
|
await page.context().clearPermissions();
|
|
32
32
|
}"
|
|
33
33
|
```
|
|
@@ -36,7 +36,7 @@ bunx @playwright/cli@latest run-code "async page => {
|
|
|
36
36
|
|
|
37
37
|
```bash
|
|
38
38
|
# Grant multiple permissions
|
|
39
|
-
bunx @playwright/cli@
|
|
39
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
40
40
|
await page.context().grantPermissions([
|
|
41
41
|
'geolocation',
|
|
42
42
|
'notifications',
|
|
@@ -46,7 +46,7 @@ bunx @playwright/cli@latest run-code "async page => {
|
|
|
46
46
|
}"
|
|
47
47
|
|
|
48
48
|
# Grant permissions for specific origin
|
|
49
|
-
bunx @playwright/cli@
|
|
49
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
50
50
|
await page.context().grantPermissions(['clipboard-read'], {
|
|
51
51
|
origin: 'https://example.com'
|
|
52
52
|
});
|
|
@@ -57,22 +57,22 @@ bunx @playwright/cli@latest run-code "async page => {
|
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
59
|
# Emulate dark color scheme
|
|
60
|
-
bunx @playwright/cli@
|
|
60
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
61
61
|
await page.emulateMedia({ colorScheme: 'dark' });
|
|
62
62
|
}"
|
|
63
63
|
|
|
64
64
|
# Emulate light color scheme
|
|
65
|
-
bunx @playwright/cli@
|
|
65
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
66
66
|
await page.emulateMedia({ colorScheme: 'light' });
|
|
67
67
|
}"
|
|
68
68
|
|
|
69
69
|
# Emulate reduced motion
|
|
70
|
-
bunx @playwright/cli@
|
|
70
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
71
71
|
await page.emulateMedia({ reducedMotion: 'reduce' });
|
|
72
72
|
}"
|
|
73
73
|
|
|
74
74
|
# Emulate print media
|
|
75
|
-
bunx @playwright/cli@
|
|
75
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
76
76
|
await page.emulateMedia({ media: 'print' });
|
|
77
77
|
}"
|
|
78
78
|
```
|
|
@@ -81,22 +81,22 @@ bunx @playwright/cli@latest run-code "async page => {
|
|
|
81
81
|
|
|
82
82
|
```bash
|
|
83
83
|
# Wait for network idle
|
|
84
|
-
bunx @playwright/cli@
|
|
84
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
85
85
|
await page.waitForLoadState('networkidle');
|
|
86
86
|
}"
|
|
87
87
|
|
|
88
88
|
# Wait for specific element
|
|
89
|
-
bunx @playwright/cli@
|
|
89
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
90
90
|
await page.locator('.loading').waitFor({ state: 'hidden' });
|
|
91
91
|
}"
|
|
92
92
|
|
|
93
93
|
# Wait for function to return true
|
|
94
|
-
bunx @playwright/cli@
|
|
94
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
95
95
|
await page.waitForFunction(() => window.appReady === true);
|
|
96
96
|
}"
|
|
97
97
|
|
|
98
98
|
# Wait with timeout
|
|
99
|
-
bunx @playwright/cli@
|
|
99
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
100
100
|
await page.locator('.result').waitFor({ timeout: 10000 });
|
|
101
101
|
}"
|
|
102
102
|
```
|
|
@@ -105,13 +105,13 @@ bunx @playwright/cli@latest run-code "async page => {
|
|
|
105
105
|
|
|
106
106
|
```bash
|
|
107
107
|
# Work with iframe
|
|
108
|
-
bunx @playwright/cli@
|
|
108
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
109
109
|
const frame = page.locator('iframe#my-iframe').contentFrame();
|
|
110
110
|
await frame.locator('button').click();
|
|
111
111
|
}"
|
|
112
112
|
|
|
113
113
|
# Get all frames
|
|
114
|
-
bunx @playwright/cli@
|
|
114
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
115
115
|
const frames = page.frames();
|
|
116
116
|
return frames.map(f => f.url());
|
|
117
117
|
}"
|
|
@@ -121,7 +121,7 @@ bunx @playwright/cli@latest run-code "async page => {
|
|
|
121
121
|
|
|
122
122
|
```bash
|
|
123
123
|
# Handle file download
|
|
124
|
-
bunx @playwright/cli@
|
|
124
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
125
125
|
const downloadPromise = page.waitForEvent('download');
|
|
126
126
|
await page.getByRole('link', { name: 'Download' }).click();
|
|
127
127
|
const download = await downloadPromise;
|
|
@@ -134,13 +134,13 @@ bunx @playwright/cli@latest run-code "async page => {
|
|
|
134
134
|
|
|
135
135
|
```bash
|
|
136
136
|
# Read clipboard (requires permission)
|
|
137
|
-
bunx @playwright/cli@
|
|
137
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
138
138
|
await page.context().grantPermissions(['clipboard-read']);
|
|
139
139
|
return await page.evaluate(() => navigator.clipboard.readText());
|
|
140
140
|
}"
|
|
141
141
|
|
|
142
142
|
# Write to clipboard
|
|
143
|
-
bunx @playwright/cli@
|
|
143
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
144
144
|
await page.evaluate(text => navigator.clipboard.writeText(text), 'Hello clipboard!');
|
|
145
145
|
}"
|
|
146
146
|
```
|
|
@@ -149,22 +149,22 @@ bunx @playwright/cli@latest run-code "async page => {
|
|
|
149
149
|
|
|
150
150
|
```bash
|
|
151
151
|
# Get page title
|
|
152
|
-
bunx @playwright/cli@
|
|
152
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
153
153
|
return await page.title();
|
|
154
154
|
}"
|
|
155
155
|
|
|
156
156
|
# Get current URL
|
|
157
|
-
bunx @playwright/cli@
|
|
157
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
158
158
|
return page.url();
|
|
159
159
|
}"
|
|
160
160
|
|
|
161
161
|
# Get page content
|
|
162
|
-
bunx @playwright/cli@
|
|
162
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
163
163
|
return await page.content();
|
|
164
164
|
}"
|
|
165
165
|
|
|
166
166
|
# Get viewport size
|
|
167
|
-
bunx @playwright/cli@
|
|
167
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
168
168
|
return page.viewportSize();
|
|
169
169
|
}"
|
|
170
170
|
```
|
|
@@ -173,7 +173,7 @@ bunx @playwright/cli@latest run-code "async page => {
|
|
|
173
173
|
|
|
174
174
|
```bash
|
|
175
175
|
# Execute JavaScript and return result
|
|
176
|
-
bunx @playwright/cli@
|
|
176
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
177
177
|
return await page.evaluate(() => {
|
|
178
178
|
return {
|
|
179
179
|
userAgent: navigator.userAgent,
|
|
@@ -184,7 +184,7 @@ bunx @playwright/cli@latest run-code "async page => {
|
|
|
184
184
|
}"
|
|
185
185
|
|
|
186
186
|
# Pass arguments to evaluate
|
|
187
|
-
bunx @playwright/cli@
|
|
187
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
188
188
|
const multiplier = 5;
|
|
189
189
|
return await page.evaluate(m => document.querySelectorAll('li').length * m, multiplier);
|
|
190
190
|
}"
|
|
@@ -194,7 +194,7 @@ bunx @playwright/cli@latest run-code "async page => {
|
|
|
194
194
|
|
|
195
195
|
```bash
|
|
196
196
|
# Try-catch in run-code
|
|
197
|
-
bunx @playwright/cli@
|
|
197
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
198
198
|
try {
|
|
199
199
|
await page.getByRole('button', { name: 'Submit' }).click({ timeout: 1000 });
|
|
200
200
|
return 'clicked';
|
|
@@ -208,7 +208,7 @@ bunx @playwright/cli@latest run-code "async page => {
|
|
|
208
208
|
|
|
209
209
|
```bash
|
|
210
210
|
# Login and save state
|
|
211
|
-
bunx @playwright/cli@
|
|
211
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
212
212
|
await page.goto('https://example.com/login');
|
|
213
213
|
await page.getByRole('textbox', { name: 'Email' }).fill('user@example.com');
|
|
214
214
|
await page.getByRole('textbox', { name: 'Password' }).fill('secret');
|
|
@@ -219,7 +219,7 @@ bunx @playwright/cli@latest run-code "async page => {
|
|
|
219
219
|
}"
|
|
220
220
|
|
|
221
221
|
# Scrape data from multiple pages
|
|
222
|
-
bunx @playwright/cli@
|
|
222
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
223
223
|
const results = [];
|
|
224
224
|
for (let i = 1; i <= 3; i++) {
|
|
225
225
|
await page.goto(\`https://example.com/page/\${i}\`);
|
|
@@ -8,14 +8,14 @@ Use `-s` flag to isolate browser contexts:
|
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
# Browser 1: Authentication flow
|
|
11
|
-
bunx @playwright/cli@
|
|
11
|
+
bunx @playwright/cli@0.1.8 -s=auth open https://app.example.com/login
|
|
12
12
|
|
|
13
13
|
# Browser 2: Public browsing (separate cookies, storage)
|
|
14
|
-
bunx @playwright/cli@
|
|
14
|
+
bunx @playwright/cli@0.1.8 -s=public open https://example.com
|
|
15
15
|
|
|
16
16
|
# Commands are isolated by browser session
|
|
17
|
-
bunx @playwright/cli@
|
|
18
|
-
bunx @playwright/cli@
|
|
17
|
+
bunx @playwright/cli@0.1.8 -s=auth fill e1 "user@example.com"
|
|
18
|
+
bunx @playwright/cli@0.1.8 -s=public snapshot
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
## Browser Session Isolation Properties
|
|
@@ -33,21 +33,21 @@ Each browser session has independent:
|
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
35
|
# List all browser sessions
|
|
36
|
-
bunx @playwright/cli@
|
|
36
|
+
bunx @playwright/cli@0.1.8 list
|
|
37
37
|
|
|
38
38
|
# Stop a browser session (close the browser)
|
|
39
|
-
bunx @playwright/cli@
|
|
40
|
-
bunx @playwright/cli@
|
|
39
|
+
bunx @playwright/cli@0.1.8 close # stop the default browser
|
|
40
|
+
bunx @playwright/cli@0.1.8 -s=mysession close # stop a named browser
|
|
41
41
|
|
|
42
42
|
# Stop all browser sessions
|
|
43
|
-
bunx @playwright/cli@
|
|
43
|
+
bunx @playwright/cli@0.1.8 close-all
|
|
44
44
|
|
|
45
45
|
# Forcefully kill all daemon processes (for stale/zombie processes)
|
|
46
|
-
bunx @playwright/cli@
|
|
46
|
+
bunx @playwright/cli@0.1.8 kill-all
|
|
47
47
|
|
|
48
48
|
# Delete browser session user data (profile directory)
|
|
49
|
-
bunx @playwright/cli@
|
|
50
|
-
bunx @playwright/cli@
|
|
49
|
+
bunx @playwright/cli@0.1.8 delete-data # delete default browser data
|
|
50
|
+
bunx @playwright/cli@0.1.8 -s=mysession delete-data # delete named browser data
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
## Environment Variable
|
|
@@ -56,7 +56,7 @@ Set a default browser session name via environment variable:
|
|
|
56
56
|
|
|
57
57
|
```bash
|
|
58
58
|
export PLAYWRIGHT_CLI_SESSION="mysession"
|
|
59
|
-
bunx @playwright/cli@
|
|
59
|
+
bunx @playwright/cli@0.1.8 open example.com # Uses "mysession" automatically
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
## Common Patterns
|
|
@@ -68,30 +68,30 @@ bunx @playwright/cli@latest open example.com # Uses "mysession" automatically
|
|
|
68
68
|
# Scrape multiple sites concurrently
|
|
69
69
|
|
|
70
70
|
# Start all browsers
|
|
71
|
-
bunx @playwright/cli@
|
|
72
|
-
bunx @playwright/cli@
|
|
73
|
-
bunx @playwright/cli@
|
|
71
|
+
bunx @playwright/cli@0.1.8 -s=site1 open https://site1.com &
|
|
72
|
+
bunx @playwright/cli@0.1.8 -s=site2 open https://site2.com &
|
|
73
|
+
bunx @playwright/cli@0.1.8 -s=site3 open https://site3.com &
|
|
74
74
|
wait
|
|
75
75
|
|
|
76
76
|
# Take snapshots from each
|
|
77
|
-
bunx @playwright/cli@
|
|
78
|
-
bunx @playwright/cli@
|
|
79
|
-
bunx @playwright/cli@
|
|
77
|
+
bunx @playwright/cli@0.1.8 -s=site1 snapshot
|
|
78
|
+
bunx @playwright/cli@0.1.8 -s=site2 snapshot
|
|
79
|
+
bunx @playwright/cli@0.1.8 -s=site3 snapshot
|
|
80
80
|
|
|
81
81
|
# Cleanup
|
|
82
|
-
bunx @playwright/cli@
|
|
82
|
+
bunx @playwright/cli@0.1.8 close-all
|
|
83
83
|
```
|
|
84
84
|
|
|
85
85
|
### A/B Testing Sessions
|
|
86
86
|
|
|
87
87
|
```bash
|
|
88
88
|
# Test different user experiences
|
|
89
|
-
bunx @playwright/cli@
|
|
90
|
-
bunx @playwright/cli@
|
|
89
|
+
bunx @playwright/cli@0.1.8 -s=variant-a open "https://app.com?variant=a"
|
|
90
|
+
bunx @playwright/cli@0.1.8 -s=variant-b open "https://app.com?variant=b"
|
|
91
91
|
|
|
92
92
|
# Compare
|
|
93
|
-
bunx @playwright/cli@
|
|
94
|
-
bunx @playwright/cli@
|
|
93
|
+
bunx @playwright/cli@0.1.8 -s=variant-a screenshot
|
|
94
|
+
bunx @playwright/cli@0.1.8 -s=variant-b screenshot
|
|
95
95
|
```
|
|
96
96
|
|
|
97
97
|
### Persistent Profile
|
|
@@ -100,10 +100,50 @@ By default, browser profile is kept in memory only. Use `--persistent` flag on `
|
|
|
100
100
|
|
|
101
101
|
```bash
|
|
102
102
|
# Use persistent profile (auto-generated location)
|
|
103
|
-
bunx @playwright/cli@
|
|
103
|
+
bunx @playwright/cli@0.1.8 open https://example.com --persistent
|
|
104
104
|
|
|
105
105
|
# Use persistent profile with custom directory
|
|
106
|
-
bunx @playwright/cli@
|
|
106
|
+
bunx @playwright/cli@0.1.8 open https://example.com --profile=/path/to/profile
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Attaching to a Running Browser
|
|
110
|
+
|
|
111
|
+
Use `attach` to connect to a browser that is already running, instead of launching a new one.
|
|
112
|
+
|
|
113
|
+
### Attach by channel name
|
|
114
|
+
|
|
115
|
+
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".
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
# Attach to Chrome
|
|
119
|
+
bunx @playwright/cli@0.1.8 attach --cdp=chrome
|
|
120
|
+
|
|
121
|
+
# Attach to Chrome Canary
|
|
122
|
+
bunx @playwright/cli@0.1.8 attach --cdp=chrome-canary
|
|
123
|
+
|
|
124
|
+
# Attach to Microsoft Edge
|
|
125
|
+
bunx @playwright/cli@0.1.8 attach --cdp=msedge
|
|
126
|
+
|
|
127
|
+
# Attach to Edge Dev
|
|
128
|
+
bunx @playwright/cli@0.1.8 attach --cdp=msedge-dev
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Supported channels: `chrome`, `chrome-beta`, `chrome-dev`, `chrome-canary`, `msedge`, `msedge-beta`, `msedge-dev`, `msedge-canary`.
|
|
132
|
+
|
|
133
|
+
### Attach via CDP endpoint
|
|
134
|
+
|
|
135
|
+
Connect to a browser that exposes a Chrome DevTools Protocol endpoint:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
bunx @playwright/cli@0.1.8 attach --cdp=http://localhost:9222
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Attach via browser extension
|
|
142
|
+
|
|
143
|
+
Connect to a browser with the Playwright extension installed:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
bunx @playwright/cli@0.1.8 attach --extension
|
|
107
147
|
```
|
|
108
148
|
|
|
109
149
|
## Default Browser Session
|
|
@@ -112,9 +152,9 @@ When `-s` is omitted, commands use the default browser session:
|
|
|
112
152
|
|
|
113
153
|
```bash
|
|
114
154
|
# These use the same default browser session
|
|
115
|
-
bunx @playwright/cli@
|
|
116
|
-
bunx @playwright/cli@
|
|
117
|
-
bunx @playwright/cli@
|
|
155
|
+
bunx @playwright/cli@0.1.8 open https://example.com
|
|
156
|
+
bunx @playwright/cli@0.1.8 snapshot
|
|
157
|
+
bunx @playwright/cli@0.1.8 close # Stops default browser
|
|
118
158
|
```
|
|
119
159
|
|
|
120
160
|
## Browser Session Configuration
|
|
@@ -123,16 +163,16 @@ Configure a browser session with specific settings when opening:
|
|
|
123
163
|
|
|
124
164
|
```bash
|
|
125
165
|
# Open with config file
|
|
126
|
-
bunx @playwright/cli@
|
|
166
|
+
bunx @playwright/cli@0.1.8 open https://example.com --config=.playwright/my-cli.json
|
|
127
167
|
|
|
128
168
|
# Open with specific browser
|
|
129
|
-
bunx @playwright/cli@
|
|
169
|
+
bunx @playwright/cli@0.1.8 open https://example.com --browser=firefox
|
|
130
170
|
|
|
131
171
|
# Open in headed mode
|
|
132
|
-
bunx @playwright/cli@
|
|
172
|
+
bunx @playwright/cli@0.1.8 open https://example.com --headed
|
|
133
173
|
|
|
134
174
|
# Open with persistent profile
|
|
135
|
-
bunx @playwright/cli@
|
|
175
|
+
bunx @playwright/cli@0.1.8 open https://example.com --persistent
|
|
136
176
|
```
|
|
137
177
|
|
|
138
178
|
## Best Practices
|
|
@@ -141,30 +181,30 @@ bunx @playwright/cli@latest open https://example.com --persistent
|
|
|
141
181
|
|
|
142
182
|
```bash
|
|
143
183
|
# GOOD: Clear purpose
|
|
144
|
-
bunx @playwright/cli@
|
|
145
|
-
bunx @playwright/cli@
|
|
184
|
+
bunx @playwright/cli@0.1.8 -s=github-auth open https://github.com
|
|
185
|
+
bunx @playwright/cli@0.1.8 -s=docs-scrape open https://docs.example.com
|
|
146
186
|
|
|
147
187
|
# AVOID: Generic names
|
|
148
|
-
bunx @playwright/cli@
|
|
188
|
+
bunx @playwright/cli@0.1.8 -s=s1 open https://github.com
|
|
149
189
|
```
|
|
150
190
|
|
|
151
191
|
### 2. Always Clean Up
|
|
152
192
|
|
|
153
193
|
```bash
|
|
154
194
|
# Stop browsers when done
|
|
155
|
-
bunx @playwright/cli@
|
|
156
|
-
bunx @playwright/cli@
|
|
195
|
+
bunx @playwright/cli@0.1.8 -s=auth close
|
|
196
|
+
bunx @playwright/cli@0.1.8 -s=scrape close
|
|
157
197
|
|
|
158
198
|
# Or stop all at once
|
|
159
|
-
bunx @playwright/cli@
|
|
199
|
+
bunx @playwright/cli@0.1.8 close-all
|
|
160
200
|
|
|
161
201
|
# If browsers become unresponsive or zombie processes remain
|
|
162
|
-
bunx @playwright/cli@
|
|
202
|
+
bunx @playwright/cli@0.1.8 kill-all
|
|
163
203
|
```
|
|
164
204
|
|
|
165
205
|
### 3. Delete Stale Browser Data
|
|
166
206
|
|
|
167
207
|
```bash
|
|
168
208
|
# Remove old browser data to free disk space
|
|
169
|
-
bunx @playwright/cli@
|
|
209
|
+
bunx @playwright/cli@0.1.8 -s=oldsession delete-data
|
|
170
210
|
```
|
|
@@ -10,20 +10,20 @@ Save and restore complete browser state including cookies and storage.
|
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
12
|
# Save to auto-generated filename (storage-state-{timestamp}.json)
|
|
13
|
-
bunx @playwright/cli@
|
|
13
|
+
bunx @playwright/cli@0.1.8 state-save
|
|
14
14
|
|
|
15
15
|
# Save to specific filename
|
|
16
|
-
bunx @playwright/cli@
|
|
16
|
+
bunx @playwright/cli@0.1.8 state-save my-auth-state.json
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
### Restore Storage State
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
22
|
# Load storage state from file
|
|
23
|
-
bunx @playwright/cli@
|
|
23
|
+
bunx @playwright/cli@0.1.8 state-load my-auth-state.json
|
|
24
24
|
|
|
25
25
|
# Reload page to apply cookies
|
|
26
|
-
bunx @playwright/cli@
|
|
26
|
+
bunx @playwright/cli@0.1.8 open https://example.com
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
### Storage State File Format
|
|
@@ -61,50 +61,50 @@ The saved file contains:
|
|
|
61
61
|
### List All Cookies
|
|
62
62
|
|
|
63
63
|
```bash
|
|
64
|
-
bunx @playwright/cli@
|
|
64
|
+
bunx @playwright/cli@0.1.8 cookie-list
|
|
65
65
|
```
|
|
66
66
|
|
|
67
67
|
### Filter Cookies by Domain
|
|
68
68
|
|
|
69
69
|
```bash
|
|
70
|
-
bunx @playwright/cli@
|
|
70
|
+
bunx @playwright/cli@0.1.8 cookie-list --domain=example.com
|
|
71
71
|
```
|
|
72
72
|
|
|
73
73
|
### Filter Cookies by Path
|
|
74
74
|
|
|
75
75
|
```bash
|
|
76
|
-
bunx @playwright/cli@
|
|
76
|
+
bunx @playwright/cli@0.1.8 cookie-list --path=/api
|
|
77
77
|
```
|
|
78
78
|
|
|
79
79
|
### Get Specific Cookie
|
|
80
80
|
|
|
81
81
|
```bash
|
|
82
|
-
bunx @playwright/cli@
|
|
82
|
+
bunx @playwright/cli@0.1.8 cookie-get session_id
|
|
83
83
|
```
|
|
84
84
|
|
|
85
85
|
### Set a Cookie
|
|
86
86
|
|
|
87
87
|
```bash
|
|
88
88
|
# Basic cookie
|
|
89
|
-
bunx @playwright/cli@
|
|
89
|
+
bunx @playwright/cli@0.1.8 cookie-set session abc123
|
|
90
90
|
|
|
91
91
|
# Cookie with options
|
|
92
|
-
bunx @playwright/cli@
|
|
92
|
+
bunx @playwright/cli@0.1.8 cookie-set session abc123 --domain=example.com --path=/ --httpOnly --secure --sameSite=Lax
|
|
93
93
|
|
|
94
94
|
# Cookie with expiration (Unix timestamp)
|
|
95
|
-
bunx @playwright/cli@
|
|
95
|
+
bunx @playwright/cli@0.1.8 cookie-set remember_me token123 --expires=1735689600
|
|
96
96
|
```
|
|
97
97
|
|
|
98
98
|
### Delete a Cookie
|
|
99
99
|
|
|
100
100
|
```bash
|
|
101
|
-
bunx @playwright/cli@
|
|
101
|
+
bunx @playwright/cli@0.1.8 cookie-delete session_id
|
|
102
102
|
```
|
|
103
103
|
|
|
104
104
|
### Clear All Cookies
|
|
105
105
|
|
|
106
106
|
```bash
|
|
107
|
-
bunx @playwright/cli@
|
|
107
|
+
bunx @playwright/cli@0.1.8 cookie-clear
|
|
108
108
|
```
|
|
109
109
|
|
|
110
110
|
### Advanced: Multiple Cookies or Custom Options
|
|
@@ -112,7 +112,7 @@ bunx @playwright/cli@latest cookie-clear
|
|
|
112
112
|
For complex scenarios like adding multiple cookies at once, use `run-code`:
|
|
113
113
|
|
|
114
114
|
```bash
|
|
115
|
-
bunx @playwright/cli@
|
|
115
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
116
116
|
await page.context().addCookies([
|
|
117
117
|
{ name: 'session_id', value: 'sess_abc123', domain: 'example.com', path: '/', httpOnly: true },
|
|
118
118
|
{ name: 'preferences', value: JSON.stringify({ theme: 'dark' }), domain: 'example.com', path: '/' }
|
|
@@ -125,37 +125,37 @@ bunx @playwright/cli@latest run-code "async page => {
|
|
|
125
125
|
### List All localStorage Items
|
|
126
126
|
|
|
127
127
|
```bash
|
|
128
|
-
bunx @playwright/cli@
|
|
128
|
+
bunx @playwright/cli@0.1.8 localstorage-list
|
|
129
129
|
```
|
|
130
130
|
|
|
131
131
|
### Get Single Value
|
|
132
132
|
|
|
133
133
|
```bash
|
|
134
|
-
bunx @playwright/cli@
|
|
134
|
+
bunx @playwright/cli@0.1.8 localstorage-get token
|
|
135
135
|
```
|
|
136
136
|
|
|
137
137
|
### Set Value
|
|
138
138
|
|
|
139
139
|
```bash
|
|
140
|
-
bunx @playwright/cli@
|
|
140
|
+
bunx @playwright/cli@0.1.8 localstorage-set theme dark
|
|
141
141
|
```
|
|
142
142
|
|
|
143
143
|
### Set JSON Value
|
|
144
144
|
|
|
145
145
|
```bash
|
|
146
|
-
bunx @playwright/cli@
|
|
146
|
+
bunx @playwright/cli@0.1.8 localstorage-set user_settings '{"theme":"dark","language":"en"}'
|
|
147
147
|
```
|
|
148
148
|
|
|
149
149
|
### Delete Single Item
|
|
150
150
|
|
|
151
151
|
```bash
|
|
152
|
-
bunx @playwright/cli@
|
|
152
|
+
bunx @playwright/cli@0.1.8 localstorage-delete token
|
|
153
153
|
```
|
|
154
154
|
|
|
155
155
|
### Clear All localStorage
|
|
156
156
|
|
|
157
157
|
```bash
|
|
158
|
-
bunx @playwright/cli@
|
|
158
|
+
bunx @playwright/cli@0.1.8 localstorage-clear
|
|
159
159
|
```
|
|
160
160
|
|
|
161
161
|
### Advanced: Multiple Operations
|
|
@@ -163,7 +163,7 @@ bunx @playwright/cli@latest localstorage-clear
|
|
|
163
163
|
For complex scenarios like setting multiple values at once, use `run-code`:
|
|
164
164
|
|
|
165
165
|
```bash
|
|
166
|
-
bunx @playwright/cli@
|
|
166
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
167
167
|
await page.evaluate(() => {
|
|
168
168
|
localStorage.setItem('token', 'jwt_abc123');
|
|
169
169
|
localStorage.setItem('user_id', '12345');
|
|
@@ -177,31 +177,31 @@ bunx @playwright/cli@latest run-code "async page => {
|
|
|
177
177
|
### List All sessionStorage Items
|
|
178
178
|
|
|
179
179
|
```bash
|
|
180
|
-
bunx @playwright/cli@
|
|
180
|
+
bunx @playwright/cli@0.1.8 sessionstorage-list
|
|
181
181
|
```
|
|
182
182
|
|
|
183
183
|
### Get Single Value
|
|
184
184
|
|
|
185
185
|
```bash
|
|
186
|
-
bunx @playwright/cli@
|
|
186
|
+
bunx @playwright/cli@0.1.8 sessionstorage-get form_data
|
|
187
187
|
```
|
|
188
188
|
|
|
189
189
|
### Set Value
|
|
190
190
|
|
|
191
191
|
```bash
|
|
192
|
-
bunx @playwright/cli@
|
|
192
|
+
bunx @playwright/cli@0.1.8 sessionstorage-set step 3
|
|
193
193
|
```
|
|
194
194
|
|
|
195
195
|
### Delete Single Item
|
|
196
196
|
|
|
197
197
|
```bash
|
|
198
|
-
bunx @playwright/cli@
|
|
198
|
+
bunx @playwright/cli@0.1.8 sessionstorage-delete step
|
|
199
199
|
```
|
|
200
200
|
|
|
201
201
|
### Clear sessionStorage
|
|
202
202
|
|
|
203
203
|
```bash
|
|
204
|
-
bunx @playwright/cli@
|
|
204
|
+
bunx @playwright/cli@0.1.8 sessionstorage-clear
|
|
205
205
|
```
|
|
206
206
|
|
|
207
207
|
## IndexedDB
|
|
@@ -209,7 +209,7 @@ bunx @playwright/cli@latest sessionstorage-clear
|
|
|
209
209
|
### List Databases
|
|
210
210
|
|
|
211
211
|
```bash
|
|
212
|
-
bunx @playwright/cli@
|
|
212
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
213
213
|
return await page.evaluate(async () => {
|
|
214
214
|
const databases = await indexedDB.databases();
|
|
215
215
|
return databases;
|
|
@@ -220,7 +220,7 @@ bunx @playwright/cli@latest run-code "async page => {
|
|
|
220
220
|
### Delete Database
|
|
221
221
|
|
|
222
222
|
```bash
|
|
223
|
-
bunx @playwright/cli@
|
|
223
|
+
bunx @playwright/cli@0.1.8 run-code "async page => {
|
|
224
224
|
await page.evaluate(() => {
|
|
225
225
|
indexedDB.deleteDatabase('myDatabase');
|
|
226
226
|
});
|
|
@@ -233,18 +233,18 @@ bunx @playwright/cli@latest run-code "async page => {
|
|
|
233
233
|
|
|
234
234
|
```bash
|
|
235
235
|
# Step 1: Login and save state
|
|
236
|
-
bunx @playwright/cli@
|
|
237
|
-
bunx @playwright/cli@
|
|
238
|
-
bunx @playwright/cli@
|
|
239
|
-
bunx @playwright/cli@
|
|
240
|
-
bunx @playwright/cli@
|
|
236
|
+
bunx @playwright/cli@0.1.8 open https://app.example.com/login
|
|
237
|
+
bunx @playwright/cli@0.1.8 snapshot
|
|
238
|
+
bunx @playwright/cli@0.1.8 fill e1 "user@example.com"
|
|
239
|
+
bunx @playwright/cli@0.1.8 fill e2 "password123"
|
|
240
|
+
bunx @playwright/cli@0.1.8 click e3
|
|
241
241
|
|
|
242
242
|
# Save the authenticated state
|
|
243
|
-
bunx @playwright/cli@
|
|
243
|
+
bunx @playwright/cli@0.1.8 state-save auth.json
|
|
244
244
|
|
|
245
245
|
# Step 2: Later, restore state and skip login
|
|
246
|
-
bunx @playwright/cli@
|
|
247
|
-
bunx @playwright/cli@
|
|
246
|
+
bunx @playwright/cli@0.1.8 state-load auth.json
|
|
247
|
+
bunx @playwright/cli@0.1.8 open https://app.example.com/dashboard
|
|
248
248
|
# Already logged in!
|
|
249
249
|
```
|
|
250
250
|
|
|
@@ -252,17 +252,17 @@ bunx @playwright/cli@latest open https://app.example.com/dashboard
|
|
|
252
252
|
|
|
253
253
|
```bash
|
|
254
254
|
# Set up authentication state
|
|
255
|
-
bunx @playwright/cli@
|
|
256
|
-
bunx @playwright/cli@
|
|
255
|
+
bunx @playwright/cli@0.1.8 open https://example.com
|
|
256
|
+
bunx @playwright/cli@0.1.8 eval "() => { document.cookie = 'session=abc123'; localStorage.setItem('user', 'john'); }"
|
|
257
257
|
|
|
258
258
|
# Save state to file
|
|
259
|
-
bunx @playwright/cli@
|
|
259
|
+
bunx @playwright/cli@0.1.8 state-save my-session.json
|
|
260
260
|
|
|
261
261
|
# ... later, in a new session ...
|
|
262
262
|
|
|
263
263
|
# Restore state
|
|
264
|
-
bunx @playwright/cli@
|
|
265
|
-
bunx @playwright/cli@
|
|
264
|
+
bunx @playwright/cli@0.1.8 state-load my-session.json
|
|
265
|
+
bunx @playwright/cli@0.1.8 open https://example.com
|
|
266
266
|
# Cookies and localStorage are restored!
|
|
267
267
|
```
|
|
268
268
|
|