playwright 1.56.0-alpha-2025-09-05 → 1.56.0-alpha-1757090131000
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.
|
@@ -38,7 +38,6 @@ var import_path = __toESM(require("path"));
|
|
|
38
38
|
var playwright = __toESM(require("playwright-core"));
|
|
39
39
|
var import_registry = require("playwright-core/lib/server/registry/index");
|
|
40
40
|
var import_server = require("playwright-core/lib/server");
|
|
41
|
-
var import_processUtils = require("./processUtils");
|
|
42
41
|
var import_log = require("../log");
|
|
43
42
|
var import_config = require("./config");
|
|
44
43
|
function contextFactory(config) {
|
|
@@ -156,27 +155,27 @@ class PersistentContextFactory {
|
|
|
156
155
|
(0, import_log.testDebug)("lock user data dir", userDataDir);
|
|
157
156
|
const browserType = playwright[this.config.browser.browserName];
|
|
158
157
|
for (let i = 0; i < 5; i++) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
throw error;
|
|
158
|
+
try {
|
|
159
|
+
const browserContext = await browserType.launchPersistentContext(userDataDir, {
|
|
160
|
+
tracesDir,
|
|
161
|
+
...this.config.browser.launchOptions,
|
|
162
|
+
...this.config.browser.contextOptions,
|
|
163
|
+
handleSIGINT: false,
|
|
164
|
+
handleSIGTERM: false
|
|
165
|
+
});
|
|
166
|
+
const close = () => this._closeBrowserContext(browserContext, userDataDir);
|
|
167
|
+
return { browserContext, close };
|
|
168
|
+
} catch (error) {
|
|
169
|
+
if (error.message.includes("Executable doesn't exist"))
|
|
170
|
+
throw new Error(`Browser specified in your config is not installed. Either install it (likely) or change the config.`);
|
|
171
|
+
if (error.message.includes("ProcessSingleton") || error.message.includes("Invalid URL")) {
|
|
172
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
throw error;
|
|
176
|
+
}
|
|
179
177
|
}
|
|
178
|
+
throw new Error(`Browser is already in use for ${userDataDir}, use --isolated to run multiple instances of the same browser`);
|
|
180
179
|
}
|
|
181
180
|
async _closeBrowserContext(browserContext, userDataDir) {
|
|
182
181
|
(0, import_log.testDebug)("close browser context (persistent)");
|
|
@@ -195,12 +194,6 @@ class PersistentContextFactory {
|
|
|
195
194
|
return result;
|
|
196
195
|
}
|
|
197
196
|
}
|
|
198
|
-
async function alreadyRunning(config, browserType, userDataDir) {
|
|
199
|
-
const execPath = config.browser.launchOptions.executablePath ?? (0, import_processUtils.getBrowserExecPath)(config.browser.launchOptions.channel ?? browserType.name());
|
|
200
|
-
if (!execPath)
|
|
201
|
-
return false;
|
|
202
|
-
return !!(0, import_processUtils.findBrowserProcess)(execPath, userDataDir);
|
|
203
|
-
}
|
|
204
197
|
async function injectCdpPort(browserConfig) {
|
|
205
198
|
if (browserConfig.browserName === "chromium")
|
|
206
199
|
browserConfig.launchOptions.cdpPort = await findFreePort();
|
|
@@ -32,6 +32,7 @@ __export(config_exports, {
|
|
|
32
32
|
configFromCLIOptions: () => configFromCLIOptions,
|
|
33
33
|
dotenvFileLoader: () => dotenvFileLoader,
|
|
34
34
|
headerParser: () => headerParser,
|
|
35
|
+
numberParser: () => numberParser,
|
|
35
36
|
outputFile: () => outputFile,
|
|
36
37
|
resolveCLIConfig: () => resolveCLIConfig,
|
|
37
38
|
resolveConfig: () => resolveConfig,
|
|
@@ -60,7 +61,11 @@ const defaultConfig = {
|
|
|
60
61
|
blockedOrigins: void 0
|
|
61
62
|
},
|
|
62
63
|
server: {},
|
|
63
|
-
saveTrace: false
|
|
64
|
+
saveTrace: false,
|
|
65
|
+
timeouts: {
|
|
66
|
+
action: 5e3,
|
|
67
|
+
navigation: 6e4
|
|
68
|
+
}
|
|
64
69
|
};
|
|
65
70
|
async function resolveConfig(config) {
|
|
66
71
|
return mergeConfig(defaultConfig, config);
|
|
@@ -156,7 +161,11 @@ function configFromCLIOptions(cliOptions) {
|
|
|
156
161
|
saveTrace: cliOptions.saveTrace,
|
|
157
162
|
secrets: cliOptions.secrets,
|
|
158
163
|
outputDir: cliOptions.outputDir,
|
|
159
|
-
imageResponses: cliOptions.imageResponses
|
|
164
|
+
imageResponses: cliOptions.imageResponses,
|
|
165
|
+
timeouts: {
|
|
166
|
+
action: cliOptions.timeoutAction,
|
|
167
|
+
navigation: cliOptions.timeoutNavigation
|
|
168
|
+
}
|
|
160
169
|
};
|
|
161
170
|
return result;
|
|
162
171
|
}
|
|
@@ -180,12 +189,14 @@ function configFromEnv() {
|
|
|
180
189
|
options.imageResponses = "omit";
|
|
181
190
|
options.sandbox = envToBoolean(process.env.PLAYWRIGHT_MCP_SANDBOX);
|
|
182
191
|
options.outputDir = envToString(process.env.PLAYWRIGHT_MCP_OUTPUT_DIR);
|
|
183
|
-
options.port =
|
|
192
|
+
options.port = numberParser(process.env.PLAYWRIGHT_MCP_PORT);
|
|
184
193
|
options.proxyBypass = envToString(process.env.PLAYWRIGHT_MCP_PROXY_BYPASS);
|
|
185
194
|
options.proxyServer = envToString(process.env.PLAYWRIGHT_MCP_PROXY_SERVER);
|
|
186
195
|
options.saveTrace = envToBoolean(process.env.PLAYWRIGHT_MCP_SAVE_TRACE);
|
|
187
196
|
options.secrets = dotenvFileLoader(process.env.PLAYWRIGHT_MCP_SECRETS_FILE);
|
|
188
197
|
options.storageState = envToString(process.env.PLAYWRIGHT_MCP_STORAGE_STATE);
|
|
198
|
+
options.timeoutAction = numberParser(process.env.PLAYWRIGHT_MCP_TIMEOUT_ACTION);
|
|
199
|
+
options.timeoutNavigation = numberParser(process.env.PLAYWRIGHT_MCP_TIMEOUT_NAVIGATION);
|
|
189
200
|
options.userAgent = envToString(process.env.PLAYWRIGHT_MCP_USER_AGENT);
|
|
190
201
|
options.userDataDir = envToString(process.env.PLAYWRIGHT_MCP_USER_DATA_DIR);
|
|
191
202
|
options.viewportSize = envToString(process.env.PLAYWRIGHT_MCP_VIEWPORT_SIZE);
|
|
@@ -240,6 +251,10 @@ function mergeConfig(base, overrides) {
|
|
|
240
251
|
server: {
|
|
241
252
|
...pickDefined(base.server),
|
|
242
253
|
...pickDefined(overrides.server)
|
|
254
|
+
},
|
|
255
|
+
timeouts: {
|
|
256
|
+
...pickDefined(base.timeouts),
|
|
257
|
+
...pickDefined(overrides.timeouts)
|
|
243
258
|
}
|
|
244
259
|
};
|
|
245
260
|
}
|
|
@@ -258,6 +273,11 @@ function dotenvFileLoader(value) {
|
|
|
258
273
|
return void 0;
|
|
259
274
|
return import_utilsBundle.dotenv.parse(import_fs.default.readFileSync(value, "utf8"));
|
|
260
275
|
}
|
|
276
|
+
function numberParser(value) {
|
|
277
|
+
if (!value)
|
|
278
|
+
return void 0;
|
|
279
|
+
return +value;
|
|
280
|
+
}
|
|
261
281
|
function headerParser(arg, previous) {
|
|
262
282
|
if (!arg)
|
|
263
283
|
return previous || {};
|
|
@@ -266,11 +286,6 @@ function headerParser(arg, previous) {
|
|
|
266
286
|
result[name] = value;
|
|
267
287
|
return result;
|
|
268
288
|
}
|
|
269
|
-
function envToNumber(value) {
|
|
270
|
-
if (!value)
|
|
271
|
-
return void 0;
|
|
272
|
-
return +value;
|
|
273
|
-
}
|
|
274
289
|
function envToBoolean(value) {
|
|
275
290
|
if (value === "true" || value === "1")
|
|
276
291
|
return true;
|
|
@@ -294,6 +309,7 @@ function sanitizeForFilePath(s) {
|
|
|
294
309
|
configFromCLIOptions,
|
|
295
310
|
dotenvFileLoader,
|
|
296
311
|
headerParser,
|
|
312
|
+
numberParser,
|
|
297
313
|
outputFile,
|
|
298
314
|
resolveCLIConfig,
|
|
299
315
|
resolveConfig,
|
package/lib/mcp/browser/tab.js
CHANGED
|
@@ -58,8 +58,8 @@ class Tab extends import_events.EventEmitter {
|
|
|
58
58
|
page.on("download", (download) => {
|
|
59
59
|
void this._downloadStarted(download);
|
|
60
60
|
});
|
|
61
|
-
page.setDefaultNavigationTimeout(
|
|
62
|
-
page.setDefaultTimeout(
|
|
61
|
+
page.setDefaultNavigationTimeout(this.context.config.timeouts.navigation);
|
|
62
|
+
page.setDefaultTimeout(this.context.config.timeouts.action);
|
|
63
63
|
page[tabSymbol] = this;
|
|
64
64
|
}
|
|
65
65
|
static forPage(page) {
|
package/lib/mcp/program.js
CHANGED
|
@@ -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-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) => {
|
|
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("--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 "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
44
|
setupExitWatchdog();
|
|
45
45
|
if (options.vision) {
|
|
46
46
|
console.error("The --vision option is deprecated, use --caps=vision instead");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "playwright",
|
|
3
|
-
"version": "1.56.0-alpha-
|
|
3
|
+
"version": "1.56.0-alpha-1757090131000",
|
|
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-
|
|
67
|
+
"playwright-core": "1.56.0-alpha-1757090131000"
|
|
68
68
|
},
|
|
69
69
|
"optionalDependencies": {
|
|
70
70
|
"fsevents": "2.3.2"
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
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 __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var processUtils_exports = {};
|
|
30
|
-
__export(processUtils_exports, {
|
|
31
|
-
findBrowserProcess: () => findBrowserProcess,
|
|
32
|
-
getBrowserExecPath: () => getBrowserExecPath
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(processUtils_exports);
|
|
35
|
-
var import_child_process = __toESM(require("child_process"));
|
|
36
|
-
var import_registry = require("playwright-core/lib/server/registry/index");
|
|
37
|
-
function getBrowserExecPath(channelOrName) {
|
|
38
|
-
return import_registry.registry.findExecutable(channelOrName)?.executablePath("javascript");
|
|
39
|
-
}
|
|
40
|
-
function findBrowserProcess(execPath, arg) {
|
|
41
|
-
switch (process.platform) {
|
|
42
|
-
case "darwin":
|
|
43
|
-
return findProcessMacos(execPath, arg);
|
|
44
|
-
case "linux":
|
|
45
|
-
return findProcessLinux(execPath, arg);
|
|
46
|
-
case "win32":
|
|
47
|
-
return findProcessWindows(execPath, arg);
|
|
48
|
-
default:
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
function findProcessLinux(execPath, arg) {
|
|
53
|
-
const psResult = import_child_process.default.spawnSync("ps", ["-eo", "pid=,args="]);
|
|
54
|
-
return findMatchingLine(psResult.stdout.toString(), execPath, arg);
|
|
55
|
-
}
|
|
56
|
-
function findProcessMacos(execPath, arg) {
|
|
57
|
-
const psResult = import_child_process.default.spawnSync("ps", ["-axo", "pid=,command="]);
|
|
58
|
-
return findMatchingLine(psResult.stdout.toString(), execPath, arg);
|
|
59
|
-
}
|
|
60
|
-
function findProcessWindows(execPath, arg) {
|
|
61
|
-
const filter = `$_.ExecutablePath -eq '${execPath}' -and $_.CommandLine.Contains('${arg}') -and $_.CommandLine -notmatch '--type'`;
|
|
62
|
-
const ps = import_child_process.default.spawnSync(
|
|
63
|
-
"powershell.exe",
|
|
64
|
-
[
|
|
65
|
-
"-NoProfile",
|
|
66
|
-
"-Command",
|
|
67
|
-
`Get-CimInstance Win32_Process | Where-Object { ${filter} } | Select-Object -Property ProcessId,CommandLine | ForEach-Object { "$($_.ProcessId) $($_.CommandLine)" }`
|
|
68
|
-
],
|
|
69
|
-
{ encoding: "utf8" }
|
|
70
|
-
);
|
|
71
|
-
if (ps.status !== 0)
|
|
72
|
-
return null;
|
|
73
|
-
return findMatchingLine(ps.stdout.toString(), execPath, arg);
|
|
74
|
-
}
|
|
75
|
-
function findMatchingLine(psOutput, execPath, arg) {
|
|
76
|
-
const lines = psOutput.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
77
|
-
for (const line of lines) {
|
|
78
|
-
if (line.includes(execPath) && line.includes(arg) && !line.includes("--type"))
|
|
79
|
-
return line;
|
|
80
|
-
}
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
84
|
-
0 && (module.exports = {
|
|
85
|
-
findBrowserProcess,
|
|
86
|
-
getBrowserExecPath
|
|
87
|
-
});
|