playwright 1.57.0-alpha-2025-10-06 → 1.57.0-alpha-2025-10-08

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.
@@ -244,6 +244,7 @@ async function initVSCodeRepo() {
244
244
  cwd: "${workspaceFolder}"
245
245
  };
246
246
  await writeFile(mcpJsonPath, JSON.stringify(mcpJson, null, 2));
247
+ console.log(import_utilsBundle.colors.yellow(`${import_utilsBundle.colors.bold("Note:")} Playwright Test Agents require VSCode version 1.105+ or VSCode Insiders`));
247
248
  }
248
249
  async function initOpencodeRepo() {
249
250
  const agents = await loadAgents();
@@ -183,6 +183,7 @@ function configFromCLIOptions(cliOptions) {
183
183
  sharedBrowserContext: cliOptions.sharedBrowserContext,
184
184
  outputDir: cliOptions.outputDir,
185
185
  imageResponses: cliOptions.imageResponses,
186
+ testIdAttribute: cliOptions.testIdAttribute,
186
187
  timeouts: {
187
188
  action: cliOptions.timeoutAction,
188
189
  navigation: cliOptions.timeoutNavigation
@@ -222,6 +223,7 @@ function configFromEnv() {
222
223
  options.saveVideo = resolutionParser("--save-video", process.env.PLAYWRIGHT_MCP_SAVE_VIDEO);
223
224
  options.secrets = dotenvFileLoader(process.env.PLAYWRIGHT_MCP_SECRETS_FILE);
224
225
  options.storageState = envToString(process.env.PLAYWRIGHT_MCP_STORAGE_STATE);
226
+ options.testIdAttribute = envToString(process.env.PLAYWRIGHT_MCP_TEST_ID_ATTRIBUTE);
225
227
  options.timeoutAction = numberParser(process.env.PLAYWRIGHT_MCP_TIMEOUT_ACTION);
226
228
  options.timeoutNavigation = numberParser(process.env.PLAYWRIGHT_MCP_TIMEOUT_NAVIGATION);
227
229
  options.userAgent = envToString(process.env.PLAYWRIGHT_MCP_USER_AGENT);
@@ -35,6 +35,7 @@ module.exports = __toCommonJS(context_exports);
35
35
  var import_fs = __toESM(require("fs"));
36
36
  var import_path = __toESM(require("path"));
37
37
  var import_utilsBundle = require("playwright-core/lib/utilsBundle");
38
+ var import_playwright_core = require("playwright-core");
38
39
  var import_log = require("../log");
39
40
  var import_tab = require("./tab");
40
41
  var import_config = require("./config");
@@ -194,6 +195,8 @@ class Context {
194
195
  async _setupBrowserContext() {
195
196
  if (this._closeBrowserContextPromise)
196
197
  throw new Error("Another browser context is being closed.");
198
+ if (this.config.testIdAttribute)
199
+ import_playwright_core.selectors.setTestIdAttribute(this.config.testIdAttribute);
197
200
  const result = await this._browserContextFactory.createContext(this._clientInfo, this._abortController.signal, this._runningToolName);
198
201
  const { browserContext } = result;
199
202
  await this._setupRequestInterception(browserContext);
@@ -40,7 +40,7 @@ var import_proxyBackend = require("./sdk/proxyBackend");
40
40
  var import_browserServerBackend = require("./browser/browserServerBackend");
41
41
  var import_extensionContextFactory = require("./extension/extensionContextFactory");
42
42
  function decorateCommand(command, version) {
43
- command.option("--allowed-hosts <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.", import_config.commaSeparatedList).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("--grant-permissions <permissions...>", 'List of permissions to grant to the browser context, for example "geolocation", "clipboard-read", "clipboard-write".', import_config.commaSeparatedList).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("--init-script <path...>", "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.").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("--save-video <size>", 'Whether to save the video of the session into the output directory. For example "--save-video=800x600"', import_config.resolutionParser.bind(null, "--save-video")).option("--secrets <path>", "path to a file containing secrets in the dotenv format", import_config.dotenvFileLoader).option("--shared-browser-context", "reuse the same browser context between all connected HTTP clients.").option("--storage-state <path>", "path to the storage state file for isolated sessions.").option("--timeout-action <timeout>", "specify action timeout in milliseconds, defaults to 5000ms", import_config.numberParser).option("--timeout-navigation <timeout>", "specify navigation timeout in milliseconds, defaults to 60000ms", import_config.numberParser).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 "1280x720"', import_config.resolutionParser.bind(null, "--viewport-size")).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) => {
43
+ command.option("--allowed-hosts <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.", import_config.commaSeparatedList).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("--grant-permissions <permissions...>", 'List of permissions to grant to the browser context, for example "geolocation", "clipboard-read", "clipboard-write".', import_config.commaSeparatedList).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("--init-script <path...>", "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.").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("--save-video <size>", 'Whether to save the video of the session into the output directory. For example "--save-video=800x600"', import_config.resolutionParser.bind(null, "--save-video")).option("--secrets <path>", "path to a file containing secrets in the dotenv format", import_config.dotenvFileLoader).option("--shared-browser-context", "reuse the same browser context between all connected HTTP clients.").option("--storage-state <path>", "path to the storage state file for isolated sessions.").option("--test-id-attribute <attribute>", 'specify the attribute to use for test ids, defaults to "data-testid"').option("--timeout-action <timeout>", "specify action timeout in milliseconds, defaults to 5000ms", import_config.numberParser).option("--timeout-navigation <timeout>", "specify navigation timeout in milliseconds, defaults to 60000ms", import_config.numberParser).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 "1280x720"', import_config.resolutionParser.bind(null, "--viewport-size")).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
44
  (0, import_watchdog.setupExitWatchdog)();
45
45
  if (options.vision) {
46
46
  console.error("The --vision option is deprecated, use --caps=vision instead");
@@ -65,7 +65,7 @@ class TestServerBackend {
65
65
  this._context.initialize(rootPath, (0, import_configLoader.resolveConfigLocation)(rootPath));
66
66
  return;
67
67
  }
68
- throw new Error("No config option or MCP root path provided");
68
+ this._context.initialize(rootPath, (0, import_configLoader.resolveConfigLocation)(void 0));
69
69
  }
70
70
  async listTools() {
71
71
  return [
@@ -201,7 +201,7 @@ class TestServerDispatcher {
201
201
  async function runUIMode(configFile, configCLIOverrides, options) {
202
202
  const configLocation = (0, import_configLoader.resolveConfigLocation)(configFile);
203
203
  return await innerRunTestServer(configLocation, configCLIOverrides, options, async (server, cancelPromise) => {
204
- await (0, import_server.installRootRedirect)(server, [], { ...options, webApp: "uiMode.html" });
204
+ await (0, import_server.installRootRedirect)(server, void 0, { ...options, webApp: "uiMode.html" });
205
205
  if (options.host !== void 0 || options.port !== void 0) {
206
206
  await (0, import_server.openTraceInBrowser)(server.urlPrefix("human-readable"));
207
207
  } else {
@@ -337,14 +337,17 @@ ${(0, import_utils.stringifyStackFrames)(step.boxedStack).join("\n")}`;
337
337
  });
338
338
  this._attach(
339
339
  await (0, import_util.normalizeAndSaveAttachment)(this.outputPath(), name, options),
340
- step.group ? void 0 : step.stepId
340
+ step.stepId
341
341
  );
342
342
  step.complete({});
343
343
  }
344
344
  _attach(attachment, stepId) {
345
345
  const index = this._attachmentsPush(attachment) - 1;
346
- if (stepId) {
347
- this._stepMap.get(stepId).attachmentIndices.push(index);
346
+ let step = stepId ? this._stepMap.get(stepId) : void 0;
347
+ if (!!step?.group)
348
+ step = void 0;
349
+ if (step) {
350
+ step.attachmentIndices.push(index);
348
351
  } else {
349
352
  const stepId2 = `attach@${(0, import_utils.createGuid)()}`;
350
353
  this._tracing.appendBeforeActionForStep({ stepId: stepId2, title: `Attach ${(0, import_utils.escapeWithQuotes)(attachment.name, '"')}`, category: "test.attach", stack: [] });
@@ -356,7 +359,7 @@ ${(0, import_utils.stringifyStackFrames)(step.boxedStack).join("\n")}`;
356
359
  contentType: attachment.contentType,
357
360
  path: attachment.path,
358
361
  body: attachment.body?.toString("base64"),
359
- stepId
362
+ stepId: step?.stepId
360
363
  });
361
364
  }
362
365
  outputPath(...pathSegments) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playwright",
3
- "version": "1.57.0-alpha-2025-10-06",
3
+ "version": "1.57.0-alpha-2025-10-08",
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.57.0-alpha-2025-10-06"
67
+ "playwright-core": "1.57.0-alpha-2025-10-08"
68
68
  },
69
69
  "optionalDependencies": {
70
70
  "fsevents": "2.3.2"