playwright 1.56.0-alpha-1757023974000 → 1.56.0-alpha-2025-09-05

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.
@@ -37,7 +37,7 @@ function escapeWithQuotes(text, char = "'") {
37
37
  function quote(text) {
38
38
  return escapeWithQuotes(text, "'");
39
39
  }
40
- function formatObject(value, indent = " ") {
40
+ function formatObject(value, indent = " ", mode = "multiline") {
41
41
  if (typeof value === "string")
42
42
  return quote(value);
43
43
  if (Array.isArray(value))
@@ -49,10 +49,12 @@ function formatObject(value, indent = " ") {
49
49
  const tokens = [];
50
50
  for (const key of keys)
51
51
  tokens.push(`${key}: ${formatObject(value[key])}`);
52
- return `{
53
- ${indent}${tokens.join(`,
52
+ if (mode === "multiline")
53
+ return `{
54
+ ${tokens.join(`,
54
55
  ${indent}`)}
55
56
  }`;
57
+ return `{ ${tokens.join(", ")} }`;
56
58
  }
57
59
  return String(value);
58
60
  }
@@ -56,7 +56,8 @@ const elementSchema = import_bundle.z.object({
56
56
  });
57
57
  const clickSchema = elementSchema.extend({
58
58
  doubleClick: import_bundle.z.boolean().optional().describe("Whether to perform a double click instead of a single click"),
59
- button: import_bundle.z.enum(["left", "right", "middle"]).optional().describe("Button to click, defaults to left")
59
+ button: import_bundle.z.enum(["left", "right", "middle"]).optional().describe("Button to click, defaults to left"),
60
+ modifiers: import_bundle.z.array(import_bundle.z.enum(["Alt", "Control", "ControlOrMeta", "Meta", "Shift"])).optional().describe("Modifier keys to press")
60
61
  });
61
62
  const click = (0, import_tool.defineTabTool)({
62
63
  capability: "core",
@@ -70,17 +71,21 @@ const click = (0, import_tool.defineTabTool)({
70
71
  handle: async (tab, params, response) => {
71
72
  response.setIncludeSnapshot();
72
73
  const locator = await tab.refLocator(params);
73
- const button = params.button;
74
- const buttonAttr = button ? `{ button: '${button}' }` : "";
74
+ const options = {
75
+ button: params.button,
76
+ modifiers: params.modifiers
77
+ };
78
+ const formatted = javascript.formatObject(options, " ", "oneline");
79
+ const optionsAttr = formatted !== "{}" ? formatted : "";
75
80
  if (params.doubleClick)
76
- response.addCode(`await page.${await (0, import_utils.generateLocator)(locator)}.dblclick(${buttonAttr});`);
81
+ response.addCode(`await page.${await (0, import_utils.generateLocator)(locator)}.dblclick(${optionsAttr});`);
77
82
  else
78
- response.addCode(`await page.${await (0, import_utils.generateLocator)(locator)}.click(${buttonAttr});`);
83
+ response.addCode(`await page.${await (0, import_utils.generateLocator)(locator)}.click(${optionsAttr});`);
79
84
  await tab.waitForCompletion(async () => {
80
85
  if (params.doubleClick)
81
- await locator.dblclick({ button });
86
+ await locator.dblclick(options);
82
87
  else
83
- await locator.click({ button });
88
+ await locator.click(options);
84
89
  });
85
90
  }
86
91
  });
@@ -5,6 +5,10 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
8
12
  var __copyProps = (to, from, except, desc) => {
9
13
  if (from && typeof from === "object" || typeof from === "function") {
10
14
  for (let key of __getOwnPropNames(from))
@@ -21,6 +25,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
25
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
26
  mod
23
27
  ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var program_exports = {};
30
+ __export(program_exports, {
31
+ decorateCommand: () => decorateCommand
32
+ });
33
+ module.exports = __toCommonJS(program_exports);
24
34
  var import_utilsBundle = require("playwright-core/lib/utilsBundle");
25
35
  var mcpServer = __toESM(require("./sdk/server"));
26
36
  var import_config = require("./browser/config");
@@ -29,56 +39,57 @@ var import_browserContextFactory = require("./browser/browserContextFactory");
29
39
  var import_proxyBackend = require("./sdk/proxyBackend");
30
40
  var import_browserServerBackend = require("./browser/browserServerBackend");
31
41
  var import_extensionContextFactory = require("./extension/extensionContextFactory");
32
- const packageJSON = require("../../package.json");
33
- import_utilsBundle.program.version("Version " + packageJSON.version).name("Playwright MCP").option("--allowed-origins <origins>", "semicolon-separated list of origins to allow the browser to request. Default is to allow all.", import_config.semicolonSeparatedList).option("--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.", import_config.semicolonSeparatedList).option("--block-service-workers", "block service workers").option("--browser <browser>", "browser or chrome channel to use, possible values: chrome, firefox, webkit, msedge.").option("--caps <caps>", "comma-separated list of additional capabilities to enable, possible values: vision, pdf.", import_config.commaSeparatedList).option("--cdp-endpoint <endpoint>", "CDP endpoint to connect to.").option("--cdp-header <headers...>", "CDP headers to send with the connect request, multiple can be specified.", import_config.headerParser).option("--config <path>", "path to the configuration file.").option("--device <device>", 'device to emulate, for example: "iPhone 15"').option("--executable-path <path>", "path to the browser executable.").option("--extension", 'Connect to a running browser instance (Edge/Chrome only). Requires the "Playwright MCP Bridge" browser extension to be installed.').option("--headless", "run browser in headless mode, headed by default").option("--host <host>", "host to bind server to. Default is localhost. Use 0.0.0.0 to bind to all interfaces.").option("--ignore-https-errors", "ignore https errors").option("--isolated", "keep the browser profile in memory, do not save it to disk.").option("--image-responses <mode>", 'whether to send image responses to the client. Can be "allow" or "omit", Defaults to "allow".').option("--no-sandbox", "disable the sandbox for all process types that are normally sandboxed.").option("--output-dir <path>", "path to the directory for output files.").option("--port <port>", "port to listen on for SSE transport.").option("--proxy-bypass <bypass>", 'comma-separated domains to bypass proxy, for example ".com,chromium.org,.domain.com"').option("--proxy-server <proxy>", 'specify proxy server, for example "http://myproxy:3128" or "socks5://myproxy:8080"').option("--save-session", "Whether to save the Playwright MCP session into the output directory.").option("--save-trace", "Whether to save the Playwright Trace of the session into the output directory.").option("--secrets <path>", "path to a file containing secrets in the dotenv format", import_config.dotenvFileLoader).option("--storage-state <path>", "path to the storage state file for isolated sessions.").option("--user-agent <ua string>", "specify user agent string").option("--user-data-dir <path>", "path to the user data directory. If not specified, a temporary directory will be created.").option("--viewport-size <size>", 'specify browser viewport size in pixels, for example "1280, 720"').addOption(new import_utilsBundle.ProgramOption("--connect-tool", "Allow to switch between different browser connection methods.").hideHelp()).addOption(new import_utilsBundle.ProgramOption("--vision", "Legacy option, use --caps=vision instead").hideHelp()).action(async (options) => {
34
- setupExitWatchdog();
35
- if (options.vision) {
36
- console.error("The --vision option is deprecated, use --caps=vision instead");
37
- options.caps = "vision";
38
- }
39
- const config = await (0, import_config.resolveCLIConfig)(options);
40
- const browserContextFactory = (0, import_browserContextFactory.contextFactory)(config);
41
- const extensionContextFactory = new import_extensionContextFactory.ExtensionContextFactory(config.browser.launchOptions.channel || "chrome", config.browser.userDataDir, config.browser.launchOptions.executablePath);
42
- if (options.extension) {
43
- const serverBackendFactory = {
44
- name: "Playwright w/ extension",
45
- nameInConfig: "playwright-extension",
46
- version: packageJSON.version,
47
- create: () => new import_browserServerBackend.BrowserServerBackend(config, extensionContextFactory)
48
- };
49
- await mcpServer.start(serverBackendFactory, config.server);
50
- return;
51
- }
52
- if (options.connectTool) {
53
- const providers = [
54
- {
55
- name: "default",
56
- description: "Starts standalone browser",
57
- connect: () => mcpServer.wrapInProcess(new import_browserServerBackend.BrowserServerBackend(config, browserContextFactory))
58
- },
59
- {
60
- name: "extension",
61
- description: "Connect to a browser using the Playwright MCP extension",
62
- connect: () => mcpServer.wrapInProcess(new import_browserServerBackend.BrowserServerBackend(config, extensionContextFactory))
63
- }
64
- ];
65
- const factory2 = {
66
- name: "Playwright w/ switch",
67
- nameInConfig: "playwright-switch",
68
- version: packageJSON.version,
69
- create: () => new import_proxyBackend.ProxyBackend(providers)
42
+ function decorateCommand(command, version) {
43
+ command.option("--allowed-origins <origins>", "semicolon-separated list of origins to allow the browser to request. Default is to allow all.", import_config.semicolonSeparatedList).option("--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.", import_config.semicolonSeparatedList).option("--block-service-workers", "block service workers").option("--browser <browser>", "browser or chrome channel to use, possible values: chrome, firefox, webkit, msedge.").option("--caps <caps>", "comma-separated list of additional capabilities to enable, possible values: vision, pdf.", import_config.commaSeparatedList).option("--cdp-endpoint <endpoint>", "CDP endpoint to connect to.").option("--cdp-header <headers...>", "CDP headers to send with the connect request, multiple can be specified.", import_config.headerParser).option("--config <path>", "path to the configuration file.").option("--device <device>", 'device to emulate, for example: "iPhone 15"').option("--executable-path <path>", "path to the browser executable.").option("--extension", 'Connect to a running browser instance (Edge/Chrome only). Requires the "Playwright MCP Bridge" browser extension to be installed.').option("--headless", "run browser in headless mode, headed by default").option("--host <host>", "host to bind server to. Default is localhost. Use 0.0.0.0 to bind to all interfaces.").option("--ignore-https-errors", "ignore https errors").option("--isolated", "keep the browser profile in memory, do not save it to disk.").option("--image-responses <mode>", 'whether to send image responses to the client. Can be "allow" or "omit", Defaults to "allow".').option("--no-sandbox", "disable the sandbox for all process types that are normally sandboxed.").option("--output-dir <path>", "path to the directory for output files.").option("--port <port>", "port to listen on for SSE transport.").option("--proxy-bypass <bypass>", 'comma-separated domains to bypass proxy, for example ".com,chromium.org,.domain.com"').option("--proxy-server <proxy>", 'specify proxy server, for example "http://myproxy:3128" or "socks5://myproxy:8080"').option("--save-session", "Whether to save the Playwright MCP session into the output directory.").option("--save-trace", "Whether to save the Playwright Trace of the session into the output directory.").option("--secrets <path>", "path to a file containing secrets in the dotenv format", import_config.dotenvFileLoader).option("--storage-state <path>", "path to the storage state file for isolated sessions.").option("--user-agent <ua string>", "specify user agent string").option("--user-data-dir <path>", "path to the user data directory. If not specified, a temporary directory will be created.").option("--viewport-size <size>", 'specify browser viewport size in pixels, for example "1280, 720"').addOption(new import_utilsBundle.ProgramOption("--connect-tool", "Allow to switch between different browser connection methods.").hideHelp()).addOption(new import_utilsBundle.ProgramOption("--vision", "Legacy option, use --caps=vision instead").hideHelp()).action(async (options) => {
44
+ setupExitWatchdog();
45
+ if (options.vision) {
46
+ console.error("The --vision option is deprecated, use --caps=vision instead");
47
+ options.caps = "vision";
48
+ }
49
+ const config = await (0, import_config.resolveCLIConfig)(options);
50
+ const browserContextFactory = (0, import_browserContextFactory.contextFactory)(config);
51
+ const extensionContextFactory = new import_extensionContextFactory.ExtensionContextFactory(config.browser.launchOptions.channel || "chrome", config.browser.userDataDir, config.browser.launchOptions.executablePath);
52
+ if (options.extension) {
53
+ const serverBackendFactory = {
54
+ name: "Playwright w/ extension",
55
+ nameInConfig: "playwright-extension",
56
+ version,
57
+ create: () => new import_browserServerBackend.BrowserServerBackend(config, extensionContextFactory)
58
+ };
59
+ await mcpServer.start(serverBackendFactory, config.server);
60
+ return;
61
+ }
62
+ if (options.connectTool) {
63
+ const providers = [
64
+ {
65
+ name: "default",
66
+ description: "Starts standalone browser",
67
+ connect: () => mcpServer.wrapInProcess(new import_browserServerBackend.BrowserServerBackend(config, browserContextFactory))
68
+ },
69
+ {
70
+ name: "extension",
71
+ description: "Connect to a browser using the Playwright MCP extension",
72
+ connect: () => mcpServer.wrapInProcess(new import_browserServerBackend.BrowserServerBackend(config, extensionContextFactory))
73
+ }
74
+ ];
75
+ const factory2 = {
76
+ name: "Playwright w/ switch",
77
+ nameInConfig: "playwright-switch",
78
+ version,
79
+ create: () => new import_proxyBackend.ProxyBackend(providers)
80
+ };
81
+ await mcpServer.start(factory2, config.server);
82
+ return;
83
+ }
84
+ const factory = {
85
+ name: "Playwright",
86
+ nameInConfig: "playwright",
87
+ version,
88
+ create: () => new import_browserServerBackend.BrowserServerBackend(config, browserContextFactory)
70
89
  };
71
- await mcpServer.start(factory2, config.server);
72
- return;
73
- }
74
- const factory = {
75
- name: "Playwright",
76
- nameInConfig: "playwright",
77
- version: packageJSON.version,
78
- create: () => new import_browserServerBackend.BrowserServerBackend(config, browserContextFactory)
79
- };
80
- await mcpServer.start(factory, config.server);
81
- });
90
+ await mcpServer.start(factory, config.server);
91
+ });
92
+ }
82
93
  function setupExitWatchdog() {
83
94
  let isExiting = false;
84
95
  const handleExit = async () => {
@@ -93,4 +104,7 @@ function setupExitWatchdog() {
93
104
  process.on("SIGINT", handleExit);
94
105
  process.on("SIGTERM", handleExit);
95
106
  }
96
- void import_utilsBundle.program.parseAsync(process.argv);
107
+ // Annotate the CommonJS export names for ESM import in node:
108
+ 0 && (module.exports = {
109
+ decorateCommand
110
+ });
package/lib/program.js CHANGED
@@ -48,6 +48,8 @@ var import_testRunner = require("./runner/testRunner");
48
48
  var import_reporters = require("./runner/reporters");
49
49
  var import_exports = require("./mcp/sdk/exports");
50
50
  var import_testBackend = require("./mcp/test/testBackend");
51
+ var import_program3 = require("./mcp/program");
52
+ const packageJSON = require("../package.json");
51
53
  function addTestCommand(program3) {
52
54
  const command = program3.command("test [test-filter...]");
53
55
  command.description("run tests with Playwright Test");
@@ -141,8 +143,13 @@ Arguments [dir]:
141
143
  Examples:
142
144
  $ npx playwright merge-reports playwright-report`);
143
145
  }
144
- function addMCPServerCommand(program3) {
146
+ function addBrowserMCPServerCommand(program3) {
145
147
  const command = program3.command("run-mcp-server", { hidden: true });
148
+ command.description("Interact with the browser over MCP");
149
+ (0, import_program3.decorateCommand)(command, packageJSON.version);
150
+ }
151
+ function addTestMCPServerCommand(program3) {
152
+ const command = program3.command("run-test-mcp-server", { hidden: true });
146
153
  command.description("Interact with the test runner over MCP");
147
154
  command.option("-c, --config <file>", `Configuration file, or a test directory with optional "playwright.config.{m,c}?{js,ts}"`);
148
155
  command.option("--host <host>", "host to bind server to. Default is localhost. Use 0.0.0.0 to bind to all interfaces.");
@@ -152,7 +159,7 @@ function addMCPServerCommand(program3) {
152
159
  const backendFactory = {
153
160
  name: "Playwright Test Runner",
154
161
  nameInConfig: "playwright-test-runner",
155
- version: "0.0.0",
162
+ version: packageJSON.version,
156
163
  create: () => new import_testBackend.TestServerBackend(resolvedLocation, { muteConsole: options.port === void 0 })
157
164
  };
158
165
  const mdbUrl = await (0, import_exports.runMainBackend)(backendFactory, { port: options.port === void 0 ? void 0 : +options.port });
@@ -359,7 +366,8 @@ addTestCommand(import_program.program);
359
366
  addShowReportCommand(import_program.program);
360
367
  addMergeReportsCommand(import_program.program);
361
368
  addClearCacheCommand(import_program.program);
362
- addMCPServerCommand(import_program.program);
369
+ addBrowserMCPServerCommand(import_program.program);
370
+ addTestMCPServerCommand(import_program.program);
363
371
  addDevServerCommand(import_program.program);
364
372
  addTestServerCommand(import_program.program);
365
373
  // Annotate the CommonJS export names for ESM import in node:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playwright",
3
- "version": "1.56.0-alpha-1757023974000",
3
+ "version": "1.56.0-alpha-2025-09-05",
4
4
  "description": "A high-level API to automate web browsers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -64,7 +64,7 @@
64
64
  },
65
65
  "license": "Apache-2.0",
66
66
  "dependencies": {
67
- "playwright-core": "1.56.0-alpha-1757023974000"
67
+ "playwright-core": "1.56.0-alpha-2025-09-05"
68
68
  },
69
69
  "optionalDependencies": {
70
70
  "fsevents": "2.3.2"