mirror of
https://github.com/microsoft/playwright-mcp.git
synced 2026-02-04 09:13:10 +00:00
Compare commits
6 Commits
925735af51
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de6776f318 | ||
|
|
822d81e02b | ||
|
|
fed2475a86 | ||
|
|
34679cc689 | ||
|
|
c83315e4c9 | ||
|
|
d246fff5d7 |
55
.github/workflows/ci.yml
vendored
55
.github/workflows/ci.yml
vendored
@@ -21,7 +21,7 @@ jobs:
|
|||||||
- name: Ensure no changes
|
- name: Ensure no changes
|
||||||
run: git diff --exit-code
|
run: git diff --exit-code
|
||||||
|
|
||||||
test_mcp:
|
test:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -38,9 +38,24 @@ jobs:
|
|||||||
run: npm ci
|
run: npm ci
|
||||||
- name: Playwright install
|
- name: Playwright install
|
||||||
run: npx playwright install --with-deps
|
run: npx playwright install --with-deps
|
||||||
- name: Run tests
|
- name: Build
|
||||||
run: npm run test
|
run: npm run build
|
||||||
working-directory: ./packages/playwright-mcp
|
- name: Run playwright-mcp tests
|
||||||
|
id: test-mcp
|
||||||
|
run: npm run test --workspace=packages/playwright-mcp
|
||||||
|
continue-on-error: true
|
||||||
|
- name: Run playwright-cli tests
|
||||||
|
id: test-cli
|
||||||
|
run: npm run test --workspace=packages/playwright-cli
|
||||||
|
continue-on-error: true
|
||||||
|
- name: Run extension tests
|
||||||
|
id: test-extension
|
||||||
|
if: matrix.os == 'macos-15'
|
||||||
|
run: npm run test --workspace=packages/extension
|
||||||
|
continue-on-error: true
|
||||||
|
- name: Check test results
|
||||||
|
if: steps.test-mcp.outcome == 'failure' || steps.test-cli.outcome == 'failure' || steps.test-extension.outcome == 'failure'
|
||||||
|
run: exit 1
|
||||||
|
|
||||||
test_mcp_docker:
|
test_mcp_docker:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -73,35 +88,3 @@ jobs:
|
|||||||
working-directory: ./packages/playwright-mcp
|
working-directory: ./packages/playwright-mcp
|
||||||
env:
|
env:
|
||||||
MCP_IN_DOCKER: 1
|
MCP_IN_DOCKER: 1
|
||||||
|
|
||||||
test_extension:
|
|
||||||
runs-on: macos-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Use Node.js 20
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: '20' # crypto.randomUUID(); stalls in v18.20.8
|
|
||||||
cache: 'npm'
|
|
||||||
- name: Install dependencies
|
|
||||||
run: npm ci
|
|
||||||
- name: Playwright install
|
|
||||||
run: npx playwright install --with-deps
|
|
||||||
- name: Build extension
|
|
||||||
run: npm run build
|
|
||||||
working-directory: ./packages/extension
|
|
||||||
- name: Upload artifact
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: extension
|
|
||||||
path: ./extension/dist
|
|
||||||
retention-days: 7
|
|
||||||
- name: Run tests
|
|
||||||
run: |
|
|
||||||
if [[ "$(uname)" == "Linux" ]]; then
|
|
||||||
xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test
|
|
||||||
else
|
|
||||||
npm run test
|
|
||||||
fi
|
|
||||||
shell: bash
|
|
||||||
working-directory: ./packages/extension
|
|
||||||
|
|||||||
18
README.md
18
README.md
@@ -340,7 +340,7 @@ Playwright MCP server supports following arguments. They can be provided in the
|
|||||||
| --blocked-origins <origins> | semicolon-separated list of origins to block the browser from requesting. Blocklist is evaluated before allowlist. If used without the allowlist, requests not matching the blocklist are still allowed. Important: *does not* serve as a security boundary and *does not* affect redirects.<br>*env* `PLAYWRIGHT_MCP_BLOCKED_ORIGINS` |
|
| --blocked-origins <origins> | semicolon-separated list of origins to block the browser from requesting. Blocklist is evaluated before allowlist. If used without the allowlist, requests not matching the blocklist are still allowed. Important: *does not* serve as a security boundary and *does not* affect redirects.<br>*env* `PLAYWRIGHT_MCP_BLOCKED_ORIGINS` |
|
||||||
| --block-service-workers | block service workers<br>*env* `PLAYWRIGHT_MCP_BLOCK_SERVICE_WORKERS` |
|
| --block-service-workers | block service workers<br>*env* `PLAYWRIGHT_MCP_BLOCK_SERVICE_WORKERS` |
|
||||||
| --browser <browser> | browser or chrome channel to use, possible values: chrome, firefox, webkit, msedge.<br>*env* `PLAYWRIGHT_MCP_BROWSER` |
|
| --browser <browser> | browser or chrome channel to use, possible values: chrome, firefox, webkit, msedge.<br>*env* `PLAYWRIGHT_MCP_BROWSER` |
|
||||||
| --caps <caps> | comma-separated list of additional capabilities to enable, possible values: vision, pdf.<br>*env* `PLAYWRIGHT_MCP_CAPS` |
|
| --caps <caps> | comma-separated list of additional capabilities to enable, possible values: vision, pdf, devtools.<br>*env* `PLAYWRIGHT_MCP_CAPS` |
|
||||||
| --cdp-endpoint <endpoint> | CDP endpoint to connect to.<br>*env* `PLAYWRIGHT_MCP_CDP_ENDPOINT` |
|
| --cdp-endpoint <endpoint> | CDP endpoint to connect to.<br>*env* `PLAYWRIGHT_MCP_CDP_ENDPOINT` |
|
||||||
| --cdp-header <headers...> | CDP headers to send with the connect request, multiple can be specified.<br>*env* `PLAYWRIGHT_MCP_CDP_HEADER` |
|
| --cdp-header <headers...> | CDP headers to send with the connect request, multiple can be specified.<br>*env* `PLAYWRIGHT_MCP_CDP_HEADER` |
|
||||||
| --codegen <lang> | specify the language to use for code generation, possible values: "typescript", "none". Default is "typescript".<br>*env* `PLAYWRIGHT_MCP_CODEGEN` |
|
| --codegen <lang> | specify the language to use for code generation, possible values: "typescript", "none". Default is "typescript".<br>*env* `PLAYWRIGHT_MCP_CODEGEN` |
|
||||||
@@ -1128,22 +1128,6 @@ http.createServer(async (req, res) => {
|
|||||||
<details>
|
<details>
|
||||||
<summary><b>Tracing (opt-in via --caps=tracing)</b></summary>
|
<summary><b>Tracing (opt-in via --caps=tracing)</b></summary>
|
||||||
|
|
||||||
<!-- NOTE: This has been generated via update-readme.js -->
|
|
||||||
|
|
||||||
- **browser_start_tracing**
|
|
||||||
- Title: Start tracing
|
|
||||||
- Description: Start trace recording
|
|
||||||
- Parameters: None
|
|
||||||
- Read-only: **true**
|
|
||||||
|
|
||||||
<!-- NOTE: This has been generated via update-readme.js -->
|
|
||||||
|
|
||||||
- **browser_stop_tracing**
|
|
||||||
- Title: Stop tracing
|
|
||||||
- Description: Stop trace recording
|
|
||||||
- Parameters: None
|
|
||||||
- Read-only: **true**
|
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
46
package-lock.json
generated
46
package-lock.json
generated
@@ -1,19 +1,19 @@
|
|||||||
{
|
{
|
||||||
"name": "playwright-mcp-internal",
|
"name": "playwright-mcp-internal",
|
||||||
"version": "0.0.61",
|
"version": "0.0.63",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "playwright-mcp-internal",
|
"name": "playwright-mcp-internal",
|
||||||
"version": "0.0.61",
|
"version": "0.0.63",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"packages/*"
|
"packages/*"
|
||||||
],
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@modelcontextprotocol/sdk": "^1.25.2",
|
"@modelcontextprotocol/sdk": "^1.25.2",
|
||||||
"@playwright/test": "1.59.0-alpha-1769561805000",
|
"@playwright/test": "1.59.0-alpha-1770157258000",
|
||||||
"@types/node": "^24.3.0"
|
"@types/node": "^24.3.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -806,13 +806,13 @@
|
|||||||
"link": true
|
"link": true
|
||||||
},
|
},
|
||||||
"node_modules/@playwright/test": {
|
"node_modules/@playwright/test": {
|
||||||
"version": "1.59.0-alpha-1769561805000",
|
"version": "1.59.0-alpha-1770157258000",
|
||||||
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.59.0-alpha-1769561805000.tgz",
|
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.59.0-alpha-1770157258000.tgz",
|
||||||
"integrity": "sha512-S6Bvamvt2+M3Aolm5CJwUpLoNTqK32NYtbrt6n278vTjQZOxm9XVCp0+cJyuzDbzIdl+1nMdCB7n1NAFkKoB7g==",
|
"integrity": "sha512-zBg9P0xkKXnDrSr7zmVqkGnUwiR/2PnxHs2zWsQ9EeG76X5YOn5hcuog/1YFrzOKvYOb+bcnjXb+dMTn8fkMTA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"playwright": "1.59.0-alpha-1769561805000"
|
"playwright": "1.59.0-alpha-1770157258000"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"playwright": "cli.js"
|
"playwright": "cli.js"
|
||||||
@@ -2562,12 +2562,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/playwright": {
|
"node_modules/playwright": {
|
||||||
"version": "1.59.0-alpha-1769561805000",
|
"version": "1.59.0-alpha-1770157258000",
|
||||||
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.59.0-alpha-1769561805000.tgz",
|
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.59.0-alpha-1770157258000.tgz",
|
||||||
"integrity": "sha512-ZSqxE5/k3QdPCQL0mqpiRYVkAeFuELBK6NMuoPfHHHx5d1OH2MBiRUL2KEBtJZXqpQt7QfZP664f4qQ0xW48JA==",
|
"integrity": "sha512-jGMgi+61xaC9Pf7cIalsgKy4g0oAreA8U4/Lr8E0xhYl3pWd/U3F6s/m7GBWxJHHEiQcIdnP3mUdy1FTOyl8SQ==",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"playwright-core": "1.59.0-alpha-1769561805000"
|
"playwright-core": "1.59.0-alpha-1770157258000"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"playwright": "cli.js"
|
"playwright": "cli.js"
|
||||||
@@ -2584,9 +2584,9 @@
|
|||||||
"link": true
|
"link": true
|
||||||
},
|
},
|
||||||
"node_modules/playwright-core": {
|
"node_modules/playwright-core": {
|
||||||
"version": "1.59.0-alpha-1769561805000",
|
"version": "1.59.0-alpha-1770157258000",
|
||||||
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.59.0-alpha-1769561805000.tgz",
|
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.59.0-alpha-1770157258000.tgz",
|
||||||
"integrity": "sha512-qB8D0mAP1vrqndK6a/v9iCji9jA/aFv95KSh0TJmoQNLzXkPWwq7a3UWmjUjUDKiyWgiQ8WpI59ham7Q+ypBww==",
|
"integrity": "sha512-D+3ARZYNY7/i6LyV6DKsPQHkzfmuMXMdKdyW981i5CHA4GmXY2NTt1F7cEL4fGYJFpwPqTfQ17Qhas8dnirPkg==",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"bin": {
|
"bin": {
|
||||||
"playwright-core": "cli.js"
|
"playwright-core": "cli.js"
|
||||||
@@ -3306,7 +3306,7 @@
|
|||||||
},
|
},
|
||||||
"packages/extension": {
|
"packages/extension": {
|
||||||
"name": "@playwright/mcp-extension",
|
"name": "@playwright/mcp-extension",
|
||||||
"version": "0.0.61",
|
"version": "0.0.63",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/chrome": "^0.0.315",
|
"@types/chrome": "^0.0.315",
|
||||||
@@ -3325,12 +3325,12 @@
|
|||||||
},
|
},
|
||||||
"packages/playwright-cli": {
|
"packages/playwright-cli": {
|
||||||
"name": "@playwright/cli",
|
"name": "@playwright/cli",
|
||||||
"version": "0.0.61",
|
"version": "0.0.63",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"minimist": "^1.2.5",
|
"minimist": "^1.2.5",
|
||||||
"playwright": "1.59.0-alpha-1769561805000",
|
"playwright": "1.59.0-alpha-1770157258000",
|
||||||
"playwright-core": "1.59.0-alpha-1769561805000"
|
"playwright-core": "1.59.0-alpha-1770157258000"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"playwright-cli": "playwright-cli.js"
|
"playwright-cli": "playwright-cli.js"
|
||||||
@@ -3341,20 +3341,20 @@
|
|||||||
},
|
},
|
||||||
"packages/playwright-cli-stub": {
|
"packages/playwright-cli-stub": {
|
||||||
"name": "playwright-cli",
|
"name": "playwright-cli",
|
||||||
"version": "0.261.0",
|
"version": "0.0.63",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@playwright/cli": "0.0.61"
|
"@playwright/cli": "0.0.63"
|
||||||
},
|
},
|
||||||
"devDependencies": {}
|
"devDependencies": {}
|
||||||
},
|
},
|
||||||
"packages/playwright-mcp": {
|
"packages/playwright-mcp": {
|
||||||
"name": "@playwright/mcp",
|
"name": "@playwright/mcp",
|
||||||
"version": "0.0.61",
|
"version": "0.0.63",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"playwright": "1.59.0-alpha-1769561805000",
|
"playwright": "1.59.0-alpha-1770157258000",
|
||||||
"playwright-core": "1.59.0-alpha-1769561805000"
|
"playwright-core": "1.59.0-alpha-1770157258000"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"playwright-mcp": "cli.js"
|
"playwright-mcp": "cli.js"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "playwright-mcp-internal",
|
"name": "playwright-mcp-internal",
|
||||||
"version": "0.0.61",
|
"version": "0.0.63",
|
||||||
"private": true,
|
"private": true,
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -17,14 +17,15 @@
|
|||||||
"docker-run": "docker run -it -p 8080:8080 --name playwright-mcp-dev playwright-mcp-dev:latest",
|
"docker-run": "docker run -it -p 8080:8080 --name playwright-mcp-dev playwright-mcp-dev:latest",
|
||||||
"lint": "npm run lint --workspaces",
|
"lint": "npm run lint --workspaces",
|
||||||
"test": "npm run test --workspaces",
|
"test": "npm run test --workspaces",
|
||||||
"build": "npm run build --workspaces"
|
"build": "npm run build --workspaces",
|
||||||
|
"bump": "npm version --workspaces --no-git-tag-version"
|
||||||
},
|
},
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"packages/*"
|
"packages/*"
|
||||||
],
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@modelcontextprotocol/sdk": "^1.25.2",
|
"@modelcontextprotocol/sdk": "^1.25.2",
|
||||||
"@playwright/test": "1.59.0-alpha-1769561805000",
|
"@playwright/test": "1.59.0-alpha-1770157258000",
|
||||||
"@types/node": "^24.3.0"
|
"@types/node": "^24.3.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "Playwright MCP Bridge",
|
"name": "Playwright MCP Bridge",
|
||||||
"version": "0.0.61",
|
"version": "0.0.63",
|
||||||
"description": "Share browser tabs with Playwright MCP server",
|
"description": "Share browser tabs with Playwright MCP server",
|
||||||
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA9nMS2b0WCohjVHPGb8D9qAdkbIngDqoAjTeSccHJijgcONejge+OJxOQOMLu7b0ovt1c9BiEJa5JcpM+EHFVGL1vluBxK71zmBy1m2f9vZF3HG0LSCp7YRkum9rAIEthDwbkxx6XTvpmAY5rjFa/NON6b9Hlbo+8peUSkoOK7HTwYnnI36asZ9eUTiveIf+DMPLojW2UX33vDWG2UKvMVDewzclb4+uLxAYshY7Mx8we/b44xu+Anb/EBLKjOPk9Yh541xJ5Ozc8EiP/5yxOp9c/lRiYUHaRW+4r0HKZyFt0eZ52ti2iM4Nfk7jRXR7an3JPsUIf5deC/1cVM/+1ZQIDAQAB",
|
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA9nMS2b0WCohjVHPGb8D9qAdkbIngDqoAjTeSccHJijgcONejge+OJxOQOMLu7b0ovt1c9BiEJa5JcpM+EHFVGL1vluBxK71zmBy1m2f9vZF3HG0LSCp7YRkum9rAIEthDwbkxx6XTvpmAY5rjFa/NON6b9Hlbo+8peUSkoOK7HTwYnnI36asZ9eUTiveIf+DMPLojW2UX33vDWG2UKvMVDewzclb4+uLxAYshY7Mx8we/b44xu+Anb/EBLKjOPk9Yh541xJ5Ozc8EiP/5yxOp9c/lRiYUHaRW+4r0HKZyFt0eZ52ti2iM4Nfk7jRXR7an3JPsUIf5deC/1cVM/+1ZQIDAQAB",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@playwright/mcp-extension",
|
"name": "@playwright/mcp-extension",
|
||||||
"version": "0.0.61",
|
"version": "0.0.63",
|
||||||
"description": "Playwright MCP Browser Extension",
|
"description": "Playwright MCP Browser Extension",
|
||||||
"private": true,
|
"private": true,
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "playwright-cli",
|
"name": "playwright-cli",
|
||||||
"version": "0.261.0",
|
"version": "0.0.63",
|
||||||
"description": "Playwright CLI",
|
"description": "Playwright CLI",
|
||||||
"repository": "github:Microsoft/playwright-cli",
|
"repository": "github:Microsoft/playwright-cli",
|
||||||
"homepage": "https://playwright.dev",
|
"homepage": "https://playwright.dev",
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
},
|
},
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@playwright/cli": "0.0.61"
|
"@playwright/cli": "0.0.63"
|
||||||
},
|
},
|
||||||
"devDependencies": {}
|
"devDependencies": {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,23 @@ npm install -g @playwright/cli@latest
|
|||||||
playwright-cli --help
|
playwright-cli --help
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Installing skills
|
||||||
|
|
||||||
|
Claude Code, GitHub Copilot and others will use the locally installed skills.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
playwright-cli install-skills
|
||||||
|
```
|
||||||
|
|
||||||
|
### Skills-less operation
|
||||||
|
|
||||||
|
Point your agent at the CLI and let it cook. It'll read the skill off `playwright-cli --help` on its own:
|
||||||
|
|
||||||
|
```
|
||||||
|
Test the "add todo" flow on https://demo.playwright.dev/todomvc using playwright-cli.
|
||||||
|
Check playwright-cli --help for available commands.
|
||||||
|
```
|
||||||
|
|
||||||
## Demo
|
## Demo
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -110,6 +127,7 @@ Manage your sessions as follows:
|
|||||||
```bash
|
```bash
|
||||||
playwright-cli session-list # list all sessions
|
playwright-cli session-list # list all sessions
|
||||||
playwright-cli session-stop [name] # stop session
|
playwright-cli session-stop [name] # stop session
|
||||||
|
playwright-cli session-restart [name] # restart session
|
||||||
playwright-cli session-stop-all # stop all sessions
|
playwright-cli session-stop-all # stop all sessions
|
||||||
playwright-cli session-delete [name] # delete session data along with the profiles
|
playwright-cli session-delete [name] # delete session data along with the profiles
|
||||||
```
|
```
|
||||||
@@ -181,6 +199,42 @@ playwright-cli tab-close [index] # close a browser tab
|
|||||||
playwright-cli tab-select <index> # select a browser tab
|
playwright-cli tab-select <index> # select a browser tab
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Storage
|
||||||
|
|
||||||
|
```bash
|
||||||
|
playwright-cli state-save [filename] # save storage state
|
||||||
|
playwright-cli state-load <filename> # load storage state
|
||||||
|
|
||||||
|
# Cookies
|
||||||
|
playwright-cli cookie-list [--domain] # list cookies
|
||||||
|
playwright-cli cookie-get <name> # get a cookie
|
||||||
|
playwright-cli cookie-set <name> <val> # set a cookie
|
||||||
|
playwright-cli cookie-delete <name> # delete a cookie
|
||||||
|
playwright-cli cookie-clear # clear all cookies
|
||||||
|
|
||||||
|
# LocalStorage
|
||||||
|
playwright-cli localstorage-list # list localStorage entries
|
||||||
|
playwright-cli localstorage-get <key> # get localStorage value
|
||||||
|
playwright-cli localstorage-set <k> <v> # set localStorage value
|
||||||
|
playwright-cli localstorage-delete <k> # delete localStorage entry
|
||||||
|
playwright-cli localstorage-clear # clear all localStorage
|
||||||
|
|
||||||
|
# SessionStorage
|
||||||
|
playwright-cli sessionstorage-list # list sessionStorage entries
|
||||||
|
playwright-cli sessionstorage-get <k> # get sessionStorage value
|
||||||
|
playwright-cli sessionstorage-set <k> <v> # set sessionStorage value
|
||||||
|
playwright-cli sessionstorage-delete <k> # delete sessionStorage entry
|
||||||
|
playwright-cli sessionstorage-clear # clear all sessionStorage
|
||||||
|
```
|
||||||
|
|
||||||
|
### Network
|
||||||
|
|
||||||
|
```bash
|
||||||
|
playwright-cli route <pattern> [opts] # mock network requests
|
||||||
|
playwright-cli route-list # list active routes
|
||||||
|
playwright-cli unroute [pattern] # remove route(s)
|
||||||
|
```
|
||||||
|
|
||||||
### DevTools
|
### DevTools
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -189,6 +243,35 @@ playwright-cli network # list all network requests since loadin
|
|||||||
playwright-cli run-code <code> # run playwright code snippet
|
playwright-cli run-code <code> # run playwright code snippet
|
||||||
playwright-cli tracing-start # start trace recording
|
playwright-cli tracing-start # start trace recording
|
||||||
playwright-cli tracing-stop # stop trace recording
|
playwright-cli tracing-stop # stop trace recording
|
||||||
|
playwright-cli video-start # start video recording
|
||||||
|
playwright-cli video-stop [filename] # stop video recording
|
||||||
|
```
|
||||||
|
|
||||||
|
### Install
|
||||||
|
|
||||||
|
```bash
|
||||||
|
playwright-cli install-browser # install browser
|
||||||
|
playwright-cli install-skills # install skills
|
||||||
|
```
|
||||||
|
|
||||||
|
### Configuration
|
||||||
|
|
||||||
|
```bash
|
||||||
|
playwright-cli config [options] # configure session settings
|
||||||
|
playwright-cli open --browser=chrome # use specific browser
|
||||||
|
playwright-cli open --extension # connect via browser extension
|
||||||
|
playwright-cli open --config=file.json # use config file
|
||||||
|
```
|
||||||
|
|
||||||
|
### Sessions
|
||||||
|
|
||||||
|
```bash
|
||||||
|
playwright-cli --session=name <cmd> # run command in named session
|
||||||
|
playwright-cli session-list # list all sessions
|
||||||
|
playwright-cli session-stop [name] # stop session
|
||||||
|
playwright-cli session-restart [name] # restart session
|
||||||
|
playwright-cli session-stop-all # stop all sessions
|
||||||
|
playwright-cli session-delete [name] # delete session data and profiles
|
||||||
```
|
```
|
||||||
<!-- END GENERATED CLI HELP -->
|
<!-- END GENERATED CLI HELP -->
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@playwright/cli",
|
"name": "@playwright/cli",
|
||||||
"version": "0.0.61",
|
"version": "0.0.63",
|
||||||
"description": "Playwright CLI",
|
"description": "Playwright CLI",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -17,12 +17,12 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "echo OK",
|
"lint": "echo OK",
|
||||||
"build": "echo OK",
|
"build": "echo OK",
|
||||||
"test": "echo OK"
|
"test": "playwright test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"minimist": "^1.2.5",
|
"minimist": "^1.2.5",
|
||||||
"playwright": "1.59.0-alpha-1769561805000",
|
"playwright": "1.59.0-alpha-1770157258000",
|
||||||
"playwright-core": "1.59.0-alpha-1769561805000"
|
"playwright-core": "1.59.0-alpha-1770157258000"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"playwright-cli": "playwright-cli.js"
|
"playwright-cli": "playwright-cli.js"
|
||||||
|
|||||||
@@ -16,8 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const { program } = require('playwright/lib/mcp/terminal/program');
|
const { program } = require('playwright/lib/mcp/terminal/program');
|
||||||
const packageJSON = require('./package.json');
|
const packageLocation = require.resolve('./package.json');
|
||||||
program({ version: packageJSON.version }).catch(e => {
|
program(packageLocation).catch(e => {
|
||||||
console.error(e.message);
|
console.error(e.message);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
|
|||||||
25
packages/playwright-cli/playwright.config.ts
Normal file
25
packages/playwright-cli/playwright.config.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) Microsoft Corporation.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { defineConfig } from '@playwright/test';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
testDir: './tests',
|
||||||
|
fullyParallel: true,
|
||||||
|
forbidOnly: !!process.env.CI,
|
||||||
|
workers: process.env.CI ? 2 : undefined,
|
||||||
|
reporter: 'list',
|
||||||
|
});
|
||||||
72
packages/playwright-cli/tests/integration.spec.ts
Normal file
72
packages/playwright-cli/tests/integration.spec.ts
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) Microsoft Corporation.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import path from 'path';
|
||||||
|
import { spawn } from 'child_process';
|
||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
|
||||||
|
type CliResult = {
|
||||||
|
output: string;
|
||||||
|
error: string;
|
||||||
|
exitCode: number | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
async function runCli(...args: string[]): Promise<CliResult> {
|
||||||
|
const cliPath = path.join(__dirname, '../playwright-cli.js');
|
||||||
|
|
||||||
|
return new Promise<CliResult>((resolve, reject) => {
|
||||||
|
let stdout = '';
|
||||||
|
let stderr = '';
|
||||||
|
|
||||||
|
const childProcess = spawn(process.execPath, [cliPath, ...args], {
|
||||||
|
env: {
|
||||||
|
...process.env,
|
||||||
|
PLAYWRIGHT_CLI_INSTALLATION_FOR_TEST: test.info().outputPath(),
|
||||||
|
},
|
||||||
|
cwd: test.info().outputPath(),
|
||||||
|
});
|
||||||
|
|
||||||
|
childProcess.stdout?.on('data', (data) => {
|
||||||
|
stdout += data.toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
childProcess.stderr?.on('data', (data) => {
|
||||||
|
stderr += data.toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
childProcess.on('close', (code) => {
|
||||||
|
resolve({
|
||||||
|
output: stdout.trim(),
|
||||||
|
error: stderr.trim(),
|
||||||
|
exitCode: code,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
childProcess.on('error', reject);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
test('open data URL', async ({}) => {
|
||||||
|
expect(await runCli('open', 'data:text/html,hello')).toEqual(expect.objectContaining({
|
||||||
|
output: expect.stringContaining('hello'),
|
||||||
|
exitCode: 0,
|
||||||
|
}));
|
||||||
|
|
||||||
|
expect(await runCli('session-delete')).toEqual(expect.objectContaining({
|
||||||
|
output: expect.stringContaining('Deleted user data for session'),
|
||||||
|
exitCode: 0,
|
||||||
|
}));
|
||||||
|
});
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@playwright/mcp",
|
"name": "@playwright/mcp",
|
||||||
"version": "0.0.61",
|
"version": "0.0.63",
|
||||||
"description": "Playwright Tools for MCP",
|
"description": "Playwright Tools for MCP",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -34,8 +34,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"playwright": "1.59.0-alpha-1769561805000",
|
"playwright": "1.59.0-alpha-1770157258000",
|
||||||
"playwright-core": "1.59.0-alpha-1769561805000"
|
"playwright-core": "1.59.0-alpha-1770157258000"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"playwright-mcp": "cli.js"
|
"playwright-mcp": "cli.js"
|
||||||
|
|||||||
Reference in New Issue
Block a user