@scoutqa/playwright 1.58.0-fork.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/ThirdPartyNotices.txt +3919 -0
- package/cli.js +19 -0
- package/index.d.ts +17 -0
- package/index.js +17 -0
- package/index.mjs +18 -0
- package/jsx-runtime.js +42 -0
- package/jsx-runtime.mjs +21 -0
- package/lib/agents/agentParser.js +89 -0
- package/lib/agents/copilot-setup-steps.yml +34 -0
- package/lib/agents/generateAgents.js +348 -0
- package/lib/agents/playwright-test-coverage.prompt.md +31 -0
- package/lib/agents/playwright-test-generate.prompt.md +8 -0
- package/lib/agents/playwright-test-generator.agent.md +88 -0
- package/lib/agents/playwright-test-heal.prompt.md +6 -0
- package/lib/agents/playwright-test-healer.agent.md +55 -0
- package/lib/agents/playwright-test-plan.prompt.md +9 -0
- package/lib/agents/playwright-test-planner.agent.md +73 -0
- package/lib/common/config.js +281 -0
- package/lib/common/configLoader.js +344 -0
- package/lib/common/esmLoaderHost.js +104 -0
- package/lib/common/expectBundle.js +43 -0
- package/lib/common/expectBundleImpl.js +407 -0
- package/lib/common/fixtures.js +302 -0
- package/lib/common/globals.js +58 -0
- package/lib/common/ipc.js +60 -0
- package/lib/common/poolBuilder.js +85 -0
- package/lib/common/process.js +132 -0
- package/lib/common/suiteUtils.js +140 -0
- package/lib/common/test.js +322 -0
- package/lib/common/testLoader.js +101 -0
- package/lib/common/testType.js +298 -0
- package/lib/common/validators.js +68 -0
- package/lib/fsWatcher.js +67 -0
- package/lib/index.js +721 -0
- package/lib/internalsForTest.js +42 -0
- package/lib/isomorphic/events.js +77 -0
- package/lib/isomorphic/folders.js +30 -0
- package/lib/isomorphic/stringInternPool.js +69 -0
- package/lib/isomorphic/teleReceiver.js +523 -0
- package/lib/isomorphic/teleSuiteUpdater.js +157 -0
- package/lib/isomorphic/testServerConnection.js +225 -0
- package/lib/isomorphic/testServerInterface.js +16 -0
- package/lib/isomorphic/testTree.js +329 -0
- package/lib/isomorphic/types.d.js +16 -0
- package/lib/loader/loaderMain.js +59 -0
- package/lib/matchers/expect.js +324 -0
- package/lib/matchers/matcherHint.js +87 -0
- package/lib/matchers/matchers.js +382 -0
- package/lib/matchers/toBeTruthy.js +73 -0
- package/lib/matchers/toEqual.js +99 -0
- package/lib/matchers/toHaveURL.js +102 -0
- package/lib/matchers/toMatchAriaSnapshot.js +159 -0
- package/lib/matchers/toMatchSnapshot.js +341 -0
- package/lib/matchers/toMatchText.js +99 -0
- package/lib/mcp/browser/actions.d.js +16 -0
- package/lib/mcp/browser/browserContextFactory.js +321 -0
- package/lib/mcp/browser/browserServerBackend.js +77 -0
- package/lib/mcp/browser/config.js +418 -0
- package/lib/mcp/browser/context.js +285 -0
- package/lib/mcp/browser/response.js +352 -0
- package/lib/mcp/browser/sessionLog.js +160 -0
- package/lib/mcp/browser/tab.js +328 -0
- package/lib/mcp/browser/tools/common.js +63 -0
- package/lib/mcp/browser/tools/console.js +44 -0
- package/lib/mcp/browser/tools/dialogs.js +60 -0
- package/lib/mcp/browser/tools/evaluate.js +59 -0
- package/lib/mcp/browser/tools/files.js +58 -0
- package/lib/mcp/browser/tools/form.js +63 -0
- package/lib/mcp/browser/tools/install.js +69 -0
- package/lib/mcp/browser/tools/keyboard.js +84 -0
- package/lib/mcp/browser/tools/mouse.js +107 -0
- package/lib/mcp/browser/tools/navigate.js +62 -0
- package/lib/mcp/browser/tools/network.js +60 -0
- package/lib/mcp/browser/tools/pdf.js +48 -0
- package/lib/mcp/browser/tools/runCode.js +77 -0
- package/lib/mcp/browser/tools/screenshot.js +105 -0
- package/lib/mcp/browser/tools/snapshot.js +191 -0
- package/lib/mcp/browser/tools/tabs.js +67 -0
- package/lib/mcp/browser/tools/tool.js +50 -0
- package/lib/mcp/browser/tools/tracing.js +74 -0
- package/lib/mcp/browser/tools/utils.js +94 -0
- package/lib/mcp/browser/tools/verify.js +143 -0
- package/lib/mcp/browser/tools/wait.js +63 -0
- package/lib/mcp/browser/tools.js +82 -0
- package/lib/mcp/browser/watchdog.js +44 -0
- package/lib/mcp/config.d.js +16 -0
- package/lib/mcp/extension/cdpRelay.js +351 -0
- package/lib/mcp/extension/extensionContextFactory.js +76 -0
- package/lib/mcp/extension/protocol.js +28 -0
- package/lib/mcp/index.js +61 -0
- package/lib/mcp/log.js +35 -0
- package/lib/mcp/program.js +93 -0
- package/lib/mcp/sdk/exports.js +28 -0
- package/lib/mcp/sdk/http.js +152 -0
- package/lib/mcp/sdk/inProcessTransport.js +71 -0
- package/lib/mcp/sdk/server.js +207 -0
- package/lib/mcp/sdk/tool.js +47 -0
- package/lib/mcp/test/browserBackend.js +98 -0
- package/lib/mcp/test/generatorTools.js +122 -0
- package/lib/mcp/test/plannerTools.js +144 -0
- package/lib/mcp/test/seed.js +82 -0
- package/lib/mcp/test/streams.js +44 -0
- package/lib/mcp/test/testBackend.js +99 -0
- package/lib/mcp/test/testContext.js +279 -0
- package/lib/mcp/test/testTool.js +30 -0
- package/lib/mcp/test/testTools.js +108 -0
- package/lib/plugins/gitCommitInfoPlugin.js +198 -0
- package/lib/plugins/index.js +28 -0
- package/lib/plugins/webServerPlugin.js +237 -0
- package/lib/program.js +417 -0
- package/lib/reporters/base.js +609 -0
- package/lib/reporters/blob.js +139 -0
- package/lib/reporters/dot.js +82 -0
- package/lib/reporters/empty.js +32 -0
- package/lib/reporters/github.js +128 -0
- package/lib/reporters/html.js +623 -0
- package/lib/reporters/internalReporter.js +140 -0
- package/lib/reporters/json.js +255 -0
- package/lib/reporters/junit.js +232 -0
- package/lib/reporters/line.js +113 -0
- package/lib/reporters/list.js +231 -0
- package/lib/reporters/listModeReporter.js +69 -0
- package/lib/reporters/markdown.js +144 -0
- package/lib/reporters/merge.js +546 -0
- package/lib/reporters/multiplexer.js +112 -0
- package/lib/reporters/reporterV2.js +102 -0
- package/lib/reporters/teleEmitter.js +319 -0
- package/lib/reporters/versions/blobV1.js +16 -0
- package/lib/runner/dispatcher.js +533 -0
- package/lib/runner/failureTracker.js +72 -0
- package/lib/runner/lastRun.js +77 -0
- package/lib/runner/loadUtils.js +334 -0
- package/lib/runner/loaderHost.js +89 -0
- package/lib/runner/processHost.js +180 -0
- package/lib/runner/projectUtils.js +241 -0
- package/lib/runner/rebase.js +189 -0
- package/lib/runner/reporters.js +138 -0
- package/lib/runner/sigIntWatcher.js +96 -0
- package/lib/runner/storage.js +91 -0
- package/lib/runner/taskRunner.js +127 -0
- package/lib/runner/tasks.js +410 -0
- package/lib/runner/testGroups.js +125 -0
- package/lib/runner/testRunner.js +398 -0
- package/lib/runner/testServer.js +269 -0
- package/lib/runner/uiModeReporter.js +30 -0
- package/lib/runner/vcs.js +72 -0
- package/lib/runner/watchMode.js +396 -0
- package/lib/runner/workerHost.js +104 -0
- package/lib/third_party/pirates.js +62 -0
- package/lib/third_party/tsconfig-loader.js +103 -0
- package/lib/transform/babelBundle.js +43 -0
- package/lib/transform/babelBundleImpl.js +461 -0
- package/lib/transform/babelHighlightUtils.js +63 -0
- package/lib/transform/compilationCache.js +272 -0
- package/lib/transform/esmLoader.js +103 -0
- package/lib/transform/portTransport.js +67 -0
- package/lib/transform/transform.js +296 -0
- package/lib/util.js +403 -0
- package/lib/utilsBundle.js +43 -0
- package/lib/utilsBundleImpl.js +100 -0
- package/lib/worker/fixtureRunner.js +258 -0
- package/lib/worker/testInfo.js +557 -0
- package/lib/worker/testTracing.js +345 -0
- package/lib/worker/timeoutManager.js +174 -0
- package/lib/worker/util.js +31 -0
- package/lib/worker/workerMain.js +529 -0
- package/package.json +72 -0
- package/test.d.ts +18 -0
- package/test.js +24 -0
- package/test.mjs +34 -0
- package/types/test.d.ts +10277 -0
- package/types/testReporter.d.ts +827 -0
|
@@ -0,0 +1,69 @@
|
|
|
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 install_exports = {};
|
|
30
|
+
__export(install_exports, {
|
|
31
|
+
default: () => install_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(install_exports);
|
|
34
|
+
var import_child_process = require("child_process");
|
|
35
|
+
var import_path = __toESM(require("path"));
|
|
36
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
37
|
+
var import_tool = require("./tool");
|
|
38
|
+
const install = (0, import_tool.defineTool)({
|
|
39
|
+
capability: "core-install",
|
|
40
|
+
schema: {
|
|
41
|
+
name: "browser_install",
|
|
42
|
+
title: "Install the browser specified in the config",
|
|
43
|
+
description: "Install the browser specified in the config. Call this if you get an error about the browser not being installed.",
|
|
44
|
+
inputSchema: import_mcpBundle.z.object({}),
|
|
45
|
+
type: "action"
|
|
46
|
+
},
|
|
47
|
+
handle: async (context, params, response) => {
|
|
48
|
+
const channel = context.config.browser?.launchOptions?.channel ?? context.config.browser?.browserName ?? "chrome";
|
|
49
|
+
const cliPath = import_path.default.join(require.resolve("playwright/package.json"), "../cli.js");
|
|
50
|
+
const child = (0, import_child_process.fork)(cliPath, ["install", channel], {
|
|
51
|
+
stdio: "pipe"
|
|
52
|
+
});
|
|
53
|
+
const output = [];
|
|
54
|
+
child.stdout?.on("data", (data) => output.push(data.toString()));
|
|
55
|
+
child.stderr?.on("data", (data) => output.push(data.toString()));
|
|
56
|
+
await new Promise((resolve, reject) => {
|
|
57
|
+
child.on("close", (code) => {
|
|
58
|
+
if (code === 0)
|
|
59
|
+
resolve();
|
|
60
|
+
else
|
|
61
|
+
reject(new Error(`Failed to install browser: ${output.join("")}`));
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
response.setIncludeTabs();
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
var install_default = [
|
|
68
|
+
install
|
|
69
|
+
];
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var keyboard_exports = {};
|
|
20
|
+
__export(keyboard_exports, {
|
|
21
|
+
default: () => keyboard_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(keyboard_exports);
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
|
+
var import_tool = require("./tool");
|
|
26
|
+
var import_snapshot = require("./snapshot");
|
|
27
|
+
const pressKey = (0, import_tool.defineTabTool)({
|
|
28
|
+
capability: "core",
|
|
29
|
+
schema: {
|
|
30
|
+
name: "browser_press_key",
|
|
31
|
+
title: "Press a key",
|
|
32
|
+
description: "Press a key on the keyboard",
|
|
33
|
+
inputSchema: import_mcpBundle.z.object({
|
|
34
|
+
key: import_mcpBundle.z.string().describe("Name of the key to press or a character to generate, such as `ArrowLeft` or `a`")
|
|
35
|
+
}),
|
|
36
|
+
type: "input"
|
|
37
|
+
},
|
|
38
|
+
handle: async (tab, params, response) => {
|
|
39
|
+
response.setIncludeSnapshot();
|
|
40
|
+
response.addCode(`// Press ${params.key}`);
|
|
41
|
+
response.addCode(`await page.keyboard.press('${params.key}');`);
|
|
42
|
+
await tab.waitForCompletion(async () => {
|
|
43
|
+
await tab.page.keyboard.press(params.key);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
const typeSchema = import_snapshot.elementSchema.extend({
|
|
48
|
+
text: import_mcpBundle.z.string().describe("Text to type into the element"),
|
|
49
|
+
submit: import_mcpBundle.z.boolean().optional().describe("Whether to submit entered text (press Enter after)"),
|
|
50
|
+
slowly: import_mcpBundle.z.boolean().optional().describe("Whether to type one character at a time. Useful for triggering key handlers in the page. By default entire text is filled in at once.")
|
|
51
|
+
});
|
|
52
|
+
const type = (0, import_tool.defineTabTool)({
|
|
53
|
+
capability: "core",
|
|
54
|
+
schema: {
|
|
55
|
+
name: "browser_type",
|
|
56
|
+
title: "Type text",
|
|
57
|
+
description: "Type text into editable element",
|
|
58
|
+
inputSchema: typeSchema,
|
|
59
|
+
type: "input"
|
|
60
|
+
},
|
|
61
|
+
handle: async (tab, params, response) => {
|
|
62
|
+
const { locator, resolved } = await tab.refLocator(params);
|
|
63
|
+
const secret = tab.context.lookupSecret(params.text);
|
|
64
|
+
await tab.waitForCompletion(async () => {
|
|
65
|
+
if (params.slowly) {
|
|
66
|
+
response.setIncludeSnapshot();
|
|
67
|
+
response.addCode(`await page.${resolved}.pressSequentially(${secret.code});`);
|
|
68
|
+
await locator.pressSequentially(secret.value);
|
|
69
|
+
} else {
|
|
70
|
+
response.addCode(`await page.${resolved}.fill(${secret.code});`);
|
|
71
|
+
await locator.fill(secret.value);
|
|
72
|
+
}
|
|
73
|
+
if (params.submit) {
|
|
74
|
+
response.setIncludeSnapshot();
|
|
75
|
+
response.addCode(`await page.${resolved}.press('Enter');`);
|
|
76
|
+
await locator.press("Enter");
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
var keyboard_default = [
|
|
82
|
+
pressKey,
|
|
83
|
+
type
|
|
84
|
+
];
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var mouse_exports = {};
|
|
20
|
+
__export(mouse_exports, {
|
|
21
|
+
default: () => mouse_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(mouse_exports);
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
|
+
var import_tool = require("./tool");
|
|
26
|
+
const elementSchema = import_mcpBundle.z.object({
|
|
27
|
+
element: import_mcpBundle.z.string().describe("Human-readable element description used to obtain permission to interact with the element")
|
|
28
|
+
});
|
|
29
|
+
const mouseMove = (0, import_tool.defineTabTool)({
|
|
30
|
+
capability: "vision",
|
|
31
|
+
schema: {
|
|
32
|
+
name: "browser_mouse_move_xy",
|
|
33
|
+
title: "Move mouse",
|
|
34
|
+
description: "Move mouse to a given position",
|
|
35
|
+
inputSchema: elementSchema.extend({
|
|
36
|
+
x: import_mcpBundle.z.number().describe("X coordinate"),
|
|
37
|
+
y: import_mcpBundle.z.number().describe("Y coordinate")
|
|
38
|
+
}),
|
|
39
|
+
type: "input"
|
|
40
|
+
},
|
|
41
|
+
handle: async (tab, params, response) => {
|
|
42
|
+
response.addCode(`// Move mouse to (${params.x}, ${params.y})`);
|
|
43
|
+
response.addCode(`await page.mouse.move(${params.x}, ${params.y});`);
|
|
44
|
+
await tab.waitForCompletion(async () => {
|
|
45
|
+
await tab.page.mouse.move(params.x, params.y);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
const mouseClick = (0, import_tool.defineTabTool)({
|
|
50
|
+
capability: "vision",
|
|
51
|
+
schema: {
|
|
52
|
+
name: "browser_mouse_click_xy",
|
|
53
|
+
title: "Click",
|
|
54
|
+
description: "Click left mouse button at a given position",
|
|
55
|
+
inputSchema: elementSchema.extend({
|
|
56
|
+
x: import_mcpBundle.z.number().describe("X coordinate"),
|
|
57
|
+
y: import_mcpBundle.z.number().describe("Y coordinate")
|
|
58
|
+
}),
|
|
59
|
+
type: "input"
|
|
60
|
+
},
|
|
61
|
+
handle: async (tab, params, response) => {
|
|
62
|
+
response.setIncludeSnapshot();
|
|
63
|
+
response.addCode(`// Click mouse at coordinates (${params.x}, ${params.y})`);
|
|
64
|
+
response.addCode(`await page.mouse.move(${params.x}, ${params.y});`);
|
|
65
|
+
response.addCode(`await page.mouse.down();`);
|
|
66
|
+
response.addCode(`await page.mouse.up();`);
|
|
67
|
+
await tab.waitForCompletion(async () => {
|
|
68
|
+
await tab.page.mouse.move(params.x, params.y);
|
|
69
|
+
await tab.page.mouse.down();
|
|
70
|
+
await tab.page.mouse.up();
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
const mouseDrag = (0, import_tool.defineTabTool)({
|
|
75
|
+
capability: "vision",
|
|
76
|
+
schema: {
|
|
77
|
+
name: "browser_mouse_drag_xy",
|
|
78
|
+
title: "Drag mouse",
|
|
79
|
+
description: "Drag left mouse button to a given position",
|
|
80
|
+
inputSchema: elementSchema.extend({
|
|
81
|
+
startX: import_mcpBundle.z.number().describe("Start X coordinate"),
|
|
82
|
+
startY: import_mcpBundle.z.number().describe("Start Y coordinate"),
|
|
83
|
+
endX: import_mcpBundle.z.number().describe("End X coordinate"),
|
|
84
|
+
endY: import_mcpBundle.z.number().describe("End Y coordinate")
|
|
85
|
+
}),
|
|
86
|
+
type: "input"
|
|
87
|
+
},
|
|
88
|
+
handle: async (tab, params, response) => {
|
|
89
|
+
response.setIncludeSnapshot();
|
|
90
|
+
response.addCode(`// Drag mouse from (${params.startX}, ${params.startY}) to (${params.endX}, ${params.endY})`);
|
|
91
|
+
response.addCode(`await page.mouse.move(${params.startX}, ${params.startY});`);
|
|
92
|
+
response.addCode(`await page.mouse.down();`);
|
|
93
|
+
response.addCode(`await page.mouse.move(${params.endX}, ${params.endY});`);
|
|
94
|
+
response.addCode(`await page.mouse.up();`);
|
|
95
|
+
await tab.waitForCompletion(async () => {
|
|
96
|
+
await tab.page.mouse.move(params.startX, params.startY);
|
|
97
|
+
await tab.page.mouse.down();
|
|
98
|
+
await tab.page.mouse.move(params.endX, params.endY);
|
|
99
|
+
await tab.page.mouse.up();
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
var mouse_default = [
|
|
104
|
+
mouseMove,
|
|
105
|
+
mouseClick,
|
|
106
|
+
mouseDrag
|
|
107
|
+
];
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var navigate_exports = {};
|
|
20
|
+
__export(navigate_exports, {
|
|
21
|
+
default: () => navigate_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(navigate_exports);
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
|
+
var import_tool = require("./tool");
|
|
26
|
+
const navigate = (0, import_tool.defineTool)({
|
|
27
|
+
capability: "core",
|
|
28
|
+
schema: {
|
|
29
|
+
name: "browser_navigate",
|
|
30
|
+
title: "Navigate to a URL",
|
|
31
|
+
description: "Navigate to a URL",
|
|
32
|
+
inputSchema: import_mcpBundle.z.object({
|
|
33
|
+
url: import_mcpBundle.z.string().describe("The URL to navigate to")
|
|
34
|
+
}),
|
|
35
|
+
type: "action"
|
|
36
|
+
},
|
|
37
|
+
handle: async (context, params, response) => {
|
|
38
|
+
const tab = await context.ensureTab();
|
|
39
|
+
await tab.navigate(params.url);
|
|
40
|
+
response.setIncludeSnapshot();
|
|
41
|
+
response.addCode(`await page.goto('${params.url}');`);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
const goBack = (0, import_tool.defineTabTool)({
|
|
45
|
+
capability: "core",
|
|
46
|
+
schema: {
|
|
47
|
+
name: "browser_navigate_back",
|
|
48
|
+
title: "Go back",
|
|
49
|
+
description: "Go back to the previous page",
|
|
50
|
+
inputSchema: import_mcpBundle.z.object({}),
|
|
51
|
+
type: "action"
|
|
52
|
+
},
|
|
53
|
+
handle: async (tab, params, response) => {
|
|
54
|
+
await tab.page.goBack();
|
|
55
|
+
response.setIncludeSnapshot();
|
|
56
|
+
response.addCode(`await page.goBack();`);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
var navigate_default = [
|
|
60
|
+
navigate,
|
|
61
|
+
goBack
|
|
62
|
+
];
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var network_exports = {};
|
|
20
|
+
__export(network_exports, {
|
|
21
|
+
default: () => network_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(network_exports);
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
|
+
var import_tool = require("./tool");
|
|
26
|
+
const requests = (0, import_tool.defineTabTool)({
|
|
27
|
+
capability: "core",
|
|
28
|
+
schema: {
|
|
29
|
+
name: "browser_network_requests",
|
|
30
|
+
title: "List network requests",
|
|
31
|
+
description: "Returns all network requests since loading the page",
|
|
32
|
+
inputSchema: import_mcpBundle.z.object({
|
|
33
|
+
includeStatic: import_mcpBundle.z.boolean().default(false).describe("Whether to include successful static resources like images, fonts, scripts, etc. Defaults to false.")
|
|
34
|
+
}),
|
|
35
|
+
type: "readOnly"
|
|
36
|
+
},
|
|
37
|
+
handle: async (tab, params, response) => {
|
|
38
|
+
const requests2 = await tab.requests();
|
|
39
|
+
for (const request of requests2) {
|
|
40
|
+
const rendered = await renderRequest(request, params.includeStatic);
|
|
41
|
+
if (rendered)
|
|
42
|
+
response.addResult(rendered);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
async function renderRequest(request, includeStatic) {
|
|
47
|
+
const response = request._hasResponse ? await request.response() : void 0;
|
|
48
|
+
const isStaticRequest = ["document", "stylesheet", "image", "media", "font", "script", "manifest"].includes(request.resourceType());
|
|
49
|
+
const isSuccessfulRequest = !response || response.status() < 400;
|
|
50
|
+
if (isStaticRequest && isSuccessfulRequest && !includeStatic)
|
|
51
|
+
return void 0;
|
|
52
|
+
const result = [];
|
|
53
|
+
result.push(`[${request.method().toUpperCase()}] ${request.url()}`);
|
|
54
|
+
if (response)
|
|
55
|
+
result.push(`=> [${response.status()}] ${response.statusText()}`);
|
|
56
|
+
return result.join(" ");
|
|
57
|
+
}
|
|
58
|
+
var network_default = [
|
|
59
|
+
requests
|
|
60
|
+
];
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var pdf_exports = {};
|
|
20
|
+
__export(pdf_exports, {
|
|
21
|
+
default: () => pdf_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(pdf_exports);
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
|
+
var import_utils = require("playwright-core/lib/utils");
|
|
26
|
+
var import_tool = require("./tool");
|
|
27
|
+
var import_utils2 = require("./utils");
|
|
28
|
+
const pdfSchema = import_mcpBundle.z.object({
|
|
29
|
+
filename: import_mcpBundle.z.string().optional().describe("File name to save the pdf to. Defaults to `page-{timestamp}.pdf` if not specified. Prefer relative file names to stay within the output directory.")
|
|
30
|
+
});
|
|
31
|
+
const pdf = (0, import_tool.defineTabTool)({
|
|
32
|
+
capability: "pdf",
|
|
33
|
+
schema: {
|
|
34
|
+
name: "browser_pdf_save",
|
|
35
|
+
title: "Save as PDF",
|
|
36
|
+
description: "Save page as PDF",
|
|
37
|
+
inputSchema: pdfSchema,
|
|
38
|
+
type: "readOnly"
|
|
39
|
+
},
|
|
40
|
+
handle: async (tab, params, response) => {
|
|
41
|
+
const fileName = await response.addFile(params.filename ?? (0, import_utils2.dateAsFileName)("pdf"), { origin: "llm", reason: "Page saved as PDF" });
|
|
42
|
+
response.addCode(`await page.pdf(${(0, import_utils.formatObject)({ path: fileName })});`);
|
|
43
|
+
await tab.page.pdf({ path: fileName });
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
var pdf_default = [
|
|
47
|
+
pdf
|
|
48
|
+
];
|
|
@@ -0,0 +1,77 @@
|
|
|
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 runCode_exports = {};
|
|
30
|
+
__export(runCode_exports, {
|
|
31
|
+
default: () => runCode_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(runCode_exports);
|
|
34
|
+
var import_vm = __toESM(require("vm"));
|
|
35
|
+
var import_utils = require("playwright-core/lib/utils");
|
|
36
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
37
|
+
var import_tool = require("./tool");
|
|
38
|
+
const codeSchema = import_mcpBundle.z.object({
|
|
39
|
+
code: import_mcpBundle.z.string().describe(`A JavaScript function containing Playwright code to execute. It will be invoked with a single argument, page, which you can use for any page interaction. For example: \`async (page) => { await page.getByRole('button', { name: 'Submit' }).click(); return await page.title(); }\``)
|
|
40
|
+
});
|
|
41
|
+
const runCode = (0, import_tool.defineTabTool)({
|
|
42
|
+
capability: "core",
|
|
43
|
+
schema: {
|
|
44
|
+
name: "browser_run_code",
|
|
45
|
+
title: "Run Playwright code",
|
|
46
|
+
description: "Run Playwright code snippet",
|
|
47
|
+
inputSchema: codeSchema,
|
|
48
|
+
type: "action"
|
|
49
|
+
},
|
|
50
|
+
handle: async (tab, params, response) => {
|
|
51
|
+
response.setIncludeSnapshot();
|
|
52
|
+
response.addCode(`await (${params.code})(page);`);
|
|
53
|
+
const __end__ = new import_utils.ManualPromise();
|
|
54
|
+
const context = {
|
|
55
|
+
page: tab.page,
|
|
56
|
+
__end__
|
|
57
|
+
};
|
|
58
|
+
import_vm.default.createContext(context);
|
|
59
|
+
await tab.waitForCompletion(async () => {
|
|
60
|
+
const snippet = `(async () => {
|
|
61
|
+
try {
|
|
62
|
+
const result = await (${params.code})(page);
|
|
63
|
+
__end__.resolve(JSON.stringify(result));
|
|
64
|
+
} catch (e) {
|
|
65
|
+
__end__.reject(e);
|
|
66
|
+
}
|
|
67
|
+
})()`;
|
|
68
|
+
await import_vm.default.runInContext(snippet, context);
|
|
69
|
+
const result = await __end__;
|
|
70
|
+
if (typeof result === "string")
|
|
71
|
+
response.addResult(result);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
var runCode_default = [
|
|
76
|
+
runCode
|
|
77
|
+
];
|
|
@@ -0,0 +1,105 @@
|
|
|
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 screenshot_exports = {};
|
|
30
|
+
__export(screenshot_exports, {
|
|
31
|
+
default: () => screenshot_default,
|
|
32
|
+
scaleImageToFitMessage: () => scaleImageToFitMessage
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(screenshot_exports);
|
|
35
|
+
var import_fs = __toESM(require("fs"));
|
|
36
|
+
var import_utils = require("playwright-core/lib/utils");
|
|
37
|
+
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
|
|
38
|
+
var import_utils2 = require("playwright-core/lib/utils");
|
|
39
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
40
|
+
var import_tool = require("./tool");
|
|
41
|
+
var import_utils3 = require("./utils");
|
|
42
|
+
const screenshotSchema = import_mcpBundle.z.object({
|
|
43
|
+
type: import_mcpBundle.z.enum(["png", "jpeg"]).default("png").describe("Image format for the screenshot. Default is png."),
|
|
44
|
+
filename: import_mcpBundle.z.string().optional().describe("File name to save the screenshot to. Defaults to `page-{timestamp}.{png|jpeg}` if not specified. Prefer relative file names to stay within the output directory."),
|
|
45
|
+
element: import_mcpBundle.z.string().optional().describe("Human-readable element description used to obtain permission to screenshot the element. If not provided, the screenshot will be taken of viewport. If element is provided, ref must be provided too."),
|
|
46
|
+
ref: import_mcpBundle.z.string().optional().describe("Exact target element reference from the page snapshot. If not provided, the screenshot will be taken of viewport. If ref is provided, element must be provided too."),
|
|
47
|
+
fullPage: import_mcpBundle.z.boolean().optional().describe("When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport. Cannot be used with element screenshots.")
|
|
48
|
+
});
|
|
49
|
+
const screenshot = (0, import_tool.defineTabTool)({
|
|
50
|
+
capability: "core",
|
|
51
|
+
schema: {
|
|
52
|
+
name: "browser_take_screenshot",
|
|
53
|
+
title: "Take a screenshot",
|
|
54
|
+
description: `Take a screenshot of the current page. You can't perform actions based on the screenshot, use browser_snapshot for actions.`,
|
|
55
|
+
inputSchema: screenshotSchema,
|
|
56
|
+
type: "readOnly"
|
|
57
|
+
},
|
|
58
|
+
handle: async (tab, params, response) => {
|
|
59
|
+
if (!!params.element !== !!params.ref)
|
|
60
|
+
throw new Error("Both element and ref must be provided or neither.");
|
|
61
|
+
if (params.fullPage && params.ref)
|
|
62
|
+
throw new Error("fullPage cannot be used with element screenshots.");
|
|
63
|
+
const fileType = params.type || "png";
|
|
64
|
+
const options = {
|
|
65
|
+
type: fileType,
|
|
66
|
+
quality: fileType === "png" ? void 0 : 90,
|
|
67
|
+
scale: "css",
|
|
68
|
+
...params.fullPage !== void 0 && { fullPage: params.fullPage }
|
|
69
|
+
};
|
|
70
|
+
const isElementScreenshot = params.element && params.ref;
|
|
71
|
+
const screenshotTarget = isElementScreenshot ? params.element : params.fullPage ? "full page" : "viewport";
|
|
72
|
+
const fileName = await response.addFile(params.filename || (0, import_utils3.dateAsFileName)(fileType), { origin: "llm", reason: `Screenshot of ${screenshotTarget}` });
|
|
73
|
+
response.addCode(`// Screenshot ${screenshotTarget} and save it as ${fileName}`);
|
|
74
|
+
const ref = params.ref ? await tab.refLocator({ element: params.element || "", ref: params.ref }) : null;
|
|
75
|
+
if (ref)
|
|
76
|
+
response.addCode(`await page.${ref.resolved}.screenshot(${(0, import_utils2.formatObject)(options)});`);
|
|
77
|
+
else
|
|
78
|
+
response.addCode(`await page.screenshot(${(0, import_utils2.formatObject)(options)});`);
|
|
79
|
+
const buffer = ref ? await ref.locator.screenshot(options) : await tab.page.screenshot(options);
|
|
80
|
+
await (0, import_utils.mkdirIfNeeded)(fileName);
|
|
81
|
+
await import_fs.default.promises.writeFile(fileName, buffer);
|
|
82
|
+
response.addImage({
|
|
83
|
+
contentType: fileType === "png" ? "image/png" : "image/jpeg",
|
|
84
|
+
data: scaleImageToFitMessage(buffer, fileType)
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
function scaleImageToFitMessage(buffer, imageType) {
|
|
89
|
+
const image = imageType === "png" ? import_utilsBundle.PNG.sync.read(buffer) : import_utilsBundle.jpegjs.decode(buffer, { maxMemoryUsageInMB: 512 });
|
|
90
|
+
const pixels = image.width * image.height;
|
|
91
|
+
const shrink = Math.min(1568 / image.width, 1568 / image.height, Math.sqrt(1.15 * 1024 * 1024 / pixels));
|
|
92
|
+
if (shrink > 1)
|
|
93
|
+
return buffer;
|
|
94
|
+
const width = image.width * shrink | 0;
|
|
95
|
+
const height = image.height * shrink | 0;
|
|
96
|
+
const scaledImage = (0, import_utils.scaleImageToSize)(image, { width, height });
|
|
97
|
+
return imageType === "png" ? import_utilsBundle.PNG.sync.write(scaledImage) : import_utilsBundle.jpegjs.encode(scaledImage, 80).data;
|
|
98
|
+
}
|
|
99
|
+
var screenshot_default = [
|
|
100
|
+
screenshot
|
|
101
|
+
];
|
|
102
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
103
|
+
0 && (module.exports = {
|
|
104
|
+
scaleImageToFitMessage
|
|
105
|
+
});
|