@pedropaulovc/playwright 1.59.0-next → 1.59.0-next.1
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/lib/common/config.js +2 -3
- package/lib/index.js +1 -1
- package/lib/isomorphic/teleReceiver.js +0 -1
- package/lib/mcp/browser/response.js +20 -21
- package/lib/mcp/browser/tab.js +4 -4
- package/lib/mcp/browser/tools/common.js +1 -3
- package/lib/mcp/browser/tools/console.js +1 -1
- package/lib/mcp/browser/tools/dialogs.js +0 -1
- package/lib/mcp/browser/tools/evaluate.js +6 -6
- package/lib/mcp/browser/tools/keyboard.js +8 -1
- package/lib/mcp/browser/tools/network.js +1 -1
- package/lib/mcp/browser/tools/pdf.js +2 -2
- package/lib/mcp/browser/tools/runCode.js +2 -4
- package/lib/mcp/browser/tools/screenshot.js +6 -9
- package/lib/mcp/browser/tools/snapshot.js +4 -2
- package/lib/mcp/browser/tools/utils.js +2 -2
- package/lib/mcp/program.js +1 -0
- package/lib/mcp/terminal/SKILL.md +158 -0
- package/lib/mcp/terminal/cli.js +2 -291
- package/lib/mcp/terminal/command.js +1 -1
- package/lib/mcp/terminal/commands.js +19 -19
- package/lib/mcp/terminal/help.json +10 -10
- package/lib/mcp/terminal/program.js +310 -0
- package/lib/program.js +1 -0
- package/lib/reporters/base.js +5 -1
- package/lib/transform/transform.js +2 -2
- package/package.json +4 -3
- package/types/test.d.ts +37 -1
- package/lib/mcp/browser/actions.d.js +0 -16
- package/lib/mcp/browser/tools/navigateAndWait.js +0 -66
- package/lib/mcp/browser/tools/snapshotViewport.js +0 -63
package/lib/mcp/terminal/cli.js
CHANGED
|
@@ -1,296 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
}
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
|
-
var import_child_process = require("child_process");
|
|
25
|
-
var import_crypto = __toESM(require("crypto"));
|
|
26
|
-
var import_fs = __toESM(require("fs"));
|
|
27
|
-
var import_net = __toESM(require("net"));
|
|
28
|
-
var import_os = __toESM(require("os"));
|
|
29
|
-
var import_path = __toESM(require("path"));
|
|
30
|
-
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
|
|
31
|
-
var import_socketConnection = require("./socketConnection");
|
|
32
|
-
const debugCli = (0, import_utilsBundle.debug)("pw:cli");
|
|
2
|
+
var import_program = require("./program");
|
|
33
3
|
const packageJSON = require("../../../package.json");
|
|
34
|
-
|
|
35
|
-
constructor(name, connection) {
|
|
36
|
-
this._nextMessageId = 1;
|
|
37
|
-
this._callbacks = /* @__PURE__ */ new Map();
|
|
38
|
-
this.name = name;
|
|
39
|
-
this._connection = connection;
|
|
40
|
-
this._connection.onmessage = (message) => this._onMessage(message);
|
|
41
|
-
this._connection.onclose = () => this.close();
|
|
42
|
-
}
|
|
43
|
-
async run(args) {
|
|
44
|
-
return await this._send("run", { args });
|
|
45
|
-
}
|
|
46
|
-
async stop() {
|
|
47
|
-
await this._send("stop");
|
|
48
|
-
this.close();
|
|
49
|
-
}
|
|
50
|
-
async _send(method, params = {}) {
|
|
51
|
-
const messageId = this._nextMessageId++;
|
|
52
|
-
const message = {
|
|
53
|
-
id: messageId,
|
|
54
|
-
method,
|
|
55
|
-
params
|
|
56
|
-
};
|
|
57
|
-
await this._connection.send(message);
|
|
58
|
-
return new Promise((resolve, reject) => {
|
|
59
|
-
this._callbacks.set(messageId, { resolve, reject });
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
close() {
|
|
63
|
-
for (const callback of this._callbacks.values())
|
|
64
|
-
callback.reject(new Error("Session closed"));
|
|
65
|
-
this._callbacks.clear();
|
|
66
|
-
this._connection.close();
|
|
67
|
-
}
|
|
68
|
-
_onMessage(object) {
|
|
69
|
-
if (object.id && this._callbacks.has(object.id)) {
|
|
70
|
-
const callback = this._callbacks.get(object.id);
|
|
71
|
-
this._callbacks.delete(object.id);
|
|
72
|
-
if (object.error)
|
|
73
|
-
callback.reject(new Error(object.error));
|
|
74
|
-
else
|
|
75
|
-
callback.resolve(object.result);
|
|
76
|
-
} else if (object.id) {
|
|
77
|
-
throw new Error(`Unexpected message id: ${object.id}`);
|
|
78
|
-
} else {
|
|
79
|
-
throw new Error(`Unexpected message without id: ${JSON.stringify(object)}`);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
class SessionManager {
|
|
84
|
-
async list() {
|
|
85
|
-
const dir = daemonSocketDir;
|
|
86
|
-
try {
|
|
87
|
-
const files = await import_fs.default.promises.readdir(dir);
|
|
88
|
-
const sessions = [];
|
|
89
|
-
for (const file of files) {
|
|
90
|
-
if (file.endsWith("-user-data")) {
|
|
91
|
-
const sessionName = file.slice(0, -"-user-data".length);
|
|
92
|
-
const live = await this._canConnect(sessionName);
|
|
93
|
-
sessions.push({ name: sessionName, live });
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return sessions;
|
|
97
|
-
} catch {
|
|
98
|
-
return [];
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
async run(args) {
|
|
102
|
-
const sessionName = this._resolveSessionName(args.session);
|
|
103
|
-
const session = await this._connect(sessionName);
|
|
104
|
-
const result = await session.run(args);
|
|
105
|
-
console.log(result);
|
|
106
|
-
session.close();
|
|
107
|
-
}
|
|
108
|
-
async stop(sessionName) {
|
|
109
|
-
sessionName = this._resolveSessionName(sessionName);
|
|
110
|
-
if (!await this._canConnect(sessionName)) {
|
|
111
|
-
console.log(`Session '${sessionName}' is not running.`);
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
const session = await this._connect(sessionName);
|
|
115
|
-
await session.stop();
|
|
116
|
-
console.log(`Session '${sessionName}' stopped.`);
|
|
117
|
-
}
|
|
118
|
-
async delete(sessionName) {
|
|
119
|
-
sessionName = this._resolveSessionName(sessionName);
|
|
120
|
-
if (await this._canConnect(sessionName)) {
|
|
121
|
-
const session = await this._connect(sessionName);
|
|
122
|
-
await session.stop();
|
|
123
|
-
}
|
|
124
|
-
const userDataDir = import_path.default.resolve(daemonSocketDir, `${sessionName}-user-data`);
|
|
125
|
-
try {
|
|
126
|
-
await import_fs.default.promises.rm(userDataDir, { recursive: true });
|
|
127
|
-
console.log(`Deleted user data for session '${sessionName}'.`);
|
|
128
|
-
} catch (e) {
|
|
129
|
-
if (e.code === "ENOENT")
|
|
130
|
-
console.log(`No user data found for session '${sessionName}'.`);
|
|
131
|
-
else
|
|
132
|
-
throw e;
|
|
133
|
-
}
|
|
134
|
-
if (import_os.default.platform() !== "win32") {
|
|
135
|
-
const socketPath = this._daemonSocketPath(sessionName);
|
|
136
|
-
await import_fs.default.promises.unlink(socketPath).catch(() => {
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
async _connect(sessionName) {
|
|
141
|
-
const socketPath = this._daemonSocketPath(sessionName);
|
|
142
|
-
debugCli(`Connecting to daemon at ${socketPath}`);
|
|
143
|
-
const socketExists = await import_fs.default.promises.stat(socketPath).then((stat) => stat?.isSocket() ?? false).catch(() => false);
|
|
144
|
-
if (socketExists) {
|
|
145
|
-
debugCli(`Socket file exists, attempting to connect...`);
|
|
146
|
-
try {
|
|
147
|
-
return await this._connectToSocket(sessionName, socketPath);
|
|
148
|
-
} catch (e) {
|
|
149
|
-
if (import_os.default.platform() !== "win32")
|
|
150
|
-
await import_fs.default.promises.unlink(socketPath).catch(() => {
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
const cliPath = import_path.default.join(__dirname, "../../../cli.js");
|
|
155
|
-
debugCli(`Will launch daemon process: ${cliPath}`);
|
|
156
|
-
const userDataDir = import_path.default.resolve(daemonSocketDir, `${sessionName}-user-data`);
|
|
157
|
-
const child = (0, import_child_process.spawn)(process.execPath, [cliPath, "run-mcp-server", `--daemon=${socketPath}`, `--user-data-dir=${userDataDir}`], {
|
|
158
|
-
detached: true,
|
|
159
|
-
stdio: "ignore",
|
|
160
|
-
cwd: process.cwd()
|
|
161
|
-
// Will be used as root.
|
|
162
|
-
});
|
|
163
|
-
child.unref();
|
|
164
|
-
const maxRetries = 50;
|
|
165
|
-
const retryDelay = 100;
|
|
166
|
-
for (let i = 0; i < maxRetries; i++) {
|
|
167
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
168
|
-
try {
|
|
169
|
-
return await this._connectToSocket(sessionName, socketPath);
|
|
170
|
-
} catch (e) {
|
|
171
|
-
if (e.code !== "ENOENT")
|
|
172
|
-
throw e;
|
|
173
|
-
debugCli(`Retrying to connect to daemon at ${socketPath} (${i + 1}/${maxRetries})`);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
throw new Error(`Failed to connect to daemon at ${socketPath} after ${maxRetries * retryDelay}ms`);
|
|
177
|
-
}
|
|
178
|
-
async _connectToSocket(sessionName, socketPath) {
|
|
179
|
-
const socket = await new Promise((resolve, reject) => {
|
|
180
|
-
const socket2 = import_net.default.createConnection(socketPath, () => {
|
|
181
|
-
debugCli(`Connected to daemon at ${socketPath}`);
|
|
182
|
-
resolve(socket2);
|
|
183
|
-
});
|
|
184
|
-
socket2.on("error", reject);
|
|
185
|
-
});
|
|
186
|
-
return new Session(sessionName, new import_socketConnection.SocketConnection(socket));
|
|
187
|
-
}
|
|
188
|
-
async _canConnect(sessionName) {
|
|
189
|
-
const socketPath = this._daemonSocketPath(sessionName);
|
|
190
|
-
return new Promise((resolve) => {
|
|
191
|
-
const socket = import_net.default.createConnection(socketPath, () => {
|
|
192
|
-
socket.destroy();
|
|
193
|
-
resolve(true);
|
|
194
|
-
});
|
|
195
|
-
socket.on("error", () => {
|
|
196
|
-
resolve(false);
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
_resolveSessionName(sessionName) {
|
|
201
|
-
if (sessionName)
|
|
202
|
-
return sessionName;
|
|
203
|
-
if (process.env.PLAYWRIGHT_CLI_SESSION)
|
|
204
|
-
return process.env.PLAYWRIGHT_CLI_SESSION;
|
|
205
|
-
return "default";
|
|
206
|
-
}
|
|
207
|
-
_daemonSocketPath(sessionName) {
|
|
208
|
-
const socketName = `${sessionName}.sock`;
|
|
209
|
-
if (import_os.default.platform() === "win32")
|
|
210
|
-
return `\\\\.\\pipe\\${socketDirHash}-${socketName}`;
|
|
211
|
-
return import_path.default.join(daemonSocketDir, socketName);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
async function handleSessionCommand(sessionManager, args) {
|
|
215
|
-
const subcommand = args._[0].split("-").slice(1).join("-");
|
|
216
|
-
if (subcommand === "list") {
|
|
217
|
-
const sessions = await sessionManager.list();
|
|
218
|
-
console.log("Sessions:");
|
|
219
|
-
for (const session of sessions) {
|
|
220
|
-
const liveMarker = session.live ? " (live)" : "";
|
|
221
|
-
console.log(` ${session.name}${liveMarker}`);
|
|
222
|
-
}
|
|
223
|
-
if (sessions.length === 0)
|
|
224
|
-
console.log(" (no sessions)");
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
if (subcommand === "stop") {
|
|
228
|
-
await sessionManager.stop(args._[1]);
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
if (subcommand === "stop-all") {
|
|
232
|
-
const sessions = await sessionManager.list();
|
|
233
|
-
for (const session of sessions)
|
|
234
|
-
await sessionManager.stop(session.name);
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
if (subcommand === "delete") {
|
|
238
|
-
await sessionManager.delete(args._[1]);
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
console.error(`Unknown session subcommand: ${subcommand}`);
|
|
242
|
-
process.exit(1);
|
|
243
|
-
}
|
|
244
|
-
const socketDirHash = (() => {
|
|
245
|
-
const hash = import_crypto.default.createHash("sha1");
|
|
246
|
-
hash.update(require.resolve("../../../package.json"));
|
|
247
|
-
return hash.digest("hex");
|
|
248
|
-
})();
|
|
249
|
-
const daemonSocketDir = (() => {
|
|
250
|
-
let localCacheDir;
|
|
251
|
-
if (process.platform === "linux")
|
|
252
|
-
localCacheDir = process.env.XDG_CACHE_HOME || import_path.default.join(import_os.default.homedir(), ".cache");
|
|
253
|
-
if (process.platform === "darwin")
|
|
254
|
-
localCacheDir = import_path.default.join(import_os.default.homedir(), "Library", "Caches");
|
|
255
|
-
if (process.platform === "win32")
|
|
256
|
-
localCacheDir = process.env.LOCALAPPDATA || import_path.default.join(import_os.default.homedir(), "AppData", "Local");
|
|
257
|
-
if (!localCacheDir)
|
|
258
|
-
throw new Error("Unsupported platform: " + process.platform);
|
|
259
|
-
return import_path.default.join(localCacheDir, "ms-playwright", "daemon", "daemon", socketDirHash);
|
|
260
|
-
})();
|
|
261
|
-
async function main() {
|
|
262
|
-
const argv = process.argv.slice(2);
|
|
263
|
-
const args = require("minimist")(argv);
|
|
264
|
-
const help = require("./help.json");
|
|
265
|
-
const commandName = args._[0];
|
|
266
|
-
if (args.version || args.v) {
|
|
267
|
-
console.log(packageJSON.version);
|
|
268
|
-
process.exit(0);
|
|
269
|
-
}
|
|
270
|
-
const command = help.commands[commandName];
|
|
271
|
-
if (args.help || args.h) {
|
|
272
|
-
if (command) {
|
|
273
|
-
console.log(command);
|
|
274
|
-
} else {
|
|
275
|
-
console.log("playwright-cli - run playwright mcp commands from terminal\n");
|
|
276
|
-
console.log(help.global);
|
|
277
|
-
}
|
|
278
|
-
process.exit(0);
|
|
279
|
-
}
|
|
280
|
-
if (!command) {
|
|
281
|
-
console.error(`Unknown command: ${commandName}
|
|
282
|
-
`);
|
|
283
|
-
console.log(help.global);
|
|
284
|
-
process.exit(1);
|
|
285
|
-
}
|
|
286
|
-
const sessionManager = new SessionManager();
|
|
287
|
-
if (commandName.startsWith("session")) {
|
|
288
|
-
await handleSessionCommand(sessionManager, args);
|
|
289
|
-
return;
|
|
290
|
-
}
|
|
291
|
-
await sessionManager.run(args);
|
|
292
|
-
}
|
|
293
|
-
main().catch((e) => {
|
|
4
|
+
(0, import_program.program)({ version: packageJSON.version }).catch((e) => {
|
|
294
5
|
console.error(e.message);
|
|
295
6
|
process.exit(1);
|
|
296
7
|
});
|
|
@@ -39,7 +39,7 @@ function parseCommand(command, args) {
|
|
|
39
39
|
} catch (e) {
|
|
40
40
|
throw new Error(formatZodError(e));
|
|
41
41
|
}
|
|
42
|
-
const toolName = typeof command.toolName === "function" ? command.toolName(parsedArgsObject, options) : command.toolName;
|
|
42
|
+
const toolName = typeof command.toolName === "function" ? command.toolName({ ...parsedArgsObject, ...options }) : command.toolName;
|
|
43
43
|
const toolParams = command.toolParams({ ...parsedArgsObject, ...options });
|
|
44
44
|
return { toolName, toolParams };
|
|
45
45
|
}
|
|
@@ -69,7 +69,7 @@ const reload = (0, import_command.declareCommand)({
|
|
|
69
69
|
toolParams: () => ({})
|
|
70
70
|
});
|
|
71
71
|
const pressKey = (0, import_command.declareCommand)({
|
|
72
|
-
name: "
|
|
72
|
+
name: "press",
|
|
73
73
|
description: "Press a key on the keyboard, `a`, `ArrowLeft`",
|
|
74
74
|
category: "keyboard",
|
|
75
75
|
args: import_mcpBundle.z.object({
|
|
@@ -92,7 +92,7 @@ const type = (0, import_command.declareCommand)({
|
|
|
92
92
|
toolParams: ({ text, submit }) => ({ text, submit })
|
|
93
93
|
});
|
|
94
94
|
const keydown = (0, import_command.declareCommand)({
|
|
95
|
-
name: "
|
|
95
|
+
name: "keydown",
|
|
96
96
|
description: "Press a key down on the keyboard",
|
|
97
97
|
category: "keyboard",
|
|
98
98
|
args: import_mcpBundle.z.object({
|
|
@@ -102,7 +102,7 @@ const keydown = (0, import_command.declareCommand)({
|
|
|
102
102
|
toolParams: ({ key }) => ({ key })
|
|
103
103
|
});
|
|
104
104
|
const keyup = (0, import_command.declareCommand)({
|
|
105
|
-
name: "
|
|
105
|
+
name: "keyup",
|
|
106
106
|
description: "Press a key up on the keyboard",
|
|
107
107
|
category: "keyboard",
|
|
108
108
|
args: import_mcpBundle.z.object({
|
|
@@ -112,7 +112,7 @@ const keyup = (0, import_command.declareCommand)({
|
|
|
112
112
|
toolParams: ({ key }) => ({ key })
|
|
113
113
|
});
|
|
114
114
|
const mouseMove = (0, import_command.declareCommand)({
|
|
115
|
-
name: "
|
|
115
|
+
name: "mousemove",
|
|
116
116
|
description: "Move mouse to a given position",
|
|
117
117
|
category: "mouse",
|
|
118
118
|
args: import_mcpBundle.z.object({
|
|
@@ -123,7 +123,7 @@ const mouseMove = (0, import_command.declareCommand)({
|
|
|
123
123
|
toolParams: ({ x, y }) => ({ x, y })
|
|
124
124
|
});
|
|
125
125
|
const mouseDown = (0, import_command.declareCommand)({
|
|
126
|
-
name: "
|
|
126
|
+
name: "mousedown",
|
|
127
127
|
description: "Press mouse down",
|
|
128
128
|
category: "mouse",
|
|
129
129
|
args: import_mcpBundle.z.object({
|
|
@@ -133,7 +133,7 @@ const mouseDown = (0, import_command.declareCommand)({
|
|
|
133
133
|
toolParams: ({ button }) => ({ button })
|
|
134
134
|
});
|
|
135
135
|
const mouseUp = (0, import_command.declareCommand)({
|
|
136
|
-
name: "
|
|
136
|
+
name: "mouseup",
|
|
137
137
|
description: "Press mouse up",
|
|
138
138
|
category: "mouse",
|
|
139
139
|
args: import_mcpBundle.z.object({
|
|
@@ -143,7 +143,7 @@ const mouseUp = (0, import_command.declareCommand)({
|
|
|
143
143
|
toolParams: ({ button }) => ({ button })
|
|
144
144
|
});
|
|
145
145
|
const mouseWheel = (0, import_command.declareCommand)({
|
|
146
|
-
name: "
|
|
146
|
+
name: "mousewheel",
|
|
147
147
|
description: "Scroll mouse wheel",
|
|
148
148
|
category: "mouse",
|
|
149
149
|
args: import_mcpBundle.z.object({
|
|
@@ -206,7 +206,7 @@ const fill = (0, import_command.declareCommand)({
|
|
|
206
206
|
options: import_mcpBundle.z.object({
|
|
207
207
|
submit: import_mcpBundle.z.boolean().optional().describe("Whether to submit entered text (press Enter after)")
|
|
208
208
|
}),
|
|
209
|
-
toolName: "
|
|
209
|
+
toolName: "browser_type",
|
|
210
210
|
toolParams: ({ ref, text, submit }) => ({ ref, text, submit })
|
|
211
211
|
});
|
|
212
212
|
const hover = (0, import_command.declareCommand)({
|
|
@@ -219,16 +219,16 @@ const hover = (0, import_command.declareCommand)({
|
|
|
219
219
|
toolName: "browser_hover",
|
|
220
220
|
toolParams: ({ ref }) => ({ ref })
|
|
221
221
|
});
|
|
222
|
-
const
|
|
222
|
+
const select = (0, import_command.declareCommand)({
|
|
223
223
|
name: "select",
|
|
224
224
|
description: "Select an option in a dropdown",
|
|
225
225
|
category: "core",
|
|
226
226
|
args: import_mcpBundle.z.object({
|
|
227
227
|
ref: import_mcpBundle.z.string().describe("Exact target element reference from the page snapshot"),
|
|
228
|
-
|
|
228
|
+
val: import_mcpBundle.z.string().describe("Value to select in the dropdown")
|
|
229
229
|
}),
|
|
230
230
|
toolName: "browser_select_option",
|
|
231
|
-
toolParams: ({ ref,
|
|
231
|
+
toolParams: ({ ref, val: value }) => ({ ref, values: [value] })
|
|
232
232
|
});
|
|
233
233
|
const fileUpload = (0, import_command.declareCommand)({
|
|
234
234
|
name: "upload",
|
|
@@ -280,7 +280,7 @@ const evaluate = (0, import_command.declareCommand)({
|
|
|
280
280
|
ref: import_mcpBundle.z.string().optional().describe("Exact target element reference from the page snapshot")
|
|
281
281
|
}),
|
|
282
282
|
toolName: "browser_evaluate",
|
|
283
|
-
toolParams: ({ func
|
|
283
|
+
toolParams: ({ func, ref }) => ({ function: func, ref })
|
|
284
284
|
});
|
|
285
285
|
const dialogAccept = (0, import_command.declareCommand)({
|
|
286
286
|
name: "dialog-accept",
|
|
@@ -358,10 +358,10 @@ const screenshot = (0, import_command.declareCommand)({
|
|
|
358
358
|
}),
|
|
359
359
|
options: import_mcpBundle.z.object({
|
|
360
360
|
filename: import_mcpBundle.z.string().optional().describe("File name to save the screenshot to. Defaults to `page-{timestamp}.{png|jpeg}` if not specified."),
|
|
361
|
-
|
|
361
|
+
["full-page"]: import_mcpBundle.z.boolean().optional().describe("When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport.")
|
|
362
362
|
}),
|
|
363
363
|
toolName: "browser_take_screenshot",
|
|
364
|
-
toolParams: ({ ref, filename, fullPage }) => ({ filename, ref, fullPage })
|
|
364
|
+
toolParams: ({ ref, filename, ["full-page"]: fullPage }) => ({ filename, ref, fullPage })
|
|
365
365
|
});
|
|
366
366
|
const pdfSave = (0, import_command.declareCommand)({
|
|
367
367
|
name: "pdf",
|
|
@@ -384,8 +384,8 @@ const consoleList = (0, import_command.declareCommand)({
|
|
|
384
384
|
options: import_mcpBundle.z.object({
|
|
385
385
|
clear: import_mcpBundle.z.boolean().optional().describe("Whether to clear the console list")
|
|
386
386
|
}),
|
|
387
|
-
toolName: "browser_console_messages",
|
|
388
|
-
toolParams: ({ ["min-level"]:
|
|
387
|
+
toolName: ({ clear }) => clear ? "browser_console_clear" : "browser_console_messages",
|
|
388
|
+
toolParams: ({ ["min-level"]: level, clear }) => clear ? {} : { level }
|
|
389
389
|
});
|
|
390
390
|
const networkRequests = (0, import_command.declareCommand)({
|
|
391
391
|
name: "network",
|
|
@@ -396,8 +396,8 @@ const networkRequests = (0, import_command.declareCommand)({
|
|
|
396
396
|
static: import_mcpBundle.z.boolean().optional().describe("Whether to include successful static resources like images, fonts, scripts, etc. Defaults to false."),
|
|
397
397
|
clear: import_mcpBundle.z.boolean().optional().describe("Whether to clear the network list")
|
|
398
398
|
}),
|
|
399
|
-
toolName: "browser_network_requests",
|
|
400
|
-
toolParams: ({ static: includeStatic }) =>
|
|
399
|
+
toolName: ({ clear }) => clear ? "browser_network_clear" : "browser_network_requests",
|
|
400
|
+
toolParams: ({ static: includeStatic, clear }) => clear ? {} : { includeStatic }
|
|
401
401
|
});
|
|
402
402
|
const runCode = (0, import_command.declareCommand)({
|
|
403
403
|
name: "run-code",
|
|
@@ -470,7 +470,7 @@ const commandsArray = [
|
|
|
470
470
|
fill,
|
|
471
471
|
drag,
|
|
472
472
|
hover,
|
|
473
|
-
|
|
473
|
+
select,
|
|
474
474
|
fileUpload,
|
|
475
475
|
check,
|
|
476
476
|
uncheck,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"global": "Usage: playwright-cli <command> [args] [options]\n\nCore:\n open <url> open url\n close close the page\n type <text> type text into editable element\n click <ref> [button] perform click on a web page\n dblclick <ref> [button] perform double click on a web page\n fill <ref> <text> fill text into editable element\n drag <startRef> <endRef> perform drag and drop between two elements\n hover <ref> hover over element on page\n select <ref> <
|
|
2
|
+
"global": "Usage: playwright-cli <command> [args] [options]\n\nCore:\n open <url> open url\n close close the page\n type <text> type text into editable element\n click <ref> [button] perform click on a web page\n dblclick <ref> [button] perform double click on a web page\n fill <ref> <text> fill text into editable element\n drag <startRef> <endRef> perform drag and drop between two elements\n hover <ref> hover over element on page\n select <ref> <val> select an option in a dropdown\n upload <file> upload one or multiple files\n check <ref> check a checkbox or radio button\n uncheck <ref> uncheck a checkbox or radio button\n snapshot capture page snapshot to obtain element ref\n eval <func> [ref] evaluate javascript expression on page or element\n dialog-accept [prompt] accept a dialog\n dialog-dismiss dismiss a dialog\n resize <w> <h> resize the browser window\n\nNavigation:\n go-back go back to the previous page\n go-forward go forward to the next page\n reload reload the current page\n\nKeyboard:\n press <key> press a key on the keyboard, `a`, `arrowleft`\n keydown <key> press a key down on the keyboard\n keyup <key> press a key up on the keyboard\n\nMouse:\n mousemove <x> <y> move mouse to a given position\n mousedown [button] press mouse down\n mouseup [button] press mouse up\n mousewheel <dx> <dy> scroll mouse wheel\n\nSave as:\n screenshot [ref] screenshot of the current page or element\n pdf save page as pdf\n\nTabs:\n tab-list list all tabs\n tab-new [url] create a new tab\n tab-close [index] close a browser tab\n tab-select <index> select a browser tab\n\nDevTools:\n console [min-level] list console messages\n network list all network requests since loading the page\n run-code <code> run playwright code snippet\n tracing-start start trace recording\n tracing-stop stop trace recording\n\nSessions:\n session-list list all sessions\n session-stop [name] stop session\n session-stop-all stop all sessions\n session-delete [name] delete session data",
|
|
3
3
|
"commands": {
|
|
4
4
|
"open": "playwright-cli open <url>\n\nOpen URL\n\nArguments:\n <url> the url to navigate to\nOptions:\n --headed run browser in headed mode",
|
|
5
5
|
"close": "playwright-cli close \n\nClose the page\n",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"fill": "playwright-cli fill <ref> <text>\n\nFill text into editable element\n\nArguments:\n <ref> exact target element reference from the page snapshot\n <text> text to fill into the element\nOptions:\n --submit whether to submit entered text (press enter after)",
|
|
10
10
|
"drag": "playwright-cli drag <startRef> <endRef>\n\nPerform drag and drop between two elements\n\nArguments:\n <startRef> exact source element reference from the page snapshot\n <endRef> exact target element reference from the page snapshot\nOptions:\n --headed run browser in headed mode",
|
|
11
11
|
"hover": "playwright-cli hover <ref>\n\nHover over element on page\n\nArguments:\n <ref> exact target element reference from the page snapshot",
|
|
12
|
-
"select": "playwright-cli select <ref> <
|
|
12
|
+
"select": "playwright-cli select <ref> <val>\n\nSelect an option in a dropdown\n\nArguments:\n <ref> exact target element reference from the page snapshot\n <val> value to select in the dropdown",
|
|
13
13
|
"upload": "playwright-cli upload <file>\n\nUpload one or multiple files\n\nArguments:\n <file> the absolute paths to the files to upload",
|
|
14
14
|
"check": "playwright-cli check <ref>\n\nCheck a checkbox or radio button\n\nArguments:\n <ref> exact target element reference from the page snapshot",
|
|
15
15
|
"uncheck": "playwright-cli uncheck <ref>\n\nUncheck a checkbox or radio button\n\nArguments:\n <ref> exact target element reference from the page snapshot",
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
"go-back": "playwright-cli go-back \n\nGo back to the previous page\n",
|
|
23
23
|
"go-forward": "playwright-cli go-forward \n\nGo forward to the next page\n",
|
|
24
24
|
"reload": "playwright-cli reload \n\nReload the current page\n",
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"screenshot": "playwright-cli screenshot [ref]\n\nscreenshot of the current page or element\n\nArguments:\n [ref] exact target element reference from the page snapshot.\nOptions:\n --filename file name to save the screenshot to. defaults to `page-{timestamp}.{png|jpeg}` if not specified.\n --
|
|
25
|
+
"press": "playwright-cli press <key>\n\nPress a key on the keyboard, `a`, `ArrowLeft`\n\nArguments:\n <key> name of the key to press or a character to generate, such as `arrowleft` or `a`",
|
|
26
|
+
"keydown": "playwright-cli keydown <key>\n\nPress a key down on the keyboard\n\nArguments:\n <key> name of the key to press or a character to generate, such as `arrowleft` or `a`",
|
|
27
|
+
"keyup": "playwright-cli keyup <key>\n\nPress a key up on the keyboard\n\nArguments:\n <key> name of the key to press or a character to generate, such as `arrowleft` or `a`",
|
|
28
|
+
"mousemove": "playwright-cli mousemove <x> <y>\n\nMove mouse to a given position\n\nArguments:\n <x> x coordinate\n <y> y coordinate",
|
|
29
|
+
"mousedown": "playwright-cli mousedown [button]\n\nPress mouse down\n\nArguments:\n [button] button to press, defaults to left",
|
|
30
|
+
"mouseup": "playwright-cli mouseup [button]\n\nPress mouse up\n\nArguments:\n [button] button to press, defaults to left",
|
|
31
|
+
"mousewheel": "playwright-cli mousewheel <dx> <dy>\n\nScroll mouse wheel\n\nArguments:\n <dx> y delta\n <dy> x delta",
|
|
32
|
+
"screenshot": "playwright-cli screenshot [ref]\n\nscreenshot of the current page or element\n\nArguments:\n [ref] exact target element reference from the page snapshot.\nOptions:\n --filename file name to save the screenshot to. defaults to `page-{timestamp}.{png|jpeg}` if not specified.\n --full-page when true, takes a screenshot of the full scrollable page, instead of the currently visible viewport.",
|
|
33
33
|
"pdf": "playwright-cli pdf \n\nSave page as PDF\n\nOptions:\n --filename file name to save the pdf to. defaults to `page-{timestamp}.pdf` if not specified.",
|
|
34
34
|
"tab-list": "playwright-cli tab-list \n\nList all tabs\n",
|
|
35
35
|
"tab-new": "playwright-cli tab-new [url]\n\nCreate a new tab\n\nArguments:\n [url] the url to navigate to in the new tab. if omitted, the new tab will be blank.",
|