@assertrx/dino 1.0.0
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/README.md +293 -0
- package/extensions/dino.ts +70 -0
- package/extensions/mabl-mcp.ts +306 -0
- package/extensions/playwright-mcp.ts +142 -0
- package/package.json +47 -0
- package/prompts/create-pr.md +110 -0
- package/prompts/generate-bdd-from-url.md +65 -0
- package/prompts/generate-pom-from-url-cli.md +48 -0
- package/prompts/generate-pom-from-url.md +45 -0
- package/prompts/generate-spec-from-feature.md +64 -0
- package/prompts/heal-playwright-failures.md +106 -0
- package/prompts/setup-playwright.md +81 -0
- package/scripts/start-dino.cmd +8 -0
- package/scripts/start-dino.mjs +226 -0
- package/scripts/start-dino.ps1 +9 -0
- package/scripts/start-dino.sh +10 -0
- package/skills/acli/SKILL.md +292 -0
- package/skills/bdd-gherkin/SKILL.md +552 -0
- package/skills/build-review-interface/SKILL.md +96 -0
- package/skills/error-analysis/SKILL.md +164 -0
- package/skills/eval-audit/SKILL.md +183 -0
- package/skills/evaluate-rag/SKILL.md +177 -0
- package/skills/generate-synthetic-data/SKILL.md +131 -0
- package/skills/mabl-mcp/SKILL.md +79 -0
- package/skills/playwright-cli/SKILL.md +246 -0
- package/skills/playwright-cli/advanced-workflows.md +679 -0
- package/skills/playwright-cli/core-commands.md +375 -0
- package/skills/playwright-cli/device-emulation.md +475 -0
- package/skills/playwright-cli/request-mocking.md +373 -0
- package/skills/playwright-cli/running-custom-code.md +553 -0
- package/skills/playwright-cli/screenshots-and-media.md +457 -0
- package/skills/playwright-cli/session-management.md +425 -0
- package/skills/playwright-cli/storage-and-auth.md +487 -0
- package/skills/playwright-cli/test-generation.md +336 -0
- package/skills/playwright-cli/tracing-and-debugging.md +501 -0
- package/skills/playwright-core/SKILL.md +101 -0
- package/skills/playwright-core/accessibility.md +1517 -0
- package/skills/playwright-core/angular.md +1086 -0
- package/skills/playwright-core/api-testing.md +1623 -0
- package/skills/playwright-core/assertions-and-waiting.md +703 -0
- package/skills/playwright-core/auth-flows.md +1081 -0
- package/skills/playwright-core/authentication.md +1409 -0
- package/skills/playwright-core/browser-apis.md +673 -0
- package/skills/playwright-core/browser-extensions.md +319 -0
- package/skills/playwright-core/canvas-and-webgl.md +494 -0
- package/skills/playwright-core/clock-and-time-mocking.md +427 -0
- package/skills/playwright-core/common-pitfalls.md +1318 -0
- package/skills/playwright-core/component-testing.md +1179 -0
- package/skills/playwright-core/configuration.md +731 -0
- package/skills/playwright-core/crud-testing.md +945 -0
- package/skills/playwright-core/debugging.md +827 -0
- package/skills/playwright-core/drag-and-drop.md +992 -0
- package/skills/playwright-core/electron-testing.md +622 -0
- package/skills/playwright-core/error-and-edge-cases.md +1181 -0
- package/skills/playwright-core/error-index.md +1903 -0
- package/skills/playwright-core/file-operations.md +749 -0
- package/skills/playwright-core/file-upload-download.md +1012 -0
- package/skills/playwright-core/fixtures-and-hooks.md +1072 -0
- package/skills/playwright-core/flaky-tests.md +883 -0
- package/skills/playwright-core/forms-and-validation.md +1056 -0
- package/skills/playwright-core/i18n-and-localization.md +622 -0
- package/skills/playwright-core/iframes-and-shadow-dom.md +488 -0
- package/skills/playwright-core/locator-strategy.md +588 -0
- package/skills/playwright-core/locators.md +743 -0
- package/skills/playwright-core/mobile-and-responsive.md +1669 -0
- package/skills/playwright-core/multi-context-and-popups.md +581 -0
- package/skills/playwright-core/multi-user-and-collaboration.md +477 -0
- package/skills/playwright-core/network-mocking.md +1395 -0
- package/skills/playwright-core/nextjs.md +1013 -0
- package/skills/playwright-core/performance-testing.md +608 -0
- package/skills/playwright-core/react.md +1082 -0
- package/skills/playwright-core/search-and-filter.md +1366 -0
- package/skills/playwright-core/security-testing.md +624 -0
- package/skills/playwright-core/service-workers-and-pwa.md +524 -0
- package/skills/playwright-core/test-architecture.md +569 -0
- package/skills/playwright-core/test-data-management.md +1209 -0
- package/skills/playwright-core/test-organization.md +947 -0
- package/skills/playwright-core/third-party-integrations.md +754 -0
- package/skills/playwright-core/trace-analysis.md +161 -0
- package/skills/playwright-core/visual-regression.md +1027 -0
- package/skills/playwright-core/vue.md +1162 -0
- package/skills/playwright-core/websockets-and-realtime.md +623 -0
- package/skills/playwright-core/when-to-mock.md +827 -0
- package/skills/playwright-pom/SKILL.md +94 -0
- package/skills/playwright-pom/page-object-model.md +921 -0
- package/skills/playwright-pom/pom-vs-fixtures-vs-helpers.md +937 -0
- package/skills/validate-evaluator/SKILL.md +215 -0
- package/skills/write-judge-prompt/SKILL.md +144 -0
- package/themes/dino.json +66 -0
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
# Session Management
|
|
2
|
+
|
|
3
|
+
> **When to use**: Running multiple isolated browser sessions concurrently, managing persistent profiles, comparing different browser states side by side, parallel scraping, or A/B testing flows.
|
|
4
|
+
> **Prerequisites**: [core-commands.md](core-commands.md) for basic CLI usage
|
|
5
|
+
|
|
6
|
+
## Quick Reference
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
# Named sessions: each has independent cookies, storage, tabs
|
|
10
|
+
playwright-cli -s=auth open https://app.example.com/login
|
|
11
|
+
playwright-cli -s=public open https://example.com
|
|
12
|
+
|
|
13
|
+
# Interact within a session
|
|
14
|
+
playwright-cli -s=auth fill e1 "user@example.com"
|
|
15
|
+
playwright-cli -s=public snapshot
|
|
16
|
+
|
|
17
|
+
# List all active sessions
|
|
18
|
+
playwright-cli list
|
|
19
|
+
|
|
20
|
+
# Attach to a browser bound from Playwright code (Playwright 1.59+)
|
|
21
|
+
playwright-cli attach checkout-debug
|
|
22
|
+
playwright-cli -s=checkout-debug snapshot
|
|
23
|
+
|
|
24
|
+
# Open the dashboard for bound browsers
|
|
25
|
+
playwright-cli show
|
|
26
|
+
|
|
27
|
+
# Clean up
|
|
28
|
+
playwright-cli -s=auth close
|
|
29
|
+
playwright-cli close-all # Close everything
|
|
30
|
+
playwright-cli kill-all # Force kill zombie processes
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Named Sessions
|
|
34
|
+
|
|
35
|
+
Use the `-s=<name>` flag to create isolated browser instances. Each named session has its own:
|
|
36
|
+
|
|
37
|
+
- Cookies
|
|
38
|
+
- localStorage / sessionStorage
|
|
39
|
+
- IndexedDB
|
|
40
|
+
- Cache
|
|
41
|
+
- Browsing history
|
|
42
|
+
- Open tabs
|
|
43
|
+
|
|
44
|
+
### Creating Sessions
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# Create a session for authentication testing
|
|
48
|
+
playwright-cli -s=admin open https://app.example.com/login
|
|
49
|
+
|
|
50
|
+
# Create a separate session for a different user
|
|
51
|
+
playwright-cli -s=viewer open https://app.example.com/login
|
|
52
|
+
|
|
53
|
+
# All commands in a session are isolated
|
|
54
|
+
playwright-cli -s=admin fill e1 "admin@company.com"
|
|
55
|
+
playwright-cli -s=admin fill e2 "admin-password"
|
|
56
|
+
playwright-cli -s=admin click e3
|
|
57
|
+
|
|
58
|
+
playwright-cli -s=viewer fill e1 "viewer@company.com"
|
|
59
|
+
playwright-cli -s=viewer fill e2 "viewer-password"
|
|
60
|
+
playwright-cli -s=viewer click e3
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Default Session
|
|
64
|
+
|
|
65
|
+
When `-s` is omitted, all commands share a single default session:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# These all use the same default session
|
|
69
|
+
playwright-cli open https://example.com
|
|
70
|
+
playwright-cli snapshot
|
|
71
|
+
playwright-cli click e1
|
|
72
|
+
playwright-cli close
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Session Isolation
|
|
76
|
+
|
|
77
|
+
Sessions are fully independent — actions in one session never affect another:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# Session A logs in as admin
|
|
81
|
+
playwright-cli -s=admin open https://app.example.com
|
|
82
|
+
playwright-cli -s=admin fill e1 "admin@example.com"
|
|
83
|
+
playwright-cli -s=admin fill e2 "admin-pass"
|
|
84
|
+
playwright-cli -s=admin click e3
|
|
85
|
+
|
|
86
|
+
# Session B visits the same site — NOT logged in
|
|
87
|
+
playwright-cli -s=guest open https://app.example.com
|
|
88
|
+
playwright-cli -s=guest snapshot
|
|
89
|
+
# Shows the login page, not the admin dashboard
|
|
90
|
+
|
|
91
|
+
# Session C can use a completely different browser
|
|
92
|
+
playwright-cli -s=firefox-test open https://app.example.com --browser=firefox
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Session Commands
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# List all active sessions with their status
|
|
99
|
+
playwright-cli list
|
|
100
|
+
|
|
101
|
+
# Close a specific named session
|
|
102
|
+
playwright-cli -s=mysession close
|
|
103
|
+
|
|
104
|
+
# Close the default session
|
|
105
|
+
playwright-cli close
|
|
106
|
+
|
|
107
|
+
# Close ALL sessions at once
|
|
108
|
+
playwright-cli close-all
|
|
109
|
+
|
|
110
|
+
# Force kill all browser daemon processes (for stuck/zombie browsers)
|
|
111
|
+
playwright-cli kill-all
|
|
112
|
+
|
|
113
|
+
# Delete persistent profile data for a session
|
|
114
|
+
playwright-cli -s=mysession delete-data
|
|
115
|
+
|
|
116
|
+
# Delete default session data
|
|
117
|
+
playwright-cli delete-data
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Bound Browser Sessions (Playwright 1.59+)
|
|
121
|
+
|
|
122
|
+
Playwright 1.59 introduced `browser.bind()`, which lets a browser launched from Playwright code be shared with `playwright-cli`, MCP servers, and other Playwright clients.
|
|
123
|
+
|
|
124
|
+
**Bind a browser from Playwright code**
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
import { chromium } from 'playwright';
|
|
128
|
+
|
|
129
|
+
async function main() {
|
|
130
|
+
const browser = await chromium.launch({ headless: false });
|
|
131
|
+
const { endpoint } = await browser.bind('checkout-debug', {
|
|
132
|
+
workspaceDir: process.cwd(),
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
console.log(`Bound browser endpoint: ${endpoint}`);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
main();
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**Attach from `playwright-cli`**
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
playwright-cli attach checkout-debug
|
|
145
|
+
playwright-cli -s=checkout-debug snapshot
|
|
146
|
+
playwright-cli -s=checkout-debug click e4
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Dashboard Visibility
|
|
150
|
+
|
|
151
|
+
`playwright-cli show` opens the dashboard for bound browsers so you can see active sessions, inspect status, and jump into the ones that matter.
|
|
152
|
+
|
|
153
|
+
For Playwright Test workflows, set `PLAYWRIGHT_DASHBOARD=1` before running tests if you want test browsers to appear in the dashboard as well.
|
|
154
|
+
|
|
155
|
+
## Attaching to a Real Browser Without Overrides (`connectOverCDP({ noDefaults })`, Playwright 1.60+)
|
|
156
|
+
|
|
157
|
+
When you attach to an *already-running* browser over CDP — your everyday Chrome started with `--remote-debugging-port`, for example — Playwright normally applies its own defaults to the default context (download behavior, focus emulation, media emulation). That can disturb a browser you're actively using.
|
|
158
|
+
|
|
159
|
+
Playwright 1.60 adds the `noDefaults` option so you can attach without changing the browser's behavior.
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
import { chromium } from 'playwright';
|
|
163
|
+
|
|
164
|
+
async function main() {
|
|
165
|
+
// Attach to a daily-driver Chrome (launched with --remote-debugging-port=9222)
|
|
166
|
+
// without Playwright overriding download/focus/media behavior.
|
|
167
|
+
const browser = await chromium.connectOverCDP('http://localhost:9222', {
|
|
168
|
+
noDefaults: true,
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
const context = browser.contexts()[0];
|
|
172
|
+
const page = context.pages()[0] ?? (await context.newPage());
|
|
173
|
+
|
|
174
|
+
console.log(await page.title());
|
|
175
|
+
|
|
176
|
+
// Detach without closing the user's browser
|
|
177
|
+
await browser.close();
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
main();
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
**Use when**: Inspecting or driving a real, user-owned browser where Playwright's default overrides would be intrusive.
|
|
184
|
+
**Avoid when**: You launched the browser for testing — the defaults (deterministic downloads, focus/media emulation) are usually what you want, so omit `noDefaults`.
|
|
185
|
+
|
|
186
|
+
## Persistent Profiles
|
|
187
|
+
|
|
188
|
+
By default, sessions run **in-memory** — all cookies, storage, and browsing data are lost when the session closes. Use `--persistent` to save state to disk.
|
|
189
|
+
|
|
190
|
+
### Auto-Generated Profile
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
# Playwright-cli manages the profile directory automatically
|
|
194
|
+
playwright-cli -s=myapp open https://example.com --persistent
|
|
195
|
+
|
|
196
|
+
# Close and reopen — cookies and storage are preserved
|
|
197
|
+
playwright-cli -s=myapp close
|
|
198
|
+
playwright-cli -s=myapp open https://example.com --persistent
|
|
199
|
+
# Still logged in!
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Custom Profile Directory
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
# Specify exactly where to store profile data
|
|
206
|
+
playwright-cli -s=myapp open https://example.com --profile=/tmp/my-browser-profile
|
|
207
|
+
|
|
208
|
+
# Useful for sharing profiles between sessions
|
|
209
|
+
playwright-cli -s=session-a open https://example.com --profile=/shared/profile
|
|
210
|
+
playwright-cli -s=session-a close
|
|
211
|
+
playwright-cli -s=session-b open https://example.com --profile=/shared/profile
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Cleaning Up Persistent Data
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
# Remove stored profile data (must close the session first)
|
|
218
|
+
playwright-cli -s=myapp close
|
|
219
|
+
playwright-cli -s=myapp delete-data
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Session Configuration
|
|
223
|
+
|
|
224
|
+
Configure browser engine and options per session:
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
# Different browsers for different sessions
|
|
228
|
+
playwright-cli -s=chrome-test open https://example.com --browser=chrome
|
|
229
|
+
playwright-cli -s=firefox-test open https://example.com --browser=firefox
|
|
230
|
+
playwright-cli -s=webkit-test open https://example.com --browser=webkit
|
|
231
|
+
playwright-cli -s=edge-test open https://example.com --browser=msedge
|
|
232
|
+
|
|
233
|
+
# With config file
|
|
234
|
+
playwright-cli -s=configured open https://example.com --config=my-config.json
|
|
235
|
+
|
|
236
|
+
# Headed mode (visible browser window)
|
|
237
|
+
playwright-cli -s=visible open https://example.com --headed
|
|
238
|
+
|
|
239
|
+
# Connect to existing browser via extension
|
|
240
|
+
playwright-cli -s=extension open --extension
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## Environment Variable
|
|
244
|
+
|
|
245
|
+
Set a default session name so all commands use it without the `-s` flag:
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
export PLAYWRIGHT_CLI_SESSION="mysession"
|
|
249
|
+
|
|
250
|
+
# These now use "mysession" automatically
|
|
251
|
+
playwright-cli open https://example.com
|
|
252
|
+
playwright-cli snapshot
|
|
253
|
+
playwright-cli close
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Common Patterns
|
|
257
|
+
|
|
258
|
+
### Multi-User Role Testing
|
|
259
|
+
|
|
260
|
+
Test the same application as different user roles simultaneously:
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
# Admin session
|
|
264
|
+
playwright-cli -s=admin open https://app.example.com/login
|
|
265
|
+
playwright-cli -s=admin snapshot
|
|
266
|
+
playwright-cli -s=admin fill e1 "admin@company.com"
|
|
267
|
+
playwright-cli -s=admin fill e2 "admin-pass"
|
|
268
|
+
playwright-cli -s=admin click e3
|
|
269
|
+
|
|
270
|
+
# Regular user session
|
|
271
|
+
playwright-cli -s=user open https://app.example.com/login
|
|
272
|
+
playwright-cli -s=user fill e1 "user@company.com"
|
|
273
|
+
playwright-cli -s=user fill e2 "user-pass"
|
|
274
|
+
playwright-cli -s=user click e3
|
|
275
|
+
|
|
276
|
+
# Compare what each role sees
|
|
277
|
+
playwright-cli -s=admin snapshot # Should show admin panel
|
|
278
|
+
playwright-cli -s=user snapshot # Should NOT show admin panel
|
|
279
|
+
|
|
280
|
+
playwright-cli -s=admin screenshot --filename=admin-view.png
|
|
281
|
+
playwright-cli -s=user screenshot --filename=user-view.png
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### Concurrent Scraping
|
|
285
|
+
|
|
286
|
+
Scrape multiple sites in parallel for speed:
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
#!/bin/bash
|
|
290
|
+
|
|
291
|
+
# Launch all browsers concurrently
|
|
292
|
+
playwright-cli -s=site1 open https://site1.example.com &
|
|
293
|
+
playwright-cli -s=site2 open https://site2.example.com &
|
|
294
|
+
playwright-cli -s=site3 open https://site3.example.com &
|
|
295
|
+
wait
|
|
296
|
+
|
|
297
|
+
# Collect data from each
|
|
298
|
+
playwright-cli -s=site1 snapshot --filename=site1.yaml
|
|
299
|
+
playwright-cli -s=site2 snapshot --filename=site2.yaml
|
|
300
|
+
playwright-cli -s=site3 snapshot --filename=site3.yaml
|
|
301
|
+
|
|
302
|
+
# Take screenshots
|
|
303
|
+
playwright-cli -s=site1 screenshot --filename=site1.png
|
|
304
|
+
playwright-cli -s=site2 screenshot --filename=site2.png
|
|
305
|
+
playwright-cli -s=site3 screenshot --filename=site3.png
|
|
306
|
+
|
|
307
|
+
# Clean up
|
|
308
|
+
playwright-cli close-all
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### A/B Testing Comparison
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
# Variant A
|
|
315
|
+
playwright-cli -s=variant-a open "https://app.example.com?variant=a"
|
|
316
|
+
playwright-cli -s=variant-a screenshot --filename=variant-a.png
|
|
317
|
+
|
|
318
|
+
# Variant B
|
|
319
|
+
playwright-cli -s=variant-b open "https://app.example.com?variant=b"
|
|
320
|
+
playwright-cli -s=variant-b screenshot --filename=variant-b.png
|
|
321
|
+
|
|
322
|
+
# Compare side by side
|
|
323
|
+
playwright-cli close-all
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
### Cross-Browser Testing
|
|
327
|
+
|
|
328
|
+
Run the same flow in multiple browsers to verify compatibility:
|
|
329
|
+
|
|
330
|
+
```bash
|
|
331
|
+
#!/bin/bash
|
|
332
|
+
|
|
333
|
+
for browser in chrome firefox webkit; do
|
|
334
|
+
playwright-cli -s=$browser open https://example.com --browser=$browser
|
|
335
|
+
playwright-cli -s=$browser snapshot
|
|
336
|
+
playwright-cli -s=$browser screenshot --filename="$browser-home.png"
|
|
337
|
+
|
|
338
|
+
playwright-cli -s=$browser goto https://example.com/features
|
|
339
|
+
playwright-cli -s=$browser screenshot --filename="$browser-features.png"
|
|
340
|
+
done
|
|
341
|
+
|
|
342
|
+
playwright-cli close-all
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
### Authenticated State Sharing Across Sessions
|
|
346
|
+
|
|
347
|
+
```bash
|
|
348
|
+
# Log in once and save state
|
|
349
|
+
playwright-cli -s=login open https://app.example.com/login
|
|
350
|
+
playwright-cli -s=login fill e1 "user@example.com"
|
|
351
|
+
playwright-cli -s=login fill e2 "password123"
|
|
352
|
+
playwright-cli -s=login click e3
|
|
353
|
+
playwright-cli -s=login state-save auth.json
|
|
354
|
+
playwright-cli -s=login close
|
|
355
|
+
|
|
356
|
+
# Reuse auth state in multiple sessions
|
|
357
|
+
playwright-cli -s=session-a open https://app.example.com
|
|
358
|
+
playwright-cli -s=session-a state-load auth.json
|
|
359
|
+
playwright-cli -s=session-a goto https://app.example.com/dashboard
|
|
360
|
+
|
|
361
|
+
playwright-cli -s=session-b open https://app.example.com
|
|
362
|
+
playwright-cli -s=session-b state-load auth.json
|
|
363
|
+
playwright-cli -s=session-b goto https://app.example.com/settings
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
## Best Practices
|
|
367
|
+
|
|
368
|
+
### 1. Name Sessions Semantically
|
|
369
|
+
|
|
370
|
+
```bash
|
|
371
|
+
# Good: Clear purpose
|
|
372
|
+
playwright-cli -s=github-auth open https://github.com
|
|
373
|
+
playwright-cli -s=docs-scrape open https://docs.example.com
|
|
374
|
+
playwright-cli -s=checkout-flow open https://shop.example.com
|
|
375
|
+
|
|
376
|
+
# Avoid: Generic names
|
|
377
|
+
playwright-cli -s=s1 open https://github.com
|
|
378
|
+
playwright-cli -s=test open https://docs.example.com
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### 2. Always Clean Up
|
|
382
|
+
|
|
383
|
+
```bash
|
|
384
|
+
# Close individual sessions when done
|
|
385
|
+
playwright-cli -s=auth close
|
|
386
|
+
playwright-cli -s=scrape close
|
|
387
|
+
|
|
388
|
+
# Or close all at once
|
|
389
|
+
playwright-cli close-all
|
|
390
|
+
|
|
391
|
+
# If browsers become unresponsive
|
|
392
|
+
playwright-cli kill-all
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
### 3. Delete Stale Persistent Data
|
|
396
|
+
|
|
397
|
+
```bash
|
|
398
|
+
# Remove old persistent profiles to free disk space
|
|
399
|
+
playwright-cli -s=old-session delete-data
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
### 4. Use Default Session for Single-Task Work
|
|
403
|
+
|
|
404
|
+
Don't create named sessions when you only need one browser:
|
|
405
|
+
|
|
406
|
+
```bash
|
|
407
|
+
# Simple single-session workflow — no -s flag needed
|
|
408
|
+
playwright-cli open https://example.com
|
|
409
|
+
playwright-cli snapshot
|
|
410
|
+
playwright-cli click e1
|
|
411
|
+
playwright-cli close
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
### 5. Combine with State Management
|
|
415
|
+
|
|
416
|
+
For long-running tasks, save state periodically:
|
|
417
|
+
|
|
418
|
+
```bash
|
|
419
|
+
playwright-cli -s=long-task open https://app.example.com --persistent
|
|
420
|
+
# ... many interactions ...
|
|
421
|
+
playwright-cli -s=long-task state-save checkpoint.json
|
|
422
|
+
# ... more interactions ...
|
|
423
|
+
# If something goes wrong, restore:
|
|
424
|
+
playwright-cli -s=long-task state-load checkpoint.json
|
|
425
|
+
```
|