@one2x/playwright 1.57.0-alpha.3 → 1.57.0-alpha.5
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/mcp/browser/config.js +4 -1
- package/lib/mcp/browser/response.js +13 -0
- package/lib/mcp/browser/tab.js +1 -1
- package/lib/mcp/browser/tools/actionRetry.js +7 -1
- package/lib/mcp/browser/tools/evaluate.js +1 -0
- package/lib/mcp/browser/tools/form.js +7 -0
- package/lib/mcp/browser/tools/keyboard.js +2 -0
- package/lib/mcp/browser/tools/mouse.js +2 -0
- package/lib/mcp/browser/tools/navigate.js +2 -0
- package/lib/mcp/browser/tools/snapshot.js +28 -0
- package/lib/mcp/browser/tools/tabs.js +2 -0
- package/lib/mcp/browser/tools/utils.js +4 -8
- package/lib/mcp/browser/tools/wait.js +1 -0
- package/lib/mcp/program.js +1 -1
- package/package.json +2 -2
|
@@ -166,7 +166,8 @@ function configFromCLIOptions(cliOptions) {
|
|
|
166
166
|
contextOptions,
|
|
167
167
|
cdpEndpoint: cliOptions.cdpEndpoint,
|
|
168
168
|
cdpHeaders: cliOptions.cdpHeader,
|
|
169
|
-
initScript: cliOptions.initScript
|
|
169
|
+
initScript: cliOptions.initScript,
|
|
170
|
+
autoScreenshot: cliOptions.autoScreenshot
|
|
170
171
|
},
|
|
171
172
|
server: {
|
|
172
173
|
port: cliOptions.port,
|
|
@@ -197,6 +198,7 @@ function configFromEnv() {
|
|
|
197
198
|
const options = {};
|
|
198
199
|
options.allowedHosts = commaSeparatedList(process.env.PLAYWRIGHT_MCP_ALLOWED_HOSTNAMES);
|
|
199
200
|
options.allowedOrigins = semicolonSeparatedList(process.env.PLAYWRIGHT_MCP_ALLOWED_ORIGINS);
|
|
201
|
+
options.autoScreenshot = envToBoolean(process.env.PLAYWRIGHT_MCP_AUTO_SCREENSHOT);
|
|
200
202
|
options.blockedOrigins = semicolonSeparatedList(process.env.PLAYWRIGHT_MCP_BLOCKED_ORIGINS);
|
|
201
203
|
options.blockServiceWorkers = envToBoolean(process.env.PLAYWRIGHT_MCP_BLOCK_SERVICE_WORKERS);
|
|
202
204
|
options.browser = envToString(process.env.PLAYWRIGHT_MCP_BROWSER);
|
|
@@ -374,6 +376,7 @@ function configFromURLParams(url) {
|
|
|
374
376
|
const getParam = (name) => url.searchParams.get(name) || void 0;
|
|
375
377
|
const options = {};
|
|
376
378
|
options.allowedOrigins = semicolonSeparatedList(getParam("allowed-origins"));
|
|
379
|
+
options.autoScreenshot = queryToBoolean(getParam("auto-screenshot"));
|
|
377
380
|
options.blockedOrigins = semicolonSeparatedList(getParam("blocked-origins"));
|
|
378
381
|
options.blockServiceWorkers = queryToBoolean(getParam("block-service-workers"));
|
|
379
382
|
options.browser = getParam("browser");
|
|
@@ -25,6 +25,7 @@ __export(response_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(response_exports);
|
|
26
26
|
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
|
|
27
27
|
var import_tab = require("./tab");
|
|
28
|
+
var import_screenshot = require("./tools/screenshot");
|
|
28
29
|
const requestDebug = (0, import_utilsBundle.debug)("pw:mcp:request");
|
|
29
30
|
class Response {
|
|
30
31
|
constructor(context, toolName, toolArgs) {
|
|
@@ -33,6 +34,7 @@ class Response {
|
|
|
33
34
|
this._images = [];
|
|
34
35
|
this._includeSnapshot = "none";
|
|
35
36
|
this._includeTabs = false;
|
|
37
|
+
this._includeAutoScreenshot = false;
|
|
36
38
|
this._context = context;
|
|
37
39
|
this.toolName = toolName;
|
|
38
40
|
this.toolArgs = toolArgs;
|
|
@@ -65,6 +67,9 @@ class Response {
|
|
|
65
67
|
setIncludeSnapshot(full) {
|
|
66
68
|
this._includeSnapshot = full ?? "incremental";
|
|
67
69
|
}
|
|
70
|
+
setIncludeAutoScreenshot() {
|
|
71
|
+
this._includeAutoScreenshot = true;
|
|
72
|
+
}
|
|
68
73
|
setIncludeTabs() {
|
|
69
74
|
this._includeTabs = true;
|
|
70
75
|
}
|
|
@@ -73,6 +78,14 @@ class Response {
|
|
|
73
78
|
this._tabSnapshot = await this._context.currentTabOrDie().captureSnapshot(this._includeSnapshot);
|
|
74
79
|
for (const tab of this._context.tabs())
|
|
75
80
|
await tab.updateTitle();
|
|
81
|
+
if (this._includeAutoScreenshot && this._context.config.browser?.autoScreenshot && this._context.config.imageResponses !== "omit" && this._context.currentTab()) {
|
|
82
|
+
const tab = this._context.currentTabOrDie();
|
|
83
|
+
await tab.page.waitForLoadState("networkidle", { timeout: 1e3 }).catch(() => {
|
|
84
|
+
});
|
|
85
|
+
const buffer = await tab.page.screenshot({ type: "jpeg", quality: 90, scale: "css" });
|
|
86
|
+
const scaledBuffer = (0, import_screenshot.scaleImageToFitMessage)(buffer, "jpeg");
|
|
87
|
+
this.addImage({ contentType: "image/jpeg", data: scaledBuffer });
|
|
88
|
+
}
|
|
76
89
|
}
|
|
77
90
|
tabSnapshot() {
|
|
78
91
|
return this._tabSnapshot;
|
package/lib/mcp/browser/tab.js
CHANGED
|
@@ -147,7 +147,7 @@ class Tab extends import_events.EventEmitter {
|
|
|
147
147
|
this._clearCollectedArtifacts();
|
|
148
148
|
const downloadEvent = (0, import_utils2.callOnPageNoTrace)(this.page, (page) => page.waitForEvent("download").catch(import_log.logUnhandledError));
|
|
149
149
|
try {
|
|
150
|
-
await this.page.goto(url, { waitUntil: "domcontentloaded" });
|
|
150
|
+
await this.page.goto(url, { waitUntil: this.context.config.browser?.autoScreenshot ? "load" : "domcontentloaded" });
|
|
151
151
|
} catch (_e) {
|
|
152
152
|
const e = _e;
|
|
153
153
|
const mightBeDownload = e.message.includes("net::ERR_ABORTED") || e.message.includes("Download is starting");
|
|
@@ -27,9 +27,15 @@ async function retryWithAllowIntercept(action, options) {
|
|
|
27
27
|
return { usedAllowIntercept: false };
|
|
28
28
|
} catch (error) {
|
|
29
29
|
if (error?.message?.includes("intercepts pointer events")) {
|
|
30
|
+
let interceptorInfo;
|
|
31
|
+
const errorMessage = error.message || "";
|
|
32
|
+
const interceptorMatch = errorMessage.match(/(.+?)\s+intercepts pointer events/);
|
|
33
|
+
if (interceptorMatch) {
|
|
34
|
+
interceptorInfo = interceptorMatch[1].trim().replace(/^\s*[\d\-:.]+\s*/, "");
|
|
35
|
+
}
|
|
30
36
|
const optionsWithAllowIntercept = { ...options, allowIntercept: true };
|
|
31
37
|
await action(optionsWithAllowIntercept);
|
|
32
|
-
return { usedAllowIntercept: true };
|
|
38
|
+
return { usedAllowIntercept: true, interceptorInfo };
|
|
33
39
|
}
|
|
34
40
|
throw error;
|
|
35
41
|
}
|
|
@@ -62,6 +62,7 @@ const evaluate = (0, import_tool.defineTabTool)({
|
|
|
62
62
|
const result = await receiver._evaluateFunction(params.function);
|
|
63
63
|
response.addResult(JSON.stringify(result, null, 2) || "undefined");
|
|
64
64
|
});
|
|
65
|
+
response.setIncludeAutoScreenshot();
|
|
65
66
|
}
|
|
66
67
|
});
|
|
67
68
|
var evaluate_default = [
|
|
@@ -65,6 +65,12 @@ const fillForm = (0, import_tool.defineTabTool)({
|
|
|
65
65
|
async (opts) => await locator.setChecked(field.value === "true", opts),
|
|
66
66
|
{}
|
|
67
67
|
);
|
|
68
|
+
if (result.usedAllowIntercept) {
|
|
69
|
+
response.addResult(`\u26A0\uFE0F Previous attempt failed: ${field.type} was intercepted`);
|
|
70
|
+
if (result.interceptorInfo)
|
|
71
|
+
response.addResult(` Intercepting element: ${result.interceptorInfo}`);
|
|
72
|
+
response.addResult("\u2713 Retried with allowIntercept: true and succeeded");
|
|
73
|
+
}
|
|
68
74
|
const optionsAttr = result.usedAllowIntercept ? ", { allowIntercept: true }" : "";
|
|
69
75
|
response.addCode(`${locatorSource}.setChecked(${field.value}${optionsAttr});`);
|
|
70
76
|
} else if (field.type === "combobox") {
|
|
@@ -72,6 +78,7 @@ const fillForm = (0, import_tool.defineTabTool)({
|
|
|
72
78
|
response.addCode(`${locatorSource}.selectOption(${codegen.quote(field.value)});`);
|
|
73
79
|
}
|
|
74
80
|
}
|
|
81
|
+
response.setIncludeAutoScreenshot();
|
|
75
82
|
}
|
|
76
83
|
});
|
|
77
84
|
var form_default = [
|
|
@@ -42,6 +42,7 @@ const pressKey = (0, import_tool.defineTabTool)({
|
|
|
42
42
|
await tab.waitForCompletion(async () => {
|
|
43
43
|
await tab.page.keyboard.press(params.key);
|
|
44
44
|
});
|
|
45
|
+
response.setIncludeAutoScreenshot();
|
|
45
46
|
}
|
|
46
47
|
});
|
|
47
48
|
const typeSchema = import_snapshot.elementSchema.extend({
|
|
@@ -76,6 +77,7 @@ const type = (0, import_tool.defineTabTool)({
|
|
|
76
77
|
await locator.press("Enter");
|
|
77
78
|
}
|
|
78
79
|
});
|
|
80
|
+
response.setIncludeAutoScreenshot();
|
|
79
81
|
}
|
|
80
82
|
});
|
|
81
83
|
var keyboard_default = [
|
|
@@ -69,6 +69,7 @@ const mouseClick = (0, import_tool.defineTabTool)({
|
|
|
69
69
|
await tab.page.mouse.down();
|
|
70
70
|
await tab.page.mouse.up();
|
|
71
71
|
});
|
|
72
|
+
response.setIncludeAutoScreenshot();
|
|
72
73
|
}
|
|
73
74
|
});
|
|
74
75
|
const mouseDrag = (0, import_tool.defineTabTool)({
|
|
@@ -98,6 +99,7 @@ const mouseDrag = (0, import_tool.defineTabTool)({
|
|
|
98
99
|
await tab.page.mouse.move(params.endX, params.endY);
|
|
99
100
|
await tab.page.mouse.up();
|
|
100
101
|
});
|
|
102
|
+
response.setIncludeAutoScreenshot();
|
|
101
103
|
}
|
|
102
104
|
});
|
|
103
105
|
var mouse_default = [
|
|
@@ -39,6 +39,7 @@ const navigate = (0, import_tool.defineTool)({
|
|
|
39
39
|
await tab.navigate(params.url);
|
|
40
40
|
response.setIncludeSnapshot();
|
|
41
41
|
response.addCode(`await page.goto('${params.url}');`);
|
|
42
|
+
response.setIncludeAutoScreenshot();
|
|
42
43
|
}
|
|
43
44
|
});
|
|
44
45
|
const goBack = (0, import_tool.defineTabTool)({
|
|
@@ -54,6 +55,7 @@ const goBack = (0, import_tool.defineTabTool)({
|
|
|
54
55
|
await tab.page.goBack();
|
|
55
56
|
response.setIncludeSnapshot();
|
|
56
57
|
response.addCode(`await page.goBack();`);
|
|
58
|
+
response.setIncludeAutoScreenshot();
|
|
57
59
|
}
|
|
58
60
|
});
|
|
59
61
|
var navigate_default = [
|
|
@@ -77,6 +77,7 @@ const click = (0, import_tool.defineTabTool)({
|
|
|
77
77
|
modifiers: params.modifiers
|
|
78
78
|
};
|
|
79
79
|
let usedAllowIntercept = false;
|
|
80
|
+
let interceptorInfo;
|
|
80
81
|
await tab.waitForCompletion(async () => {
|
|
81
82
|
const result = await (0, import_actionRetry.retryWithAllowIntercept)(
|
|
82
83
|
async (opts) => {
|
|
@@ -88,7 +89,14 @@ const click = (0, import_tool.defineTabTool)({
|
|
|
88
89
|
options
|
|
89
90
|
);
|
|
90
91
|
usedAllowIntercept = result.usedAllowIntercept;
|
|
92
|
+
interceptorInfo = result.interceptorInfo;
|
|
91
93
|
});
|
|
94
|
+
if (usedAllowIntercept) {
|
|
95
|
+
response.addResult("\u26A0\uFE0F Previous attempt failed: element was intercepted");
|
|
96
|
+
if (interceptorInfo)
|
|
97
|
+
response.addResult(` Intercepting element: ${interceptorInfo}`);
|
|
98
|
+
response.addResult("\u2713 Retried with allowIntercept: true and succeeded");
|
|
99
|
+
}
|
|
92
100
|
const finalOptions = usedAllowIntercept ? { ...options, allowIntercept: true } : options;
|
|
93
101
|
const formatted = javascript.formatObject(finalOptions, " ", "oneline");
|
|
94
102
|
const optionsAttr = formatted !== "{}" ? formatted : "";
|
|
@@ -96,6 +104,7 @@ const click = (0, import_tool.defineTabTool)({
|
|
|
96
104
|
response.addCode(`await page.${resolved}.dblclick(${optionsAttr});`);
|
|
97
105
|
else
|
|
98
106
|
response.addCode(`await page.${resolved}.click(${optionsAttr});`);
|
|
107
|
+
response.setIncludeAutoScreenshot();
|
|
99
108
|
}
|
|
100
109
|
});
|
|
101
110
|
const drag = (0, import_tool.defineTabTool)({
|
|
@@ -119,15 +128,24 @@ const drag = (0, import_tool.defineTabTool)({
|
|
|
119
128
|
{ ref: params.endRef, element: params.endElement }
|
|
120
129
|
]);
|
|
121
130
|
let usedAllowIntercept = false;
|
|
131
|
+
let interceptorInfo;
|
|
122
132
|
await tab.waitForCompletion(async () => {
|
|
123
133
|
const result = await (0, import_actionRetry.retryWithAllowIntercept)(
|
|
124
134
|
async (opts) => await start.locator.dragTo(end.locator, opts),
|
|
125
135
|
{}
|
|
126
136
|
);
|
|
127
137
|
usedAllowIntercept = result.usedAllowIntercept;
|
|
138
|
+
interceptorInfo = result.interceptorInfo;
|
|
128
139
|
});
|
|
140
|
+
if (usedAllowIntercept) {
|
|
141
|
+
response.addResult("\u26A0\uFE0F Previous attempt failed: element was intercepted");
|
|
142
|
+
if (interceptorInfo)
|
|
143
|
+
response.addResult(` Intercepting element: ${interceptorInfo}`);
|
|
144
|
+
response.addResult("\u2713 Retried with allowIntercept: true and succeeded");
|
|
145
|
+
}
|
|
129
146
|
const optionsAttr = usedAllowIntercept ? ", { allowIntercept: true }" : "";
|
|
130
147
|
response.addCode(`await page.${start.resolved}.dragTo(page.${end.resolved}${optionsAttr});`);
|
|
148
|
+
response.setIncludeAutoScreenshot();
|
|
131
149
|
}
|
|
132
150
|
});
|
|
133
151
|
const hover = (0, import_tool.defineTabTool)({
|
|
@@ -143,15 +161,24 @@ const hover = (0, import_tool.defineTabTool)({
|
|
|
143
161
|
response.setIncludeSnapshot();
|
|
144
162
|
const { locator, resolved } = await tab.refLocator(params);
|
|
145
163
|
let usedAllowIntercept = false;
|
|
164
|
+
let interceptorInfo;
|
|
146
165
|
await tab.waitForCompletion(async () => {
|
|
147
166
|
const result = await (0, import_actionRetry.retryWithAllowIntercept)(
|
|
148
167
|
async (opts) => await locator.hover(opts),
|
|
149
168
|
{}
|
|
150
169
|
);
|
|
151
170
|
usedAllowIntercept = result.usedAllowIntercept;
|
|
171
|
+
interceptorInfo = result.interceptorInfo;
|
|
152
172
|
});
|
|
173
|
+
if (usedAllowIntercept) {
|
|
174
|
+
response.addResult("\u26A0\uFE0F Previous attempt failed: element was intercepted");
|
|
175
|
+
if (interceptorInfo)
|
|
176
|
+
response.addResult(` Intercepting element: ${interceptorInfo}`);
|
|
177
|
+
response.addResult("\u2713 Retried with allowIntercept: true and succeeded");
|
|
178
|
+
}
|
|
153
179
|
const optionsAttr = usedAllowIntercept ? "{ allowIntercept: true }" : "";
|
|
154
180
|
response.addCode(`await page.${resolved}.hover(${optionsAttr});`);
|
|
181
|
+
response.setIncludeAutoScreenshot();
|
|
155
182
|
}
|
|
156
183
|
});
|
|
157
184
|
const selectOptionSchema = elementSchema.extend({
|
|
@@ -173,6 +200,7 @@ const selectOption = (0, import_tool.defineTabTool)({
|
|
|
173
200
|
await tab.waitForCompletion(async () => {
|
|
174
201
|
await locator.selectOption(params.values);
|
|
175
202
|
});
|
|
203
|
+
response.setIncludeAutoScreenshot();
|
|
176
204
|
}
|
|
177
205
|
});
|
|
178
206
|
const pickLocator = (0, import_tool.defineTabTool)({
|
|
@@ -50,6 +50,7 @@ const browserTabs = (0, import_tool.defineTool)({
|
|
|
50
50
|
case "close": {
|
|
51
51
|
await context.closeTab(params.index);
|
|
52
52
|
response.setIncludeSnapshot("full");
|
|
53
|
+
response.setIncludeAutoScreenshot();
|
|
53
54
|
return;
|
|
54
55
|
}
|
|
55
56
|
case "select": {
|
|
@@ -57,6 +58,7 @@ const browserTabs = (0, import_tool.defineTool)({
|
|
|
57
58
|
throw new Error("Tab index is required");
|
|
58
59
|
await context.selectTab(params.index);
|
|
59
60
|
response.setIncludeSnapshot("full");
|
|
61
|
+
response.setIncludeAutoScreenshot();
|
|
60
62
|
return;
|
|
61
63
|
}
|
|
62
64
|
}
|
|
@@ -33,16 +33,12 @@ async function waitForCompletion(tab, callback) {
|
|
|
33
33
|
const waitBarrier = new Promise((f) => {
|
|
34
34
|
waitCallback = f;
|
|
35
35
|
});
|
|
36
|
-
const
|
|
36
|
+
const requestListener = (request) => requests.add(request);
|
|
37
|
+
const requestFinishedListener = (request) => {
|
|
37
38
|
requests.delete(request);
|
|
38
39
|
if (!requests.size)
|
|
39
40
|
waitCallback();
|
|
40
41
|
};
|
|
41
|
-
const requestListener = (request) => {
|
|
42
|
-
requests.add(request);
|
|
43
|
-
void request.response().then(() => responseListener(request)).catch(() => {
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
42
|
const frameNavigateListener = (frame) => {
|
|
47
43
|
if (frame.parentFrame())
|
|
48
44
|
return;
|
|
@@ -56,12 +52,12 @@ async function waitForCompletion(tab, callback) {
|
|
|
56
52
|
waitCallback();
|
|
57
53
|
};
|
|
58
54
|
tab.page.on("request", requestListener);
|
|
59
|
-
tab.page.on("
|
|
55
|
+
tab.page.on("requestfinished", requestFinishedListener);
|
|
60
56
|
tab.page.on("framenavigated", frameNavigateListener);
|
|
61
57
|
const timeout = setTimeout(onTimeout, 1e4);
|
|
62
58
|
const dispose = () => {
|
|
63
59
|
tab.page.off("request", requestListener);
|
|
64
|
-
tab.page.off("
|
|
60
|
+
tab.page.off("requestfinished", requestFinishedListener);
|
|
65
61
|
tab.page.off("framenavigated", frameNavigateListener);
|
|
66
62
|
clearTimeout(timeout);
|
|
67
63
|
};
|
package/lib/mcp/program.js
CHANGED
|
@@ -42,7 +42,7 @@ var import_proxyBackend = require("./sdk/proxyBackend");
|
|
|
42
42
|
var import_browserServerBackend = require("./browser/browserServerBackend");
|
|
43
43
|
var import_extensionContextFactory = require("./extension/extensionContextFactory");
|
|
44
44
|
function decorateCommand(command, version) {
|
|
45
|
-
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) => {
|
|
45
|
+
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("--auto-screenshot", "automatically capture viewport screenshot after DOM changes").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) => {
|
|
46
46
|
(0, import_watchdog.setupExitWatchdog)();
|
|
47
47
|
if (options.vision) {
|
|
48
48
|
console.error("The --vision option is deprecated, use --caps=vision instead");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@one2x/playwright",
|
|
3
|
-
"version": "1.57.0-alpha.
|
|
3
|
+
"version": "1.57.0-alpha.5",
|
|
4
4
|
"description": "A high-level API to automate web browsers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"license": "Apache-2.0",
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"content-type": "^1.0.5",
|
|
68
|
-
"playwright-core": "npm:@one2x/playwright-core@1.57.0-alpha.
|
|
68
|
+
"playwright-core": "npm:@one2x/playwright-core@1.57.0-alpha.5",
|
|
69
69
|
"raw-body": "^2.5.2"
|
|
70
70
|
},
|
|
71
71
|
"optionalDependencies": {
|