Skip to content

Commit a0b79f6

Browse files
authored
chore: roll Playwright to 1.59.0-alpha-1773608981000 (#303)
1 parent e63e9b7 commit a0b79f6

9 files changed

Lines changed: 142 additions & 38 deletions

File tree

.claude/skills/dev/roll.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
## Steps
44

5-
1. **Update Playwright packages** in `package.json`:
5+
1. **Obtain latest Playwright version**
6+
`npm info playwright@next version`
7+
8+
2. **Update Playwright packages** in `package.json`:
69
- Update `playwright` (dependency) and `@playwright/test` (devDependency) to the target version.
710
- Run `npm install` to update `package-lock.json`.
811

9-
2. **Run the update script** to sync skills and README:
12+
3. **Run the update script** to sync skills and README:
1013
```bash
1114
node scripts/update.js
1215
```

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
node_modules/
22
.vscode/
33
/test-results/
4-
/.playwright-cli/
4+
/.playwright-cli/
5+
# Ignore self-skill which is a build artifact
6+
.claude/skills/playwright-cli/

README.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,31 @@ You can also take a snapshot on demand using `playwright-cli snapshot` command.
271271
272272
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.
273273
274+
### Targeting elements
275+
276+
By default, use refs from the snapshot to interact with page elements.
277+
278+
```bash
279+
# get snapshot with refs
280+
playwright-cli snapshot
281+
282+
# interact using a ref
283+
playwright-cli click e15
284+
```
285+
286+
You can also use css or role selectors, for example when explicitly asked for it.
287+
288+
```bash
289+
# css selector
290+
playwright-cli click "#main > button.submit"
291+
292+
# role selector
293+
playwright-cli click "role=button[name=Submit]"
294+
295+
# chaining css and role selectors
296+
playwright-cli click "#footer >> role=button[name=Submit]"
297+
```
298+
274299
### Sessions
275300
276301
```bash
@@ -284,11 +309,16 @@ playwright-cli kill-all # forcefully kill all browser processes
284309
285310
### Local installation
286311
287-
In some cases you might want to install playwright-cli locally. If running the globally available `playwright-cli` binary fails, use `npx playwright-cli` to run the commands. For example:
312+
If global `playwright-cli` command is not available, try a local version via `npx playwright-cli`:
313+
314+
```bash
315+
npx --no-install playwright-cli --version
316+
```
317+
318+
When local version is available, use `npx playwright-cli` in all commands. Otherwise, install `playwright-cli` as a global command:
288319
289320
```bash
290-
npx playwright-cli open https://example.com
291-
npx playwright-cli click e1
321+
npm install -g @playwright/cli@latest
292322
```
293323
294324
## Configuration file
@@ -488,6 +518,7 @@ Playwright CLI will load config from `.playwright/cli.config.json` by default so
488518

489519
The installed skill includes detailed reference guides for common tasks:
490520

521+
* **Running and Debugging Playwright tests** — run, debug and manage Playwright test suites
491522
* **Request mocking** — intercept and mock network requests
492523
* **Running Playwright code** — execute arbitrary Playwright scripts
493524
* **Browser session management** — manage multiple browser sessions

package-lock.json

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
"test": "playwright test"
1919
},
2020
"devDependencies": {
21-
"@playwright/test": "1.59.0-alpha-1771104257000",
21+
"@playwright/test": "1.59.0-alpha-1773608981000",
2222
"@types/node": "^25.2.1"
2323
},
2424
"dependencies": {
2525
"minimist": "^1.2.5",
26-
"playwright": "1.59.0-alpha-1771104257000"
26+
"playwright": "1.59.0-alpha-1773608981000"
2727
},
2828
"bin": {
2929
"playwright-cli": "playwright-cli.js"

playwright-cli.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
require('playwright/lib/cli/client/program');
18+
const { program } = require('playwright-core/lib/tools/cli-client/program');
19+
const packageJson = require('./package.json');
20+
21+
program({ embedderVersion: packageJson.version });

skills/playwright-cli/SKILL.md

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: playwright-cli
3-
description: Automates browser interactions for web testing, form filling, screenshots, and data extraction. Use when the user needs to navigate websites, interact with web pages, fill forms, take screenshots, test web applications, or extract information from web pages.
4-
allowed-tools: Bash(playwright-cli:*)
3+
description: Automate browser interactions, test web pages and work with Playwright tests.
4+
allowed-tools: Bash(playwright-cli:*) Bash(npx:*) Bash(npm:*)
55
---
66

77
# Browser Automation with playwright-cli
@@ -196,6 +196,31 @@ You can also take a snapshot on demand using `playwright-cli snapshot` command.
196196
197197
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.
198198
199+
## Targeting elements
200+
201+
By default, use refs from the snapshot to interact with page elements.
202+
203+
```bash
204+
# get snapshot with refs
205+
playwright-cli snapshot
206+
207+
# interact using a ref
208+
playwright-cli click e15
209+
```
210+
211+
You can also use css or role selectors, for example when explicitly asked for it.
212+
213+
```bash
214+
# css selector
215+
playwright-cli click "#main > button.submit"
216+
217+
# role selector
218+
playwright-cli click "role=button[name=Submit]"
219+
220+
# chaining css and role selectors
221+
playwright-cli click "#footer >> role=button[name=Submit]"
222+
```
223+
199224
## Browser Sessions
200225
201226
```bash
@@ -214,13 +239,18 @@ playwright-cli close-all
214239
playwright-cli kill-all
215240
```
216241
217-
## Local installation
242+
## Installation
243+
244+
If global `playwright-cli` command is not available, try a local version via `npx playwright-cli`:
245+
246+
```bash
247+
npx --no-install playwright-cli --version
248+
```
218249
219-
In some cases user might want to install playwright-cli locally. If running globally available `playwright-cli` binary fails, use `npx playwright-cli` to run the commands. For example:
250+
When local version is available, use `npx playwright-cli` in all commands. Otherwise, install `playwright-cli` as a global command:
220251
221252
```bash
222-
npx playwright-cli open https://example.com
223-
npx playwright-cli click e1
253+
npm install -g @playwright/cli@latest
224254
```
225255
226256
## Example: Form submission
@@ -269,6 +299,7 @@ playwright-cli close
269299
270300
## Specific tasks
271301
302+
* **Running and Debugging Playwright tests** [references/playwright-tests.md](references/playwright-tests.md)
272303
* **Request mocking** [references/request-mocking.md](references/request-mocking.md)
273304
* **Running Playwright code** [references/running-code.md](references/running-code.md)
274305
* **Browser session management** [references/session-management.md](references/session-management.md)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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 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.
16+
17+
**IMPORTANT**: run the command in the background and check the output until "Debugging Instructions" is printed.
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.
20+
21+
```bash
22+
# Run the test
23+
PLAYWRIGHT_HTML_OPEN=never PWPAUSE=cli npx playwright test
24+
# ...
25+
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
30+
```
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.
33+
34+
Every action you perform with `playwright-cli` generates corresponding Playwright TypeScript code.
35+
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.

skills/playwright-cli/references/running-code.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ playwright-cli run-code "async page => {
8787

8888
# Wait for specific element
8989
playwright-cli run-code "async page => {
90-
await page.waitForSelector('.loading', { state: 'hidden' });
90+
await page.locator('.loading').waitFor({ state: 'hidden' });
9191
}"
9292

9393
# Wait for function to return true
@@ -97,7 +97,7 @@ playwright-cli run-code "async page => {
9797

9898
# Wait with timeout
9999
playwright-cli run-code "async page => {
100-
await page.waitForSelector('.result', { timeout: 10000 });
100+
await page.locator('.result').waitFor({ timeout: 10000 });
101101
}"
102102
```
103103

@@ -122,10 +122,9 @@ playwright-cli run-code "async page => {
122122
```bash
123123
# Handle file download
124124
playwright-cli run-code "async page => {
125-
const [download] = await Promise.all([
126-
page.waitForEvent('download'),
127-
page.click('a.download-link')
128-
]);
125+
const downloadPromise = page.waitForEvent('download');
126+
await page.getByRole('link', { name: 'Download' }).click();
127+
const download = await downloadPromise;
129128
await download.saveAs('./downloaded-file.pdf');
130129
return download.suggestedFilename();
131130
}"
@@ -197,7 +196,7 @@ playwright-cli run-code "async page => {
197196
# Try-catch in run-code
198197
playwright-cli run-code "async page => {
199198
try {
200-
await page.click('.maybe-missing', { timeout: 1000 });
199+
await page.getByRole('button', { name: 'Submit' }).click({ timeout: 1000 });
201200
return 'clicked';
202201
} catch (e) {
203202
return 'element not found';
@@ -211,9 +210,9 @@ playwright-cli run-code "async page => {
211210
# Login and save state
212211
playwright-cli run-code "async page => {
213212
await page.goto('https://example.com/login');
214-
await page.fill('input[name=email]', 'user@example.com');
215-
await page.fill('input[name=password]', 'secret');
216-
await page.click('button[type=submit]');
213+
await page.getByRole('textbox', { name: 'Email' }).fill('user@example.com');
214+
await page.getByRole('textbox', { name: 'Password' }).fill('secret');
215+
await page.getByRole('button', { name: 'Sign in' }).click();
217216
await page.waitForURL('**/dashboard');
218217
await page.context().storageState({ path: 'auth.json' });
219218
return 'Login successful';

0 commit comments

Comments
 (0)