@playwright/cli 0.0.60
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/LICENSE +201 -0
- package/README.md +391 -0
- package/package.json +30 -0
- package/playwright-cli.js +23 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright (c) Microsoft Corporation.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
# playwright-cli
|
|
2
|
+
|
|
3
|
+
Playwright CLI with SKILLS
|
|
4
|
+
|
|
5
|
+
### Playwright CLI vs Playwright MCP
|
|
6
|
+
|
|
7
|
+
This package provides CLI interface into Playwright. If you are using **coding agents**, that is the best fit.
|
|
8
|
+
|
|
9
|
+
- **CLI**: Modern **coding agents** increasingly favor CLI–based workflows exposed as SKILLs over MCP because CLI invocations are more token-efficient: they avoid loading large tool schemas and verbose accessibility trees into the model context, allowing agents to act through concise, purpose-built commands. This makes CLI + SKILLs better suited for high-throughput coding agents that must balance browser automation with large codebases, tests, and reasoning within limited context windows.
|
|
10
|
+
|
|
11
|
+
- **MCP**: MCP remains relevant for specialized agentic loops that benefit from persistent state, rich introspection, and iterative reasoning over page structure, such as exploratory automation, self-healing tests, or long-running autonomous workflows where maintaining continuous browser context outweighs token cost concerns. Learn more about [Playwright MCP](https://github.com/microsoft/playwright-mcp).
|
|
12
|
+
|
|
13
|
+
### Key Features
|
|
14
|
+
|
|
15
|
+
- **Token-efficient**. Does not force page data into LLM.
|
|
16
|
+
|
|
17
|
+
### Requirements
|
|
18
|
+
- Node.js 18 or newer
|
|
19
|
+
- Claude Code, GitHub Copilot, or any other coding agent.
|
|
20
|
+
|
|
21
|
+
## Getting Started
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install -g @playwright/cli@latest
|
|
27
|
+
playwright-cli --help
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Demo
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
> Use playwright skills to test https://demo.playwright.dev/todomvc/.
|
|
34
|
+
Take screenshots for all successful and failing scenarios.
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Your agent will be running commands, but it does not mean you can't play with it manually:
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
playwright-cli open https://demo.playwright.dev/todomvc/ --headed
|
|
41
|
+
playwright-cli type "Buy groceries"
|
|
42
|
+
playwright-cli press Enter
|
|
43
|
+
playwright-cli type "Water flowers"
|
|
44
|
+
playwright-cli press Enter
|
|
45
|
+
playwright-cli check e21
|
|
46
|
+
playwright-cli check e35
|
|
47
|
+
playwright-cli screenshot
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Skills-less operation
|
|
51
|
+
|
|
52
|
+
Point your agent at the CLI and let it cook. It'll read the skill off `playwright-cli --help` on its own:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
Test the "add todo" flow on https://demo.playwright.dev/todomvc using playwright-cli.
|
|
56
|
+
Check playwright-cli --help for available commands.
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Installing skills
|
|
60
|
+
|
|
61
|
+
Claude Code, GitHub copilot and others will let you install the Playwright skills into the agentic loop.
|
|
62
|
+
|
|
63
|
+
#### plugin (recommended)
|
|
64
|
+
```bash
|
|
65
|
+
/plugin marketplace add microsoft/playwright-cli
|
|
66
|
+
/plugin install playwright-cli
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
#### manual
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
mkdir -p .claude/skills/playwright-cli
|
|
73
|
+
curl -o .claude/skills/playwright-cli/SKILL.md \
|
|
74
|
+
https://raw.githubusercontent.com/microsoft/playwright-cli/main/skills/playwright-cli/SKILL.md
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Headed operation
|
|
78
|
+
|
|
79
|
+
Playwright CLI is headless by default. If you'd like to see the browser, pass `--headed` to `open`:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
playwright-cli open https://playwright.dev --headed
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Sessions
|
|
86
|
+
|
|
87
|
+
Playwright CLI will use a dedicated persistent profile by default. It means that
|
|
88
|
+
your cookies and other storage state will be preserved between the calls. You can use different
|
|
89
|
+
instances of the browser for different projects with sessions.
|
|
90
|
+
|
|
91
|
+
Following will result in two browsers with separate profiles being available. Pass `--session` to
|
|
92
|
+
the invocation to talk to a specific browser.
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
playwright-cli open https://playwright.dev
|
|
96
|
+
playwright-cli --session=example open https://example.com
|
|
97
|
+
playwright-cli session-list
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
You can run your coding agent with the `PLAYWRIGHT_CLI_SESSION` environment variable:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
PLAYWRIGHT_CLI_SESSION=todo-app claude .
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Or instruct it to prepend `--session` to the calls.
|
|
107
|
+
|
|
108
|
+
Manage your sessions as follows:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
playwright-cli session-list # list all sessions
|
|
112
|
+
playwright-cli session-stop [name] # stop session
|
|
113
|
+
playwright-cli session-stop-all # stop all sessions
|
|
114
|
+
playwright-cli session-delete [name] # delete session data along with the profiles
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
<!-- BEGIN GENERATED CLI HELP -->
|
|
118
|
+
|
|
119
|
+
## Commands
|
|
120
|
+
|
|
121
|
+
### Core
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
playwright-cli open <url> # open url
|
|
125
|
+
playwright-cli close # close the page
|
|
126
|
+
playwright-cli type <text> # type text into editable element
|
|
127
|
+
playwright-cli click <ref> [button] # perform click on a web page
|
|
128
|
+
playwright-cli dblclick <ref> [button] # perform double click on a web page
|
|
129
|
+
playwright-cli fill <ref> <text> # fill text into editable element
|
|
130
|
+
playwright-cli drag <startRef> <endRef> # perform drag and drop between two elements
|
|
131
|
+
playwright-cli hover <ref> # hover over element on page
|
|
132
|
+
playwright-cli select <ref> <val> # select an option in a dropdown
|
|
133
|
+
playwright-cli upload <file> # upload one or multiple files
|
|
134
|
+
playwright-cli check <ref> # check a checkbox or radio button
|
|
135
|
+
playwright-cli uncheck <ref> # uncheck a checkbox or radio button
|
|
136
|
+
playwright-cli snapshot # capture page snapshot to obtain element ref
|
|
137
|
+
playwright-cli eval <func> [ref] # evaluate javascript expression on page or element
|
|
138
|
+
playwright-cli dialog-accept [prompt] # accept a dialog
|
|
139
|
+
playwright-cli dialog-dismiss # dismiss a dialog
|
|
140
|
+
playwright-cli resize <w> <h> # resize the browser window
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Navigation
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
playwright-cli go-back # go back to the previous page
|
|
147
|
+
playwright-cli go-forward # go forward to the next page
|
|
148
|
+
playwright-cli reload # reload the current page
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Keyboard
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
playwright-cli press <key> # press a key on the keyboard, `a`, `arrowleft`
|
|
155
|
+
playwright-cli keydown <key> # press a key down on the keyboard
|
|
156
|
+
playwright-cli keyup <key> # press a key up on the keyboard
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Mouse
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
playwright-cli mousemove <x> <y> # move mouse to a given position
|
|
163
|
+
playwright-cli mousedown [button] # press mouse down
|
|
164
|
+
playwright-cli mouseup [button] # press mouse up
|
|
165
|
+
playwright-cli mousewheel <dx> <dy> # scroll mouse wheel
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Save as
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
playwright-cli screenshot [ref] # screenshot of the current page or element
|
|
172
|
+
playwright-cli pdf # save page as pdf
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Tabs
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
playwright-cli tab-list # list all tabs
|
|
179
|
+
playwright-cli tab-new [url] # create a new tab
|
|
180
|
+
playwright-cli tab-close [index] # close a browser tab
|
|
181
|
+
playwright-cli tab-select <index> # select a browser tab
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### DevTools
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
playwright-cli console [min-level] # list console messages
|
|
188
|
+
playwright-cli network # list all network requests since loading the page
|
|
189
|
+
playwright-cli run-code <code> # run playwright code snippet
|
|
190
|
+
playwright-cli tracing-start # start trace recording
|
|
191
|
+
playwright-cli tracing-stop # stop trace recording
|
|
192
|
+
```
|
|
193
|
+
<!-- END GENERATED CLI HELP -->
|
|
194
|
+
|
|
195
|
+
## Configuration file
|
|
196
|
+
|
|
197
|
+
The Playwright CLI can be configured using a JSON configuration file. You can specify the configuration file using the `--config` command line option:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
playwright-cli --config path/to/config.json open example.com
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Playwright CLI will load config from `playwright-cli.json` by default so that you did not need to specify it every time.
|
|
204
|
+
|
|
205
|
+
<details>
|
|
206
|
+
<summary>Configuration file schema</summary>
|
|
207
|
+
|
|
208
|
+
```typescript
|
|
209
|
+
{
|
|
210
|
+
/**
|
|
211
|
+
* The browser to use.
|
|
212
|
+
*/
|
|
213
|
+
browser?: {
|
|
214
|
+
/**
|
|
215
|
+
* The type of browser to use.
|
|
216
|
+
*/
|
|
217
|
+
browserName?: 'chromium' | 'firefox' | 'webkit';
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Keep the browser profile in memory, do not save it to disk.
|
|
221
|
+
*/
|
|
222
|
+
isolated?: boolean;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Path to a user data directory for browser profile persistence.
|
|
226
|
+
* Temporary directory is created by default.
|
|
227
|
+
*/
|
|
228
|
+
userDataDir?: string;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Launch options passed to
|
|
232
|
+
* @see https://playwright.dev/docs/api/class-browsertype#browser-type-launch-persistent-context
|
|
233
|
+
*
|
|
234
|
+
* This is useful for settings options like `channel`, `headless`, `executablePath`, etc.
|
|
235
|
+
*/
|
|
236
|
+
launchOptions?: playwright.LaunchOptions;
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Context options for the browser context.
|
|
240
|
+
*
|
|
241
|
+
* This is useful for settings options like `viewport`.
|
|
242
|
+
*/
|
|
243
|
+
contextOptions?: playwright.BrowserContextOptions;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Chrome DevTools Protocol endpoint to connect to an existing browser instance in case of Chromium family browsers.
|
|
247
|
+
*/
|
|
248
|
+
cdpEndpoint?: string;
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* CDP headers to send with the connect request.
|
|
252
|
+
*/
|
|
253
|
+
cdpHeaders?: Record<string, string>;
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Timeout in milliseconds for connecting to CDP endpoint. Defaults to 30000 (30 seconds). Pass 0 to disable timeout.
|
|
257
|
+
*/
|
|
258
|
+
cdpTimeout?: number;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Remote endpoint to connect to an existing Playwright server.
|
|
262
|
+
*/
|
|
263
|
+
remoteEndpoint?: string;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Paths to TypeScript files to add as initialization scripts for Playwright page.
|
|
267
|
+
*/
|
|
268
|
+
initPage?: string[];
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Paths to JavaScript files to add as initialization scripts.
|
|
272
|
+
* The scripts will be evaluated in every page before any of the page's scripts.
|
|
273
|
+
*/
|
|
274
|
+
initScript?: string[];
|
|
275
|
+
},
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* If specified, saves the Playwright video of the session into the output directory.
|
|
279
|
+
*/
|
|
280
|
+
saveVideo?: {
|
|
281
|
+
width: number;
|
|
282
|
+
height: number;
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* The directory to save output files.
|
|
287
|
+
*/
|
|
288
|
+
outputDir?: string;
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Whether to save snapshots, console messages, network logs and other session logs to a file or to the standard output. Defaults to "stdout".
|
|
292
|
+
*/
|
|
293
|
+
outputMode?: 'file' | 'stdout';
|
|
294
|
+
|
|
295
|
+
console?: {
|
|
296
|
+
/**
|
|
297
|
+
* The level of console messages to return. Each level includes the messages of more severe levels. Defaults to "info".
|
|
298
|
+
*/
|
|
299
|
+
level?: 'error' | 'warning' | 'info' | 'debug';
|
|
300
|
+
},
|
|
301
|
+
|
|
302
|
+
network?: {
|
|
303
|
+
/**
|
|
304
|
+
* List of origins to allow the browser to request. Default is to allow all. Origins matching both `allowedOrigins` and `blockedOrigins` will be blocked.
|
|
305
|
+
*/
|
|
306
|
+
allowedOrigins?: string[];
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* List of origins to block the browser to request. Origins matching both `allowedOrigins` and `blockedOrigins` will be blocked.
|
|
310
|
+
*/
|
|
311
|
+
blockedOrigins?: string[];
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Specify the attribute to use for test ids, defaults to "data-testid".
|
|
316
|
+
*/
|
|
317
|
+
testIdAttribute?: string;
|
|
318
|
+
|
|
319
|
+
timeouts?: {
|
|
320
|
+
/*
|
|
321
|
+
* Configures default action timeout: https://playwright.dev/docs/api/class-page#page-set-default-timeout. Defaults to 5000ms.
|
|
322
|
+
*/
|
|
323
|
+
action?: number;
|
|
324
|
+
|
|
325
|
+
/*
|
|
326
|
+
* Configures default navigation timeout: https://playwright.dev/docs/api/class-page#page-set-default-navigation-timeout. Defaults to 60000ms.
|
|
327
|
+
*/
|
|
328
|
+
navigation?: number;
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Whether to allow file uploads from anywhere on the file system.
|
|
333
|
+
* By default (false), file uploads are restricted to paths within the MCP roots only.
|
|
334
|
+
*/
|
|
335
|
+
allowUnrestrictedFileAccess?: boolean;
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Specify the language to use for code generation.
|
|
339
|
+
*/
|
|
340
|
+
codegen?: 'typescript' | 'none';
|
|
341
|
+
}
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
</details>
|
|
345
|
+
|
|
346
|
+
## Environment
|
|
347
|
+
|
|
348
|
+
| Environment |
|
|
349
|
+
|-------------|
|
|
350
|
+
| `PLAYWRIGHT_MCP_ALLOWED_HOSTS` comma-separated list of hosts this server is allowed to serve from. Defaults to the host the server is bound to. Pass '*' to disable the host check. |
|
|
351
|
+
| `PLAYWRIGHT_MCP_ALLOWED_ORIGINS` semicolon-separated list of TRUSTED origins to allow the browser to request. Default is to allow all. Important: *does not* serve as a security boundary and *does not* affect redirects. |
|
|
352
|
+
| `PLAYWRIGHT_MCP_ALLOW_UNRESTRICTED_FILE_ACCESS` allow access to files outside of the workspace roots. Also allows unrestricted access to file:// URLs. By default access to file system is restricted to workspace root directories (or cwd if no roots are configured) only, and navigation to file:// URLs is blocked. |
|
|
353
|
+
| `PLAYWRIGHT_MCP_BLOCKED_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. |
|
|
354
|
+
| `PLAYWRIGHT_MCP_BLOCK_SERVICE_WORKERS` block service workers |
|
|
355
|
+
| `PLAYWRIGHT_MCP_BROWSER` browser or chrome channel to use, possible values: chrome, firefox, webkit, msedge. |
|
|
356
|
+
| `PLAYWRIGHT_MCP_CAPS` comma-separated list of additional capabilities to enable, possible values: vision, pdf. |
|
|
357
|
+
| `PLAYWRIGHT_MCP_CDP_ENDPOINT` CDP endpoint to connect to. |
|
|
358
|
+
| `PLAYWRIGHT_MCP_CDP_HEADER` CDP headers to send with the connect request, multiple can be specified. |
|
|
359
|
+
| `PLAYWRIGHT_MCP_CODEGEN` specify the language to use for code generation, possible values: "typescript", "none". Default is "typescript". |
|
|
360
|
+
| `PLAYWRIGHT_MCP_CONFIG` path to the configuration file. |
|
|
361
|
+
| `PLAYWRIGHT_MCP_CONSOLE_LEVEL` level of console messages to return: "error", "warning", "info", "debug". Each level includes the messages of more severe levels. |
|
|
362
|
+
| `PLAYWRIGHT_MCP_DEVICE` device to emulate, for example: "iPhone 15" |
|
|
363
|
+
| `PLAYWRIGHT_MCP_EXECUTABLE_PATH` path to the browser executable. |
|
|
364
|
+
| `PLAYWRIGHT_MCP_EXTENSION` Connect to a running browser instance (Edge/Chrome only). Requires the "Playwright MCP Bridge" browser extension to be installed. |
|
|
365
|
+
| `PLAYWRIGHT_MCP_GRANT_PERMISSIONS` List of permissions to grant to the browser context, for example "geolocation", "clipboard-read", "clipboard-write". |
|
|
366
|
+
| `PLAYWRIGHT_MCP_HEADLESS` run browser in headless mode, headed by default |
|
|
367
|
+
| `PLAYWRIGHT_MCP_HOST` host to bind server to. Default is localhost. Use 0.0.0.0 to bind to all interfaces. |
|
|
368
|
+
| `PLAYWRIGHT_MCP_IGNORE_HTTPS_ERRORS` ignore https errors |
|
|
369
|
+
| `PLAYWRIGHT_MCP_INIT_PAGE` path to TypeScript file to evaluate on Playwright page object |
|
|
370
|
+
| `PLAYWRIGHT_MCP_INIT_SCRIPT` path to JavaScript file to add as an initialization script. The script will be evaluated in every page before any of the page's scripts. Can be specified multiple times. |
|
|
371
|
+
| `PLAYWRIGHT_MCP_ISOLATED` keep the browser profile in memory, do not save it to disk. |
|
|
372
|
+
| `PLAYWRIGHT_MCP_IMAGE_RESPONSES` whether to send image responses to the client. Can be "allow" or "omit", Defaults to "allow". |
|
|
373
|
+
| `PLAYWRIGHT_MCP_NO_SANDBOX` disable the sandbox for all process types that are normally sandboxed. |
|
|
374
|
+
| `PLAYWRIGHT_MCP_OUTPUT_DIR` path to the directory for output files. |
|
|
375
|
+
| `PLAYWRIGHT_MCP_OUTPUT_MODE` whether to save snapshots, console messages, network logs to a file or to the standard output. Can be "file" or "stdout". Default is "stdout". |
|
|
376
|
+
| `PLAYWRIGHT_MCP_PORT` port to listen on for SSE transport. |
|
|
377
|
+
| `PLAYWRIGHT_MCP_PROXY_BYPASS` comma-separated domains to bypass proxy, for example ".com,chromium.org,.domain.com" |
|
|
378
|
+
| `PLAYWRIGHT_MCP_PROXY_SERVER` specify proxy server, for example "http://myproxy:3128" or "socks5://myproxy:8080" |
|
|
379
|
+
| `PLAYWRIGHT_MCP_SAVE_SESSION` Whether to save the Playwright MCP session into the output directory. |
|
|
380
|
+
| `PLAYWRIGHT_MCP_SAVE_TRACE` Whether to save the Playwright Trace of the session into the output directory. |
|
|
381
|
+
| `PLAYWRIGHT_MCP_SAVE_VIDEO` Whether to save the video of the session into the output directory. For example "--save-video=800x600" |
|
|
382
|
+
| `PLAYWRIGHT_MCP_SECRETS` path to a file containing secrets in the dotenv format |
|
|
383
|
+
| `PLAYWRIGHT_MCP_SHARED_BROWSER_CONTEXT` reuse the same browser context between all connected HTTP clients. |
|
|
384
|
+
| `PLAYWRIGHT_MCP_SNAPSHOT_MODE` when taking snapshots for responses, specifies the mode to use. Can be "incremental", "full", or "none". Default is incremental. |
|
|
385
|
+
| `PLAYWRIGHT_MCP_STORAGE_STATE` path to the storage state file for isolated sessions. |
|
|
386
|
+
| `PLAYWRIGHT_MCP_TEST_ID_ATTRIBUTE` specify the attribute to use for test ids, defaults to "data-testid" |
|
|
387
|
+
| `PLAYWRIGHT_MCP_TIMEOUT_ACTION` specify action timeout in milliseconds, defaults to 5000ms |
|
|
388
|
+
| `PLAYWRIGHT_MCP_TIMEOUT_NAVIGATION` specify navigation timeout in milliseconds, defaults to 60000ms |
|
|
389
|
+
| `PLAYWRIGHT_MCP_USER_AGENT` specify user agent string |
|
|
390
|
+
| `PLAYWRIGHT_MCP_USER_DATA_DIR` path to the user data directory. If not specified, a temporary directory will be created. |
|
|
391
|
+
| `PLAYWRIGHT_MCP_VIEWPORT_SIZE` specify browser viewport size in pixels, for example "1280x720" |
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@playwright/cli",
|
|
3
|
+
"version": "0.0.60",
|
|
4
|
+
"description": "Playwright CLI",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/microsoft/playwright-cli.git"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://playwright.dev",
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=18"
|
|
12
|
+
},
|
|
13
|
+
"author": {
|
|
14
|
+
"name": "Microsoft Corporation"
|
|
15
|
+
},
|
|
16
|
+
"license": "Apache-2.0",
|
|
17
|
+
"scripts": {
|
|
18
|
+
"lint": "echo OK",
|
|
19
|
+
"build": "echo OK",
|
|
20
|
+
"test": "echo OK"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"minimist": "^1.2.5",
|
|
24
|
+
"playwright": "1.59.0-alpha-1769452054000",
|
|
25
|
+
"playwright-core": "1.59.0-alpha-1769452054000"
|
|
26
|
+
},
|
|
27
|
+
"bin": {
|
|
28
|
+
"playwright-cli": "./playwright-cli.js"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const { program } = require('playwright/lib/mcp/terminal/program');
|
|
19
|
+
const packageJSON = require('./package.json');
|
|
20
|
+
program({ version: packageJSON.version }).catch(e => {
|
|
21
|
+
console.error(e.message);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
});
|