@one2x/playwright 1.57.0-alpha.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/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +168 -0
- package/ThirdPartyNotices.txt +6277 -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/copilot-setup-steps.yml +34 -0
- package/lib/agents/generateAgents.js +394 -0
- package/lib/agents/generateAgents.js.map +7 -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 +117 -0
- package/lib/common/config.js +280 -0
- package/lib/common/config.js.map +7 -0
- package/lib/common/configLoader.js +344 -0
- package/lib/common/configLoader.js.map +7 -0
- package/lib/common/esmLoaderHost.js +102 -0
- package/lib/common/esmLoaderHost.js.map +7 -0
- package/lib/common/expectBundle.js +52 -0
- package/lib/common/expectBundle.js.map +7 -0
- package/lib/common/expectBundleImpl.js +389 -0
- package/lib/common/expectBundleImpl.js.map +7 -0
- package/lib/common/fixtures.js +302 -0
- package/lib/common/fixtures.js.map +7 -0
- package/lib/common/globals.js +58 -0
- package/lib/common/globals.js.map +7 -0
- package/lib/common/ipc.js +60 -0
- package/lib/common/ipc.js.map +7 -0
- package/lib/common/poolBuilder.js +85 -0
- package/lib/common/poolBuilder.js.map +7 -0
- package/lib/common/process.js +104 -0
- package/lib/common/process.js.map +7 -0
- package/lib/common/suiteUtils.js +140 -0
- package/lib/common/suiteUtils.js.map +7 -0
- package/lib/common/test.js +321 -0
- package/lib/common/test.js.map +7 -0
- package/lib/common/testLoader.js +101 -0
- package/lib/common/testLoader.js.map +7 -0
- package/lib/common/testType.js +298 -0
- package/lib/common/testType.js.map +7 -0
- package/lib/common/validators.js +68 -0
- package/lib/common/validators.js.map +7 -0
- package/lib/fsWatcher.js +67 -0
- package/lib/fsWatcher.js.map +7 -0
- package/lib/index.js +682 -0
- package/lib/index.js.map +7 -0
- package/lib/internalsForTest.js +42 -0
- package/lib/internalsForTest.js.map +7 -0
- package/lib/isomorphic/events.js +77 -0
- package/lib/isomorphic/events.js.map +7 -0
- package/lib/isomorphic/folders.js +30 -0
- package/lib/isomorphic/folders.js.map +7 -0
- package/lib/isomorphic/stringInternPool.js +69 -0
- package/lib/isomorphic/stringInternPool.js.map +7 -0
- package/lib/isomorphic/teleReceiver.js +508 -0
- package/lib/isomorphic/teleReceiver.js.map +7 -0
- package/lib/isomorphic/teleSuiteUpdater.js +137 -0
- package/lib/isomorphic/teleSuiteUpdater.js.map +7 -0
- package/lib/isomorphic/testServerConnection.js +211 -0
- package/lib/isomorphic/testServerConnection.js.map +7 -0
- package/lib/isomorphic/testServerInterface.js +16 -0
- package/lib/isomorphic/testServerInterface.js.map +7 -0
- package/lib/isomorphic/testTree.js +334 -0
- package/lib/isomorphic/testTree.js.map +7 -0
- package/lib/isomorphic/types.d.js +16 -0
- package/lib/isomorphic/types.d.js.map +7 -0
- package/lib/loader/loaderMain.js +59 -0
- package/lib/loader/loaderMain.js.map +7 -0
- package/lib/matchers/expect.js +325 -0
- package/lib/matchers/expect.js.map +7 -0
- package/lib/matchers/matcherHint.js +87 -0
- package/lib/matchers/matcherHint.js.map +7 -0
- package/lib/matchers/matchers.js +366 -0
- package/lib/matchers/matchers.js.map +7 -0
- package/lib/matchers/toBeTruthy.js +73 -0
- package/lib/matchers/toBeTruthy.js.map +7 -0
- package/lib/matchers/toEqual.js +99 -0
- package/lib/matchers/toEqual.js.map +7 -0
- package/lib/matchers/toHaveURL.js +102 -0
- package/lib/matchers/toHaveURL.js.map +7 -0
- package/lib/matchers/toMatchAriaSnapshot.js +159 -0
- package/lib/matchers/toMatchAriaSnapshot.js.map +7 -0
- package/lib/matchers/toMatchSnapshot.js +341 -0
- package/lib/matchers/toMatchSnapshot.js.map +7 -0
- package/lib/matchers/toMatchText.js +99 -0
- package/lib/matchers/toMatchText.js.map +7 -0
- package/lib/mcp/browser/actions.d.js +16 -0
- package/lib/mcp/browser/actions.d.js.map +7 -0
- package/lib/mcp/browser/browserContextFactory.js +357 -0
- package/lib/mcp/browser/browserContextFactory.js.map +7 -0
- package/lib/mcp/browser/browserServerBackend.js +76 -0
- package/lib/mcp/browser/browserServerBackend.js.map +7 -0
- package/lib/mcp/browser/codegen.js +66 -0
- package/lib/mcp/browser/codegen.js.map +7 -0
- package/lib/mcp/browser/config.js +425 -0
- package/lib/mcp/browser/config.js.map +7 -0
- package/lib/mcp/browser/context.js +287 -0
- package/lib/mcp/browser/context.js.map +7 -0
- package/lib/mcp/browser/response.js +228 -0
- package/lib/mcp/browser/response.js.map +7 -0
- package/lib/mcp/browser/sessionLog.js +160 -0
- package/lib/mcp/browser/sessionLog.js.map +7 -0
- package/lib/mcp/browser/tab.js +280 -0
- package/lib/mcp/browser/tab.js.map +7 -0
- package/lib/mcp/browser/tools/actionRetry.js +40 -0
- package/lib/mcp/browser/tools/actionRetry.js.map +7 -0
- package/lib/mcp/browser/tools/common.js +63 -0
- package/lib/mcp/browser/tools/common.js.map +7 -0
- package/lib/mcp/browser/tools/console.js +44 -0
- package/lib/mcp/browser/tools/console.js.map +7 -0
- package/lib/mcp/browser/tools/dialogs.js +60 -0
- package/lib/mcp/browser/tools/dialogs.js.map +7 -0
- package/lib/mcp/browser/tools/evaluate.js +69 -0
- package/lib/mcp/browser/tools/evaluate.js.map +7 -0
- package/lib/mcp/browser/tools/files.js +58 -0
- package/lib/mcp/browser/tools/files.js.map +7 -0
- package/lib/mcp/browser/tools/form.js +79 -0
- package/lib/mcp/browser/tools/form.js.map +7 -0
- package/lib/mcp/browser/tools/install.js +69 -0
- package/lib/mcp/browser/tools/install.js.map +7 -0
- package/lib/mcp/browser/tools/keyboard.js +84 -0
- package/lib/mcp/browser/tools/keyboard.js.map +7 -0
- package/lib/mcp/browser/tools/mouse.js +107 -0
- package/lib/mcp/browser/tools/mouse.js.map +7 -0
- package/lib/mcp/browser/tools/navigate.js +62 -0
- package/lib/mcp/browser/tools/navigate.js.map +7 -0
- package/lib/mcp/browser/tools/network.js +54 -0
- package/lib/mcp/browser/tools/network.js.map +7 -0
- package/lib/mcp/browser/tools/pdf.js +59 -0
- package/lib/mcp/browser/tools/pdf.js.map +7 -0
- package/lib/mcp/browser/tools/screenshot.js +106 -0
- package/lib/mcp/browser/tools/screenshot.js.map +7 -0
- package/lib/mcp/browser/tools/snapshot.js +312 -0
- package/lib/mcp/browser/tools/snapshot.js.map +7 -0
- package/lib/mcp/browser/tools/tabs.js +67 -0
- package/lib/mcp/browser/tools/tabs.js.map +7 -0
- package/lib/mcp/browser/tools/tool.js +49 -0
- package/lib/mcp/browser/tools/tool.js.map +7 -0
- package/lib/mcp/browser/tools/tracing.js +74 -0
- package/lib/mcp/browser/tools/tracing.js.map +7 -0
- package/lib/mcp/browser/tools/utils.js +96 -0
- package/lib/mcp/browser/tools/utils.js.map +7 -0
- package/lib/mcp/browser/tools/verify.js +153 -0
- package/lib/mcp/browser/tools/verify.js.map +7 -0
- package/lib/mcp/browser/tools/wait.js +63 -0
- package/lib/mcp/browser/tools/wait.js.map +7 -0
- package/lib/mcp/browser/tools.js +80 -0
- package/lib/mcp/browser/tools.js.map +7 -0
- package/lib/mcp/browser/watchdog.js +44 -0
- package/lib/mcp/browser/watchdog.js.map +7 -0
- package/lib/mcp/config.d.js +16 -0
- package/lib/mcp/config.d.js.map +7 -0
- package/lib/mcp/extension/cdpRelay.js +351 -0
- package/lib/mcp/extension/cdpRelay.js.map +7 -0
- package/lib/mcp/extension/extensionContextFactory.js +75 -0
- package/lib/mcp/extension/extensionContextFactory.js.map +7 -0
- package/lib/mcp/extension/protocol.js +28 -0
- package/lib/mcp/extension/protocol.js.map +7 -0
- package/lib/mcp/index.js +61 -0
- package/lib/mcp/index.js.map +7 -0
- package/lib/mcp/log.js +35 -0
- package/lib/mcp/log.js.map +7 -0
- package/lib/mcp/program.js +118 -0
- package/lib/mcp/program.js.map +7 -0
- package/lib/mcp/sdk/bundle.js +81 -0
- package/lib/mcp/sdk/bundle.js.map +7 -0
- package/lib/mcp/sdk/exports.js +32 -0
- package/lib/mcp/sdk/exports.js.map +7 -0
- package/lib/mcp/sdk/http.js +276 -0
- package/lib/mcp/sdk/http.js.map +7 -0
- package/lib/mcp/sdk/inProcessTransport.js +71 -0
- package/lib/mcp/sdk/inProcessTransport.js.map +7 -0
- package/lib/mcp/sdk/mdb.js +208 -0
- package/lib/mcp/sdk/mdb.js.map +7 -0
- package/lib/mcp/sdk/proxyBackend.js +128 -0
- package/lib/mcp/sdk/proxyBackend.js.map +7 -0
- package/lib/mcp/sdk/server.js +190 -0
- package/lib/mcp/sdk/server.js.map +7 -0
- package/lib/mcp/sdk/tool.js +51 -0
- package/lib/mcp/sdk/tool.js.map +7 -0
- package/lib/mcp/test/browserBackend.js +98 -0
- package/lib/mcp/test/browserBackend.js.map +7 -0
- package/lib/mcp/test/generatorTools.js +122 -0
- package/lib/mcp/test/generatorTools.js.map +7 -0
- package/lib/mcp/test/plannerTools.js +46 -0
- package/lib/mcp/test/plannerTools.js.map +7 -0
- package/lib/mcp/test/seed.js +82 -0
- package/lib/mcp/test/seed.js.map +7 -0
- package/lib/mcp/test/streams.js +41 -0
- package/lib/mcp/test/streams.js.map +7 -0
- package/lib/mcp/test/testBackend.js +97 -0
- package/lib/mcp/test/testBackend.js.map +7 -0
- package/lib/mcp/test/testContext.js +216 -0
- package/lib/mcp/test/testContext.js.map +7 -0
- package/lib/mcp/test/testTool.js +30 -0
- package/lib/mcp/test/testTool.js.map +7 -0
- package/lib/mcp/test/testTools.js +111 -0
- package/lib/mcp/test/testTools.js.map +7 -0
- package/lib/mcpBundleImpl.js +41 -0
- package/lib/mcpBundleImpl.js.map +7 -0
- package/lib/plugins/gitCommitInfoPlugin.js +198 -0
- package/lib/plugins/gitCommitInfoPlugin.js.map +7 -0
- package/lib/plugins/index.js +28 -0
- package/lib/plugins/index.js.map +7 -0
- package/lib/plugins/webServerPlugin.js +233 -0
- package/lib/plugins/webServerPlugin.js.map +7 -0
- package/lib/program.js +412 -0
- package/lib/program.js.map +7 -0
- package/lib/reporters/base.js +609 -0
- package/lib/reporters/base.js.map +7 -0
- package/lib/reporters/blob.js +135 -0
- package/lib/reporters/blob.js.map +7 -0
- package/lib/reporters/dot.js +82 -0
- package/lib/reporters/dot.js.map +7 -0
- package/lib/reporters/empty.js +32 -0
- package/lib/reporters/empty.js.map +7 -0
- package/lib/reporters/github.js +128 -0
- package/lib/reporters/github.js.map +7 -0
- package/lib/reporters/html.js +623 -0
- package/lib/reporters/html.js.map +7 -0
- package/lib/reporters/internalReporter.js +130 -0
- package/lib/reporters/internalReporter.js.map +7 -0
- package/lib/reporters/json.js +254 -0
- package/lib/reporters/json.js.map +7 -0
- package/lib/reporters/junit.js +232 -0
- package/lib/reporters/junit.js.map +7 -0
- package/lib/reporters/line.js +113 -0
- package/lib/reporters/line.js.map +7 -0
- package/lib/reporters/list.js +231 -0
- package/lib/reporters/list.js.map +7 -0
- package/lib/reporters/listModeReporter.js +69 -0
- package/lib/reporters/listModeReporter.js.map +7 -0
- package/lib/reporters/markdown.js +144 -0
- package/lib/reporters/markdown.js.map +7 -0
- package/lib/reporters/merge.js +541 -0
- package/lib/reporters/merge.js.map +7 -0
- package/lib/reporters/multiplexer.js +104 -0
- package/lib/reporters/multiplexer.js.map +7 -0
- package/lib/reporters/reporterV2.js +102 -0
- package/lib/reporters/reporterV2.js.map +7 -0
- package/lib/reporters/teleEmitter.js +298 -0
- package/lib/reporters/teleEmitter.js.map +7 -0
- package/lib/reporters/versions/blobV1.js +16 -0
- package/lib/reporters/versions/blobV1.js.map +7 -0
- package/lib/runner/dispatcher.js +491 -0
- package/lib/runner/dispatcher.js.map +7 -0
- package/lib/runner/failureTracker.js +72 -0
- package/lib/runner/failureTracker.js.map +7 -0
- package/lib/runner/lastRun.js +77 -0
- package/lib/runner/lastRun.js.map +7 -0
- package/lib/runner/loadUtils.js +334 -0
- package/lib/runner/loadUtils.js.map +7 -0
- package/lib/runner/loaderHost.js +89 -0
- package/lib/runner/loaderHost.js.map +7 -0
- package/lib/runner/processHost.js +161 -0
- package/lib/runner/processHost.js.map +7 -0
- package/lib/runner/projectUtils.js +241 -0
- package/lib/runner/projectUtils.js.map +7 -0
- package/lib/runner/rebase.js +189 -0
- package/lib/runner/rebase.js.map +7 -0
- package/lib/runner/reporters.js +138 -0
- package/lib/runner/reporters.js.map +7 -0
- package/lib/runner/runner.js +110 -0
- package/lib/runner/sigIntWatcher.js +96 -0
- package/lib/runner/sigIntWatcher.js.map +7 -0
- package/lib/runner/taskRunner.js +127 -0
- package/lib/runner/taskRunner.js.map +7 -0
- package/lib/runner/tasks.js +410 -0
- package/lib/runner/tasks.js.map +7 -0
- package/lib/runner/testGroups.js +117 -0
- package/lib/runner/testGroups.js.map +7 -0
- package/lib/runner/testRunner.js +390 -0
- package/lib/runner/testRunner.js.map +7 -0
- package/lib/runner/testServer.js +267 -0
- package/lib/runner/testServer.js.map +7 -0
- package/lib/runner/uiModeReporter.js +30 -0
- package/lib/runner/uiModeReporter.js.map +7 -0
- package/lib/runner/vcs.js +72 -0
- package/lib/runner/vcs.js.map +7 -0
- package/lib/runner/watchMode.js +395 -0
- package/lib/runner/watchMode.js.map +7 -0
- package/lib/runner/workerHost.js +95 -0
- package/lib/runner/workerHost.js.map +7 -0
- package/lib/third_party/pirates.js +62 -0
- package/lib/third_party/pirates.js.map +7 -0
- package/lib/third_party/tsconfig-loader.js +103 -0
- package/lib/third_party/tsconfig-loader.js.map +7 -0
- package/lib/transform/babelBundle.js +43 -0
- package/lib/transform/babelBundle.js.map +7 -0
- package/lib/transform/babelBundleImpl.js +461 -0
- package/lib/transform/babelBundleImpl.js.map +7 -0
- package/lib/transform/compilationCache.js +272 -0
- package/lib/transform/compilationCache.js.map +7 -0
- package/lib/transform/esmLoader.js +104 -0
- package/lib/transform/esmLoader.js.map +7 -0
- package/lib/transform/portTransport.js +67 -0
- package/lib/transform/portTransport.js.map +7 -0
- package/lib/transform/transform.js +293 -0
- package/lib/transform/transform.js.map +7 -0
- package/lib/util.js +403 -0
- package/lib/util.js.map +7 -0
- package/lib/utilsBundle.js +43 -0
- package/lib/utilsBundle.js.map +7 -0
- package/lib/utilsBundleImpl.js +100 -0
- package/lib/utilsBundleImpl.js.map +7 -0
- package/lib/worker/fixtureRunner.js +258 -0
- package/lib/worker/fixtureRunner.js.map +7 -0
- package/lib/worker/testInfo.js +514 -0
- package/lib/worker/testInfo.js.map +7 -0
- package/lib/worker/testTracing.js +344 -0
- package/lib/worker/testTracing.js.map +7 -0
- package/lib/worker/timeoutManager.js +174 -0
- package/lib/worker/timeoutManager.js.map +7 -0
- package/lib/worker/util.js +31 -0
- package/lib/worker/util.js.map +7 -0
- package/lib/worker/workerMain.js +520 -0
- package/lib/worker/workerMain.js.map +7 -0
- package/package.json +74 -0
- package/test.d.ts +18 -0
- package/test.js +24 -0
- package/test.mjs +33 -0
- package/types/test.d.ts +10196 -0
- package/types/testReporter.d.ts +821 -0
|
@@ -0,0 +1,96 @@
|
|
|
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 utils_exports = {};
|
|
20
|
+
__export(utils_exports, {
|
|
21
|
+
callOnPageNoTrace: () => callOnPageNoTrace,
|
|
22
|
+
dateAsFileName: () => dateAsFileName,
|
|
23
|
+
generateLocators: () => generateLocators,
|
|
24
|
+
waitForCompletion: () => waitForCompletion
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(utils_exports);
|
|
27
|
+
var import_utils = require("playwright-core/lib/utils");
|
|
28
|
+
async function waitForCompletion(tab, callback) {
|
|
29
|
+
const requests = /* @__PURE__ */ new Set();
|
|
30
|
+
let frameNavigated = false;
|
|
31
|
+
let waitCallback = () => {
|
|
32
|
+
};
|
|
33
|
+
const waitBarrier = new Promise((f) => {
|
|
34
|
+
waitCallback = f;
|
|
35
|
+
});
|
|
36
|
+
const responseListener = (request) => {
|
|
37
|
+
requests.delete(request);
|
|
38
|
+
if (!requests.size)
|
|
39
|
+
waitCallback();
|
|
40
|
+
};
|
|
41
|
+
const requestListener = (request) => {
|
|
42
|
+
requests.add(request);
|
|
43
|
+
void request.response().then(() => responseListener(request)).catch(() => {
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
const frameNavigateListener = (frame) => {
|
|
47
|
+
if (frame.parentFrame())
|
|
48
|
+
return;
|
|
49
|
+
frameNavigated = true;
|
|
50
|
+
dispose();
|
|
51
|
+
clearTimeout(timeout);
|
|
52
|
+
void tab.waitForLoadState("load").then(waitCallback);
|
|
53
|
+
};
|
|
54
|
+
const onTimeout = () => {
|
|
55
|
+
dispose();
|
|
56
|
+
waitCallback();
|
|
57
|
+
};
|
|
58
|
+
tab.page.on("request", requestListener);
|
|
59
|
+
tab.page.on("requestfailed", responseListener);
|
|
60
|
+
tab.page.on("framenavigated", frameNavigateListener);
|
|
61
|
+
const timeout = setTimeout(onTimeout, 1e4);
|
|
62
|
+
const dispose = () => {
|
|
63
|
+
tab.page.off("request", requestListener);
|
|
64
|
+
tab.page.off("requestfailed", responseListener);
|
|
65
|
+
tab.page.off("framenavigated", frameNavigateListener);
|
|
66
|
+
clearTimeout(timeout);
|
|
67
|
+
};
|
|
68
|
+
try {
|
|
69
|
+
const result = await callback();
|
|
70
|
+
if (!requests.size && !frameNavigated)
|
|
71
|
+
waitCallback();
|
|
72
|
+
await waitBarrier;
|
|
73
|
+
await tab.waitForTimeout(1e3);
|
|
74
|
+
return result;
|
|
75
|
+
} finally {
|
|
76
|
+
dispose();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async function callOnPageNoTrace(page, callback) {
|
|
80
|
+
return await page._wrapApiCall(() => callback(page), { internal: true });
|
|
81
|
+
}
|
|
82
|
+
function dateAsFileName(extension) {
|
|
83
|
+
const date = /* @__PURE__ */ new Date();
|
|
84
|
+
return `page-${date.toISOString().replace(/[:.]/g, "-")}.${extension}`;
|
|
85
|
+
}
|
|
86
|
+
async function generateLocators(locator) {
|
|
87
|
+
const selectors = await locator.evaluate((el) => window.__injectedScript.generateSelector(el, { multiple: true, testIdAttributeName: "data-testid" }).selectors);
|
|
88
|
+
return selectors.map((s) => (0, import_utils.asLocator)("javascript", s));
|
|
89
|
+
}
|
|
90
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
91
|
+
0 && (module.exports = {
|
|
92
|
+
callOnPageNoTrace,
|
|
93
|
+
dateAsFileName,
|
|
94
|
+
generateLocators,
|
|
95
|
+
waitForCompletion
|
|
96
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/mcp/browser/tools/utils.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright (c) Microsoft Corporation.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// @ts-ignore\nimport { asLocator } from 'playwright-core/lib/utils';\n\nimport type * as playwright from 'playwright-core';\nimport type { Tab } from '../tab';\n\nexport async function waitForCompletion<R>(tab: Tab, callback: () => Promise<R>): Promise<R> {\n const requests = new Set<playwright.Request>();\n let frameNavigated = false;\n let waitCallback: () => void = () => {};\n const waitBarrier = new Promise<void>(f => { waitCallback = f; });\n\n const responseListener = (request: playwright.Request) => {\n requests.delete(request);\n if (!requests.size)\n waitCallback();\n };\n\n const requestListener = (request: playwright.Request) => {\n requests.add(request);\n void request.response().then(() => responseListener(request)).catch(() => {});\n };\n\n const frameNavigateListener = (frame: playwright.Frame) => {\n if (frame.parentFrame())\n return;\n frameNavigated = true;\n dispose();\n clearTimeout(timeout);\n void tab.waitForLoadState('load').then(waitCallback);\n };\n\n const onTimeout = () => {\n dispose();\n waitCallback();\n };\n\n tab.page.on('request', requestListener);\n tab.page.on('requestfailed', responseListener);\n tab.page.on('framenavigated', frameNavigateListener);\n const timeout = setTimeout(onTimeout, 10000);\n\n const dispose = () => {\n tab.page.off('request', requestListener);\n tab.page.off('requestfailed', responseListener);\n tab.page.off('framenavigated', frameNavigateListener);\n clearTimeout(timeout);\n };\n\n try {\n const result = await callback();\n if (!requests.size && !frameNavigated)\n waitCallback();\n await waitBarrier;\n await tab.waitForTimeout(1000);\n return result;\n } finally {\n dispose();\n }\n}\n\nexport async function callOnPageNoTrace<T>(page: playwright.Page, callback: (page: playwright.Page) => Promise<T>): Promise<T> {\n return await (page as any)._wrapApiCall(() => callback(page), { internal: true });\n}\n\nexport function dateAsFileName(extension: string): string {\n const date = new Date();\n return `page-${date.toISOString().replace(/[:.]/g, '-')}.${extension}`;\n}\n\nexport async function generateLocators(locator: playwright.Locator): Promise<string[]> {\n // Relies on process.env.PWTEST_UNDER_TEST environment variable: injects __injectedScript object for generating locators\n const selectors = (await locator.evaluate(el => (window as any).__injectedScript.generateSelector(el, { multiple: true, testIdAttributeName: 'data-testid' }).selectors)) as string[];\n return selectors.map(s => asLocator('javascript', s));\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBA,mBAA0B;AAK1B,eAAsB,kBAAqB,KAAU,UAAwC;AAC3F,QAAM,WAAW,oBAAI,IAAwB;AAC7C,MAAI,iBAAiB;AACrB,MAAI,eAA2B,MAAM;AAAA,EAAC;AACtC,QAAM,cAAc,IAAI,QAAc,OAAK;AAAE,mBAAe;AAAA,EAAG,CAAC;AAEhE,QAAM,mBAAmB,CAAC,YAAgC;AACxD,aAAS,OAAO,OAAO;AACvB,QAAI,CAAC,SAAS;AACZ,mBAAa;AAAA,EACjB;AAEA,QAAM,kBAAkB,CAAC,YAAgC;AACvD,aAAS,IAAI,OAAO;AACpB,SAAK,QAAQ,SAAS,EAAE,KAAK,MAAM,iBAAiB,OAAO,CAAC,EAAE,MAAM,MAAM;AAAA,IAAC,CAAC;AAAA,EAC9E;AAEA,QAAM,wBAAwB,CAAC,UAA4B;AACzD,QAAI,MAAM,YAAY;AACpB;AACF,qBAAiB;AACjB,YAAQ;AACR,iBAAa,OAAO;AACpB,SAAK,IAAI,iBAAiB,MAAM,EAAE,KAAK,YAAY;AAAA,EACrD;AAEA,QAAM,YAAY,MAAM;AACtB,YAAQ;AACR,iBAAa;AAAA,EACf;AAEA,MAAI,KAAK,GAAG,WAAW,eAAe;AACtC,MAAI,KAAK,GAAG,iBAAiB,gBAAgB;AAC7C,MAAI,KAAK,GAAG,kBAAkB,qBAAqB;AACnD,QAAM,UAAU,WAAW,WAAW,GAAK;AAE3C,QAAM,UAAU,MAAM;AACpB,QAAI,KAAK,IAAI,WAAW,eAAe;AACvC,QAAI,KAAK,IAAI,iBAAiB,gBAAgB;AAC9C,QAAI,KAAK,IAAI,kBAAkB,qBAAqB;AACpD,iBAAa,OAAO;AAAA,EACtB;AAEA,MAAI;AACF,UAAM,SAAS,MAAM,SAAS;AAC9B,QAAI,CAAC,SAAS,QAAQ,CAAC;AACrB,mBAAa;AACf,UAAM;AACN,UAAM,IAAI,eAAe,GAAI;AAC7B,WAAO;AAAA,EACT,UAAE;AACA,YAAQ;AAAA,EACV;AACF;AAEA,eAAsB,kBAAqB,MAAuB,UAA6D;AAC7H,SAAO,MAAO,KAAa,aAAa,MAAM,SAAS,IAAI,GAAG,EAAE,UAAU,KAAK,CAAC;AAClF;AAEO,SAAS,eAAe,WAA2B;AACxD,QAAM,OAAO,oBAAI,KAAK;AACtB,SAAO,QAAQ,KAAK,YAAY,EAAE,QAAQ,SAAS,GAAG,CAAC,IAAI,SAAS;AACtE;AAEA,eAAsB,iBAAiB,SAAgD;AAErF,QAAM,YAAa,MAAM,QAAQ,SAAS,QAAO,OAAe,iBAAiB,iBAAiB,IAAI,EAAE,UAAU,MAAM,qBAAqB,cAAc,CAAC,EAAE,SAAS;AACvK,SAAO,UAAU,IAAI,WAAK,wBAAU,cAAc,CAAC,CAAC;AACtD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
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 verify_exports = {};
|
|
30
|
+
__export(verify_exports, {
|
|
31
|
+
default: () => verify_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(verify_exports);
|
|
34
|
+
var import_bundle = require("../../sdk/bundle");
|
|
35
|
+
var import_tool = require("./tool");
|
|
36
|
+
var javascript = __toESM(require("../codegen"));
|
|
37
|
+
const verifyElement = (0, import_tool.defineTabTool)({
|
|
38
|
+
capability: "testing",
|
|
39
|
+
schema: {
|
|
40
|
+
name: "browser_verify_element_visible",
|
|
41
|
+
title: "Verify element visible",
|
|
42
|
+
description: "Verify element is visible on the page",
|
|
43
|
+
inputSchema: import_bundle.z.object({
|
|
44
|
+
role: import_bundle.z.string().describe('ROLE of the element. Can be found in the snapshot like this: `- {ROLE} "Accessible Name":`'),
|
|
45
|
+
accessibleName: import_bundle.z.string().describe('ACCESSIBLE_NAME of the element. Can be found in the snapshot like this: `- role "{ACCESSIBLE_NAME}"`')
|
|
46
|
+
}),
|
|
47
|
+
type: "assertion"
|
|
48
|
+
},
|
|
49
|
+
handle: async (tab, params, response) => {
|
|
50
|
+
const locator = tab.page.getByRole(params.role, { name: params.accessibleName });
|
|
51
|
+
if (await locator.count() === 0) {
|
|
52
|
+
response.addError(`Element with role "${params.role}" and accessible name "${params.accessibleName}" not found`);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
response.addCode(`await expect(page.getByRole(${javascript.escapeWithQuotes(params.role)}, { name: ${javascript.escapeWithQuotes(params.accessibleName)} })).toBeVisible();`);
|
|
56
|
+
response.addResult("Done");
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
const verifyText = (0, import_tool.defineTabTool)({
|
|
60
|
+
capability: "testing",
|
|
61
|
+
schema: {
|
|
62
|
+
name: "browser_verify_text_visible",
|
|
63
|
+
title: "Verify text visible",
|
|
64
|
+
description: `Verify text is visible on the page. Prefer ${verifyElement.schema.name} if possible.`,
|
|
65
|
+
inputSchema: import_bundle.z.object({
|
|
66
|
+
text: import_bundle.z.string().describe('TEXT to verify. Can be found in the snapshot like this: `- role "Accessible Name": {TEXT}` or like this: `- text: {TEXT}`')
|
|
67
|
+
}),
|
|
68
|
+
type: "assertion"
|
|
69
|
+
},
|
|
70
|
+
handle: async (tab, params, response) => {
|
|
71
|
+
const locator = tab.page.getByText(params.text).filter({ visible: true });
|
|
72
|
+
if (await locator.count() === 0) {
|
|
73
|
+
response.addError("Text not found");
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
response.addCode(`await expect(page.getByText(${javascript.escapeWithQuotes(params.text)})).toBeVisible();`);
|
|
77
|
+
response.addResult("Done");
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
const verifyList = (0, import_tool.defineTabTool)({
|
|
81
|
+
capability: "testing",
|
|
82
|
+
schema: {
|
|
83
|
+
name: "browser_verify_list_visible",
|
|
84
|
+
title: "Verify list visible",
|
|
85
|
+
description: "Verify list is visible on the page",
|
|
86
|
+
inputSchema: import_bundle.z.object({
|
|
87
|
+
element: import_bundle.z.string().describe("Human-readable list description"),
|
|
88
|
+
ref: import_bundle.z.string().describe("Exact target element reference that points to the list"),
|
|
89
|
+
items: import_bundle.z.array(import_bundle.z.string()).describe("Items to verify")
|
|
90
|
+
}),
|
|
91
|
+
type: "assertion"
|
|
92
|
+
},
|
|
93
|
+
handle: async (tab, params, response) => {
|
|
94
|
+
const { locator } = await tab.refLocator({ ref: params.ref, element: params.element });
|
|
95
|
+
const itemTexts = [];
|
|
96
|
+
for (const item of params.items) {
|
|
97
|
+
const itemLocator = locator.getByText(item);
|
|
98
|
+
if (await itemLocator.count() === 0) {
|
|
99
|
+
response.addError(`Item "${item}" not found`);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
itemTexts.push(await itemLocator.textContent());
|
|
103
|
+
}
|
|
104
|
+
const ariaSnapshot = `\`
|
|
105
|
+
- list:
|
|
106
|
+
${itemTexts.map((t) => ` - listitem: ${javascript.escapeWithQuotes(t, '"')}`).join("\n")}
|
|
107
|
+
\``;
|
|
108
|
+
response.addCode(`await expect(page.locator('body')).toMatchAriaSnapshot(${ariaSnapshot});`);
|
|
109
|
+
response.addResult("Done");
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
const verifyValue = (0, import_tool.defineTabTool)({
|
|
113
|
+
capability: "testing",
|
|
114
|
+
schema: {
|
|
115
|
+
name: "browser_verify_value",
|
|
116
|
+
title: "Verify value",
|
|
117
|
+
description: "Verify element value",
|
|
118
|
+
inputSchema: import_bundle.z.object({
|
|
119
|
+
type: import_bundle.z.enum(["textbox", "checkbox", "radio", "combobox", "slider"]).describe("Type of the element"),
|
|
120
|
+
element: import_bundle.z.string().describe("Human-readable element description"),
|
|
121
|
+
ref: import_bundle.z.string().describe("Exact target element reference that points to the element"),
|
|
122
|
+
value: import_bundle.z.string().describe('Value to verify. For checkbox, use "true" or "false".')
|
|
123
|
+
}),
|
|
124
|
+
type: "assertion"
|
|
125
|
+
},
|
|
126
|
+
handle: async (tab, params, response) => {
|
|
127
|
+
const { locator, resolved } = await tab.refLocator({ ref: params.ref, element: params.element });
|
|
128
|
+
const locatorSource = `page.${resolved}`;
|
|
129
|
+
if (params.type === "textbox" || params.type === "slider" || params.type === "combobox") {
|
|
130
|
+
const value = await locator.inputValue();
|
|
131
|
+
if (value !== params.value) {
|
|
132
|
+
response.addError(`Expected value "${params.value}", but got "${value}"`);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
response.addCode(`await expect(${locatorSource}).toHaveValue(${javascript.quote(params.value)});`);
|
|
136
|
+
} else if (params.type === "checkbox" || params.type === "radio") {
|
|
137
|
+
const value = await locator.isChecked();
|
|
138
|
+
if (value !== (params.value === "true")) {
|
|
139
|
+
response.addError(`Expected value "${params.value}", but got "${value}"`);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const matcher = value ? "toBeChecked" : "not.toBeChecked";
|
|
143
|
+
response.addCode(`await expect(${locatorSource}).${matcher}();`);
|
|
144
|
+
}
|
|
145
|
+
response.addResult("Done");
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
var verify_default = [
|
|
149
|
+
verifyElement,
|
|
150
|
+
verifyText,
|
|
151
|
+
verifyList,
|
|
152
|
+
verifyValue
|
|
153
|
+
];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/mcp/browser/tools/verify.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright (c) Microsoft Corporation.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { z } from '../../sdk/bundle';\nimport { defineTabTool } from './tool';\nimport * as javascript from '../codegen';\n\nconst verifyElement = defineTabTool({\n capability: 'testing',\n schema: {\n name: 'browser_verify_element_visible',\n title: 'Verify element visible',\n description: 'Verify element is visible on the page',\n inputSchema: z.object({\n role: z.string().describe('ROLE of the element. Can be found in the snapshot like this: \\`- {ROLE} \"Accessible Name\":\\`'),\n accessibleName: z.string().describe('ACCESSIBLE_NAME of the element. Can be found in the snapshot like this: \\`- role \"{ACCESSIBLE_NAME}\"\\`'),\n }),\n type: 'assertion',\n },\n\n handle: async (tab, params, response) => {\n const locator = tab.page.getByRole(params.role as any, { name: params.accessibleName });\n if (await locator.count() === 0) {\n response.addError(`Element with role \"${params.role}\" and accessible name \"${params.accessibleName}\" not found`);\n return;\n }\n\n response.addCode(`await expect(page.getByRole(${javascript.escapeWithQuotes(params.role)}, { name: ${javascript.escapeWithQuotes(params.accessibleName)} })).toBeVisible();`);\n response.addResult('Done');\n },\n});\n\nconst verifyText = defineTabTool({\n capability: 'testing',\n schema: {\n name: 'browser_verify_text_visible',\n title: 'Verify text visible',\n description: `Verify text is visible on the page. Prefer ${verifyElement.schema.name} if possible.`,\n inputSchema: z.object({\n text: z.string().describe('TEXT to verify. Can be found in the snapshot like this: \\`- role \"Accessible Name\": {TEXT}\\` or like this: \\`- text: {TEXT}\\`'),\n }),\n type: 'assertion',\n },\n\n handle: async (tab, params, response) => {\n const locator = tab.page.getByText(params.text).filter({ visible: true });\n if (await locator.count() === 0) {\n response.addError('Text not found');\n return;\n }\n\n response.addCode(`await expect(page.getByText(${javascript.escapeWithQuotes(params.text)})).toBeVisible();`);\n response.addResult('Done');\n },\n});\n\nconst verifyList = defineTabTool({\n capability: 'testing',\n schema: {\n name: 'browser_verify_list_visible',\n title: 'Verify list visible',\n description: 'Verify list is visible on the page',\n inputSchema: z.object({\n element: z.string().describe('Human-readable list description'),\n ref: z.string().describe('Exact target element reference that points to the list'),\n items: z.array(z.string()).describe('Items to verify'),\n }),\n type: 'assertion',\n },\n\n handle: async (tab, params, response) => {\n const { locator } = await tab.refLocator({ ref: params.ref, element: params.element });\n const itemTexts: string[] = [];\n for (const item of params.items) {\n const itemLocator = locator.getByText(item);\n if (await itemLocator.count() === 0) {\n response.addError(`Item \"${item}\" not found`);\n return;\n }\n itemTexts.push((await itemLocator.textContent())!);\n }\n const ariaSnapshot = `\\`\n- list:\n${itemTexts.map(t => ` - listitem: ${javascript.escapeWithQuotes(t, '\"')}`).join('\\n')}\n\\``;\n response.addCode(`await expect(page.locator('body')).toMatchAriaSnapshot(${ariaSnapshot});`);\n response.addResult('Done');\n },\n});\n\nconst verifyValue = defineTabTool({\n capability: 'testing',\n schema: {\n name: 'browser_verify_value',\n title: 'Verify value',\n description: 'Verify element value',\n inputSchema: z.object({\n type: z.enum(['textbox', 'checkbox', 'radio', 'combobox', 'slider']).describe('Type of the element'),\n element: z.string().describe('Human-readable element description'),\n ref: z.string().describe('Exact target element reference that points to the element'),\n value: z.string().describe('Value to verify. For checkbox, use \"true\" or \"false\".'),\n }),\n type: 'assertion',\n },\n\n handle: async (tab, params, response) => {\n const { locator, resolved } = await tab.refLocator({ ref: params.ref, element: params.element });\n const locatorSource = `page.${resolved}`;\n if (params.type === 'textbox' || params.type === 'slider' || params.type === 'combobox') {\n const value = await locator.inputValue();\n if (value !== params.value) {\n response.addError(`Expected value \"${params.value}\", but got \"${value}\"`);\n return;\n }\n response.addCode(`await expect(${locatorSource}).toHaveValue(${javascript.quote(params.value)});`);\n } else if (params.type === 'checkbox' || params.type === 'radio') {\n const value = await locator.isChecked();\n if (value !== (params.value === 'true')) {\n response.addError(`Expected value \"${params.value}\", but got \"${value}\"`);\n return;\n }\n const matcher = value ? 'toBeChecked' : 'not.toBeChecked';\n response.addCode(`await expect(${locatorSource}).${matcher}();`);\n }\n response.addResult('Done');\n },\n});\n\nexport default [\n verifyElement,\n verifyText,\n verifyList,\n verifyValue,\n];\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
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 wait_exports = {};
|
|
20
|
+
__export(wait_exports, {
|
|
21
|
+
default: () => wait_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(wait_exports);
|
|
24
|
+
var import_bundle = require("../../sdk/bundle");
|
|
25
|
+
var import_tool = require("./tool");
|
|
26
|
+
const wait = (0, import_tool.defineTool)({
|
|
27
|
+
capability: "core",
|
|
28
|
+
schema: {
|
|
29
|
+
name: "browser_wait_for",
|
|
30
|
+
title: "Wait for",
|
|
31
|
+
description: "Wait for text to appear or disappear or a specified time to pass",
|
|
32
|
+
inputSchema: import_bundle.z.object({
|
|
33
|
+
time: import_bundle.z.number().optional().describe("The time to wait in seconds"),
|
|
34
|
+
text: import_bundle.z.string().optional().describe("The text to wait for"),
|
|
35
|
+
textGone: import_bundle.z.string().optional().describe("The text to wait for to disappear")
|
|
36
|
+
}),
|
|
37
|
+
type: "assertion"
|
|
38
|
+
},
|
|
39
|
+
handle: async (context, params, response) => {
|
|
40
|
+
if (!params.text && !params.textGone && !params.time)
|
|
41
|
+
throw new Error("Either time, text or textGone must be provided");
|
|
42
|
+
if (params.time) {
|
|
43
|
+
response.addCode(`await new Promise(f => setTimeout(f, ${params.time} * 1000));`);
|
|
44
|
+
await new Promise((f) => setTimeout(f, Math.min(3e4, params.time * 1e3)));
|
|
45
|
+
}
|
|
46
|
+
const tab = context.currentTabOrDie();
|
|
47
|
+
const locator = params.text ? tab.page.getByText(params.text).first() : void 0;
|
|
48
|
+
const goneLocator = params.textGone ? tab.page.getByText(params.textGone).first() : void 0;
|
|
49
|
+
if (goneLocator) {
|
|
50
|
+
response.addCode(`await page.getByText(${JSON.stringify(params.textGone)}).first().waitFor({ state: 'hidden' });`);
|
|
51
|
+
await goneLocator.waitFor({ state: "hidden" });
|
|
52
|
+
}
|
|
53
|
+
if (locator) {
|
|
54
|
+
response.addCode(`await page.getByText(${JSON.stringify(params.text)}).first().waitFor({ state: 'visible' });`);
|
|
55
|
+
await locator.waitFor({ state: "visible" });
|
|
56
|
+
}
|
|
57
|
+
response.addResult(`Waited for ${params.text || params.textGone || params.time}`);
|
|
58
|
+
response.setIncludeSnapshot();
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
var wait_default = [
|
|
62
|
+
wait
|
|
63
|
+
];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/mcp/browser/tools/wait.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright (c) Microsoft Corporation.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { z } from '../../sdk/bundle';\nimport { defineTool } from './tool';\n\nconst wait = defineTool({\n capability: 'core',\n\n schema: {\n name: 'browser_wait_for',\n title: 'Wait for',\n description: 'Wait for text to appear or disappear or a specified time to pass',\n inputSchema: z.object({\n time: z.number().optional().describe('The time to wait in seconds'),\n text: z.string().optional().describe('The text to wait for'),\n textGone: z.string().optional().describe('The text to wait for to disappear'),\n }),\n type: 'assertion',\n },\n\n handle: async (context, params, response) => {\n if (!params.text && !params.textGone && !params.time)\n throw new Error('Either time, text or textGone must be provided');\n\n if (params.time) {\n response.addCode(`await new Promise(f => setTimeout(f, ${params.time!} * 1000));`);\n await new Promise(f => setTimeout(f, Math.min(30000, params.time! * 1000)));\n }\n\n const tab = context.currentTabOrDie();\n const locator = params.text ? tab.page.getByText(params.text).first() : undefined;\n const goneLocator = params.textGone ? tab.page.getByText(params.textGone).first() : undefined;\n\n if (goneLocator) {\n response.addCode(`await page.getByText(${JSON.stringify(params.textGone)}).first().waitFor({ state: 'hidden' });`);\n await goneLocator.waitFor({ state: 'hidden' });\n }\n\n if (locator) {\n response.addCode(`await page.getByText(${JSON.stringify(params.text)}).first().waitFor({ state: 'visible' });`);\n await locator.waitFor({ state: 'visible' });\n }\n\n response.addResult(`Waited for ${params.text || params.textGone || params.time}`);\n response.setIncludeSnapshot();\n },\n});\n\nexport default [\n wait,\n];\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,oBAAkB;AAClB,kBAA2B;AAE3B,MAAM,WAAO,wBAAW;AAAA,EACtB,YAAY;AAAA,EAEZ,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,IACP,aAAa;AAAA,IACb,aAAa,gBAAE,OAAO;AAAA,MACpB,MAAM,gBAAE,OAAO,EAAE,SAAS,EAAE,SAAS,6BAA6B;AAAA,MAClE,MAAM,gBAAE,OAAO,EAAE,SAAS,EAAE,SAAS,sBAAsB;AAAA,MAC3D,UAAU,gBAAE,OAAO,EAAE,SAAS,EAAE,SAAS,mCAAmC;AAAA,IAC9E,CAAC;AAAA,IACD,MAAM;AAAA,EACR;AAAA,EAEA,QAAQ,OAAO,SAAS,QAAQ,aAAa;AAC3C,QAAI,CAAC,OAAO,QAAQ,CAAC,OAAO,YAAY,CAAC,OAAO;AAC9C,YAAM,IAAI,MAAM,gDAAgD;AAElE,QAAI,OAAO,MAAM;AACf,eAAS,QAAQ,wCAAwC,OAAO,IAAK,YAAY;AACjF,YAAM,IAAI,QAAQ,OAAK,WAAW,GAAG,KAAK,IAAI,KAAO,OAAO,OAAQ,GAAI,CAAC,CAAC;AAAA,IAC5E;AAEA,UAAM,MAAM,QAAQ,gBAAgB;AACpC,UAAM,UAAU,OAAO,OAAO,IAAI,KAAK,UAAU,OAAO,IAAI,EAAE,MAAM,IAAI;AACxE,UAAM,cAAc,OAAO,WAAW,IAAI,KAAK,UAAU,OAAO,QAAQ,EAAE,MAAM,IAAI;AAEpF,QAAI,aAAa;AACf,eAAS,QAAQ,wBAAwB,KAAK,UAAU,OAAO,QAAQ,CAAC,yCAAyC;AACjH,YAAM,YAAY,QAAQ,EAAE,OAAO,SAAS,CAAC;AAAA,IAC/C;AAEA,QAAI,SAAS;AACX,eAAS,QAAQ,wBAAwB,KAAK,UAAU,OAAO,IAAI,CAAC,0CAA0C;AAC9G,YAAM,QAAQ,QAAQ,EAAE,OAAO,UAAU,CAAC;AAAA,IAC5C;AAEA,aAAS,UAAU,cAAc,OAAO,QAAQ,OAAO,YAAY,OAAO,IAAI,EAAE;AAChF,aAAS,mBAAmB;AAAA,EAC9B;AACF,CAAC;AAED,IAAO,eAAQ;AAAA,EACb;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
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 tools_exports = {};
|
|
30
|
+
__export(tools_exports, {
|
|
31
|
+
browserTools: () => browserTools,
|
|
32
|
+
filteredTools: () => filteredTools
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(tools_exports);
|
|
35
|
+
var import_common = __toESM(require("./tools/common"));
|
|
36
|
+
var import_console = __toESM(require("./tools/console"));
|
|
37
|
+
var import_dialogs = __toESM(require("./tools/dialogs"));
|
|
38
|
+
var import_evaluate = __toESM(require("./tools/evaluate"));
|
|
39
|
+
var import_files = __toESM(require("./tools/files"));
|
|
40
|
+
var import_form = __toESM(require("./tools/form"));
|
|
41
|
+
var import_install = __toESM(require("./tools/install"));
|
|
42
|
+
var import_keyboard = __toESM(require("./tools/keyboard"));
|
|
43
|
+
var import_mouse = __toESM(require("./tools/mouse"));
|
|
44
|
+
var import_navigate = __toESM(require("./tools/navigate"));
|
|
45
|
+
var import_network = __toESM(require("./tools/network"));
|
|
46
|
+
var import_pdf = __toESM(require("./tools/pdf"));
|
|
47
|
+
var import_snapshot = __toESM(require("./tools/snapshot"));
|
|
48
|
+
var import_screenshot = __toESM(require("./tools/screenshot"));
|
|
49
|
+
var import_tabs = __toESM(require("./tools/tabs"));
|
|
50
|
+
var import_tracing = __toESM(require("./tools/tracing"));
|
|
51
|
+
var import_wait = __toESM(require("./tools/wait"));
|
|
52
|
+
var import_verify = __toESM(require("./tools/verify"));
|
|
53
|
+
const browserTools = [
|
|
54
|
+
...import_common.default,
|
|
55
|
+
...import_console.default,
|
|
56
|
+
...import_dialogs.default,
|
|
57
|
+
...import_evaluate.default,
|
|
58
|
+
...import_files.default,
|
|
59
|
+
...import_form.default,
|
|
60
|
+
...import_install.default,
|
|
61
|
+
...import_keyboard.default,
|
|
62
|
+
...import_navigate.default,
|
|
63
|
+
...import_network.default,
|
|
64
|
+
...import_mouse.default,
|
|
65
|
+
...import_pdf.default,
|
|
66
|
+
...import_screenshot.default,
|
|
67
|
+
...import_snapshot.default,
|
|
68
|
+
...import_tabs.default,
|
|
69
|
+
...import_tracing.default,
|
|
70
|
+
...import_wait.default,
|
|
71
|
+
...import_verify.default
|
|
72
|
+
];
|
|
73
|
+
function filteredTools(config) {
|
|
74
|
+
return browserTools.filter((tool) => tool.capability.startsWith("core") || config.capabilities?.includes(tool.capability));
|
|
75
|
+
}
|
|
76
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
77
|
+
0 && (module.exports = {
|
|
78
|
+
browserTools,
|
|
79
|
+
filteredTools
|
|
80
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/mcp/browser/tools.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright (c) Microsoft Corporation.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport common from './tools/common';\nimport console from './tools/console';\nimport dialogs from './tools/dialogs';\nimport evaluate from './tools/evaluate';\nimport files from './tools/files';\nimport form from './tools/form';\nimport install from './tools/install';\nimport keyboard from './tools/keyboard';\nimport mouse from './tools/mouse';\nimport navigate from './tools/navigate';\nimport network from './tools/network';\nimport pdf from './tools/pdf';\nimport snapshot from './tools/snapshot';\nimport screenshot from './tools/screenshot';\nimport tabs from './tools/tabs';\nimport tracing from './tools/tracing';\nimport wait from './tools/wait';\nimport verify from './tools/verify';\n\nimport type { Tool } from './tools/tool';\nimport type { FullConfig } from './config';\n\nexport const browserTools: Tool<any>[] = [\n ...common,\n ...console,\n ...dialogs,\n ...evaluate,\n ...files,\n ...form,\n ...install,\n ...keyboard,\n ...navigate,\n ...network,\n ...mouse,\n ...pdf,\n ...screenshot,\n ...snapshot,\n ...tabs,\n ...tracing,\n ...wait,\n ...verify,\n];\n\nexport function filteredTools(config: FullConfig) {\n return browserTools.filter(tool => tool.capability.startsWith('core') || config.capabilities?.includes(tool.capability));\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,oBAAmB;AACnB,qBAAoB;AACpB,qBAAoB;AACpB,sBAAqB;AACrB,mBAAkB;AAClB,kBAAiB;AACjB,qBAAoB;AACpB,sBAAqB;AACrB,mBAAkB;AAClB,sBAAqB;AACrB,qBAAoB;AACpB,iBAAgB;AAChB,sBAAqB;AACrB,wBAAuB;AACvB,kBAAiB;AACjB,qBAAoB;AACpB,kBAAiB;AACjB,oBAAmB;AAKZ,MAAM,eAA4B;AAAA,EACvC,GAAG,cAAAA;AAAA,EACH,GAAG,eAAAC;AAAA,EACH,GAAG,eAAAC;AAAA,EACH,GAAG,gBAAAC;AAAA,EACH,GAAG,aAAAC;AAAA,EACH,GAAG,YAAAC;AAAA,EACH,GAAG,eAAAC;AAAA,EACH,GAAG,gBAAAC;AAAA,EACH,GAAG,gBAAAC;AAAA,EACH,GAAG,eAAAC;AAAA,EACH,GAAG,aAAAC;AAAA,EACH,GAAG,WAAAC;AAAA,EACH,GAAG,kBAAAC;AAAA,EACH,GAAG,gBAAAC;AAAA,EACH,GAAG,YAAAC;AAAA,EACH,GAAG,eAAAC;AAAA,EACH,GAAG,YAAAC;AAAA,EACH,GAAG,cAAAC;AACL;AAEO,SAAS,cAAc,QAAoB;AAChD,SAAO,aAAa,OAAO,UAAQ,KAAK,WAAW,WAAW,MAAM,KAAK,OAAO,cAAc,SAAS,KAAK,UAAU,CAAC;AACzH;",
|
|
6
|
+
"names": ["common", "console", "dialogs", "evaluate", "files", "form", "install", "keyboard", "navigate", "network", "mouse", "pdf", "screenshot", "snapshot", "tabs", "tracing", "wait", "verify"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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 watchdog_exports = {};
|
|
20
|
+
__export(watchdog_exports, {
|
|
21
|
+
setupExitWatchdog: () => setupExitWatchdog
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(watchdog_exports);
|
|
24
|
+
var import_browserContextFactory = require("./browserContextFactory");
|
|
25
|
+
var import_context = require("./context");
|
|
26
|
+
function setupExitWatchdog() {
|
|
27
|
+
let isExiting = false;
|
|
28
|
+
const handleExit = async () => {
|
|
29
|
+
if (isExiting)
|
|
30
|
+
return;
|
|
31
|
+
isExiting = true;
|
|
32
|
+
setTimeout(() => process.exit(0), 15e3);
|
|
33
|
+
await import_context.Context.disposeAll();
|
|
34
|
+
await import_browserContextFactory.SharedContextFactory.dispose();
|
|
35
|
+
process.exit(0);
|
|
36
|
+
};
|
|
37
|
+
process.stdin.on("close", handleExit);
|
|
38
|
+
process.on("SIGINT", handleExit);
|
|
39
|
+
process.on("SIGTERM", handleExit);
|
|
40
|
+
}
|
|
41
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
+
0 && (module.exports = {
|
|
43
|
+
setupExitWatchdog
|
|
44
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/mcp/browser/watchdog.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright (c) Microsoft Corporation.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { SharedContextFactory } from './browserContextFactory';\nimport { Context } from './context';\n\nexport function setupExitWatchdog() {\n let isExiting = false;\n const handleExit = async () => {\n if (isExiting)\n return;\n isExiting = true;\n // eslint-disable-next-line no-restricted-properties\n setTimeout(() => process.exit(0), 15000);\n await Context.disposeAll();\n await SharedContextFactory.dispose();\n // eslint-disable-next-line no-restricted-properties\n process.exit(0);\n };\n\n process.stdin.on('close', handleExit);\n process.on('SIGINT', handleExit);\n process.on('SIGTERM', handleExit);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,mCAAqC;AACrC,qBAAwB;AAEjB,SAAS,oBAAoB;AAClC,MAAI,YAAY;AAChB,QAAM,aAAa,YAAY;AAC7B,QAAI;AACF;AACF,gBAAY;AAEZ,eAAW,MAAM,QAAQ,KAAK,CAAC,GAAG,IAAK;AACvC,UAAM,uBAAQ,WAAW;AACzB,UAAM,kDAAqB,QAAQ;AAEnC,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,UAAQ,MAAM,GAAG,SAAS,UAAU;AACpC,UAAQ,GAAG,UAAU,UAAU;AAC/B,UAAQ,GAAG,WAAW,UAAU;AAClC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var config_d_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(config_d_exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/mcp/config.d.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright (c) Microsoft Corporation.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type * as playwright from 'playwright-core';\n\nexport type ToolCapability = 'core' | 'core-tabs' | 'core-install' | 'vision' | 'pdf' | 'testing' | 'tracing';\n\nexport type Config = {\n /**\n * The browser to use.\n */\n browser?: {\n /**\n * The type of browser to use.\n */\n browserName?: 'chromium' | 'firefox' | 'webkit';\n\n /**\n * Keep the browser profile in memory, do not save it to disk.\n */\n isolated?: boolean;\n\n /**\n * Path to a user data directory for browser profile persistence.\n * Temporary directory is created by default.\n */\n userDataDir?: string;\n\n /**\n * Launch options passed to\n * @see https://playwright.dev/docs/api/class-browsertype#browser-type-launch-persistent-context\n *\n * This is useful for settings options like `channel`, `headless`, `executablePath`, etc.\n */\n launchOptions?: playwright.LaunchOptions;\n\n /**\n * Context options for the browser context.\n *\n * This is useful for settings options like `viewport`.\n */\n contextOptions?: playwright.BrowserContextOptions;\n\n /**\n * Chrome DevTools Protocol endpoint to connect to an existing browser instance in case of Chromium family browsers.\n */\n cdpEndpoint?: string;\n\n /**\n * CDP headers to send with the connect request.\n */\n cdpHeaders?: Record<string, string>;\n\n /**\n * Remote endpoint to connect to an existing Playwright server.\n */\n remoteEndpoint?: string;\n\n /**\n * Paths to JavaScript files to add as initialization scripts.\n * The scripts will be evaluated in every page before any of the page's scripts.\n */\n initScript?: string[];\n },\n\n server?: {\n /**\n * The port to listen on for SSE or MCP transport.\n */\n port?: number;\n\n /**\n * The host to bind the server to. Default is localhost. Use 0.0.0.0 to bind to all interfaces.\n */\n host?: string;\n\n /**\n * The hosts this server is allowed to serve from. Defaults to the host server is bound to.\n * This is not for CORS, but rather for the DNS rebinding protection.\n */\n allowedHosts?: string[];\n },\n\n /**\n * List of enabled tool capabilities. Possible values:\n * - 'core': Core browser automation features.\n * - 'pdf': PDF generation and manipulation.\n * - 'vision': Coordinate-based interactions.\n */\n capabilities?: ToolCapability[];\n\n /**\n * Whether to save the Playwright session into the output directory.\n */\n saveSession?: boolean;\n\n /**\n * Whether to save the Playwright trace of the session into the output directory.\n */\n saveTrace?: boolean;\n\n /**\n * If specified, saves the Playwright video of the session into the output directory.\n */\n saveVideo?: {\n width: number;\n height: number;\n };\n\n /**\n * Reuse the same browser context between all connected HTTP clients.\n */\n sharedBrowserContext?: boolean;\n\n /**\n * Secrets are used to prevent LLM from getting sensitive data while\n * automating scenarios such as authentication.\n * Prefer the browser.contextOptions.storageState over secrets file as a more secure alternative.\n */\n secrets?: Record<string, string>;\n\n /**\n * The directory to save output files.\n */\n outputDir?: string;\n\n network?: {\n /**\n * List of origins to allow the browser to request. Default is to allow all. Origins matching both `allowedOrigins` and `blockedOrigins` will be blocked.\n */\n allowedOrigins?: string[];\n\n /**\n * List of origins to block the browser to request. Origins matching both `allowedOrigins` and `blockedOrigins` will be blocked.\n */\n blockedOrigins?: string[];\n };\n\n /**\n * Specify the attribute to use for test ids, defaults to \"data-testid\".\n */\n testIdAttribute?: string;\n\n timeouts?: {\n /*\n * Configures default action timeout: https://playwright.dev/docs/api/class-page#page-set-default-timeout. Defaults to 5000ms.\n */\n action?: number;\n\n /*\n * Configures default navigation timeout: https://playwright.dev/docs/api/class-page#page-set-default-navigation-timeout. Defaults to 60000ms.\n */\n navigation?: number;\n };\n\n /**\n * Whether to send image responses to the client. Can be \"allow\", \"omit\", or \"auto\". Defaults to \"auto\", which sends images if the client can display them.\n */\n imageResponses?: 'allow' | 'omit';\n};\n\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|