You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can also take a snapshot on demand using `playwright-cli snapshot` command.
275
+
You can also take a snapshot on demand using `playwright-cli snapshot` command. All the options below can be combined as needed.
271
276
272
-
If `--filename` is not provided, a new snapshot file is created with a timestamp. Default to automatic file naming, use `--filename=` when artifact is a part of the workflow result.
277
+
```bash
278
+
# default - save to a file with timestamp-based name
279
+
playwright-cli snapshot
280
+
281
+
# save to file, use when snapshot is a part of the workflow result
If `--filename` is not provided, a new snapshot file is created with a timestamp. Default to automatic file naming, use `--filename=` when artifact is a part of the workflow result.
212
+
# limit snapshot depth for efficiency, take a partial snapshot afterwards
213
+
playwright-cli snapshot --depth=4
214
+
playwright-cli snapshot e34
215
+
```
198
216
199
217
## Targeting elements
200
218
@@ -208,17 +226,17 @@ playwright-cli snapshot
208
226
playwright-cli click e15
209
227
```
210
228
211
-
You can also use css or role selectors, for example when explicitly asked for it.
229
+
You can also use css selectors or Playwright locators.
Copy file name to clipboardExpand all lines: skills/playwright-cli/references/playwright-tests.md
+12-8Lines changed: 12 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,24 +12,28 @@ PLAYWRIGHT_HTML_OPEN=never npm run special-test-command
12
12
13
13
# Debugging Playwright Tests
14
14
15
-
To debug a failing test, run it with Playwright as usual, but set `PWPAUSE=cli`environment variable. This command will pause the test at the point of failure, and print the debugging instructions.
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
16
17
17
**IMPORTANT**: run the command in the background and check the output until "Debugging Instructions" is printed.
18
18
19
-
Once instructions are printed, use `playwright-cli` to explore the page. Debugging instructions include a browser name that should be used in `playwright-cli` to attach to the page under test.
19
+
Once instructions containing a session name are printed, use `playwright-cli` to attach the session and explore the page.
20
20
21
21
```bash
22
22
# Run the test
23
-
PLAYWRIGHT_HTML_OPEN=never PWPAUSE=cli npx playwright test
23
+
PLAYWRIGHT_HTML_OPEN=never npx playwright test --debug=cli
24
+
# ...
25
+
# ... debugging instructions for "tw-abcdef" session ...
24
26
# ...
25
27
26
-
# Explore the page and interact if needed
27
-
playwright-cli --session=test open --attach=test-worker-abcdef
28
-
playwright-cli --session=test snapshot
29
-
playwright-cli --session=test click e14
28
+
# Attach to the test
29
+
playwright-cli attach tw-abcdef
30
30
```
31
31
32
-
Keep the test running in the background while you explore and look for a fix. After fixing the test, stop the background test run.
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.
33
35
34
36
Every action you perform with `playwright-cli` generates corresponding Playwright TypeScript code.
35
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 commit comments