@playwright/mcp 0.0.36-alpha-2025-09-02 → 0.0.36-alpha-2025-09-04
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/README.md +1 -1
- package/cli.js +1 -1
- package/index.d.ts +1 -1
- package/index.js +2 -2
- package/lib/{browserContextFactory.js → browser/browserContextFactory.js} +76 -36
- package/lib/{browserServerBackend.js → browser/browserServerBackend.js} +24 -22
- package/lib/{utils → browser}/codegen.js +8 -3
- package/lib/{config.js → browser/config.js} +43 -26
- package/lib/{context.js → browser/context.js} +27 -30
- package/lib/{response.js → browser/response.js} +14 -14
- package/lib/{sessionLog.js → browser/sessionLog.js} +23 -18
- package/lib/{tab.js → browser/tab.js} +29 -27
- package/lib/{tools → browser/tools}/common.js +11 -9
- package/lib/{tools → browser/tools}/console.js +7 -5
- package/lib/{tools → browser/tools}/dialogs.js +9 -7
- package/lib/browser/tools/evaluate.js +88 -0
- package/lib/{tools → browser/tools}/files.js +8 -6
- package/lib/browser/tools/form.js +92 -0
- package/lib/{tools → browser/tools}/install.js +18 -14
- package/lib/browser/tools/keyboard.js +113 -0
- package/lib/{tools → browser/tools}/mouse.js +18 -16
- package/lib/{tools → browser/tools}/navigate.js +10 -8
- package/lib/{tools → browser/tools}/network.js +7 -5
- package/lib/browser/tools/pdf.js +76 -0
- package/lib/browser/tools/screenshot.js +115 -0
- package/lib/browser/tools/snapshot.js +175 -0
- package/lib/{tools → browser/tools}/tabs.js +9 -7
- package/lib/{tools → browser/tools}/tool.js +6 -2
- package/lib/{tools → browser/tools}/utils.js +10 -5
- package/lib/{tools → browser/tools}/verify.js +59 -24
- package/lib/{tools → browser/tools}/wait.js +10 -8
- package/lib/browser/tools.js +61 -0
- package/lib/extension/cdpRelay.js +85 -48
- package/lib/extension/extensionContextFactory.js +48 -11
- package/lib/extension/protocol.js +4 -1
- package/lib/index.js +47 -12
- package/lib/{utils/log.js → log.js} +11 -4
- package/lib/{utils/package.js → package.js} +9 -5
- package/lib/program.js +68 -39
- package/lib/sdk/bundle.js +79 -0
- package/lib/{mcp → sdk}/http.js +57 -17
- package/lib/{mcp → sdk}/inProcessTransport.js +15 -20
- package/lib/{mcp → sdk}/manualPromise.js +11 -9
- package/lib/{mcp → sdk}/mdb.js +77 -38
- package/lib/{mcp → sdk}/proxyBackend.js +53 -16
- package/lib/sdk/server.js +164 -0
- package/lib/{mcp → sdk}/tool.js +8 -4
- package/lib/vscode/host.js +64 -35
- package/lib/vscode/main.js +48 -13
- package/package.json +6 -7
- package/lib/loop/loop.js +0 -69
- package/lib/loop/loopClaude.js +0 -152
- package/lib/loop/loopOpenAI.js +0 -141
- package/lib/loop/main.js +0 -60
- package/lib/loopTools/context.js +0 -67
- package/lib/loopTools/main.js +0 -54
- package/lib/loopTools/perform.js +0 -32
- package/lib/loopTools/snapshot.js +0 -29
- package/lib/loopTools/tool.js +0 -18
- package/lib/mcp/server.js +0 -123
- package/lib/tools/evaluate.js +0 -53
- package/lib/tools/form.js +0 -57
- package/lib/tools/keyboard.js +0 -78
- package/lib/tools/pdf.js +0 -40
- package/lib/tools/screenshot.js +0 -79
- package/lib/tools/snapshot.js +0 -139
- package/lib/tools.js +0 -54
- package/lib/utils/fileUtils.js +0 -36
- package/lib/utils/guid.js +0 -22
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
24
|
+
}) : (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
o[k2] = m[k];
|
|
27
|
+
}));
|
|
28
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
+
}) : function(o, v) {
|
|
31
|
+
o["default"] = v;
|
|
32
|
+
});
|
|
33
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
34
|
+
var ownKeys = function(o) {
|
|
35
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
36
|
+
var ar = [];
|
|
37
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
38
|
+
return ar;
|
|
39
|
+
};
|
|
40
|
+
return ownKeys(o);
|
|
41
|
+
};
|
|
42
|
+
return function (mod) {
|
|
43
|
+
if (mod && mod.__esModule) return mod;
|
|
44
|
+
var result = {};
|
|
45
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
46
|
+
__setModuleDefault(result, mod);
|
|
47
|
+
return result;
|
|
48
|
+
};
|
|
49
|
+
})();
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
exports.elementSchema = void 0;
|
|
52
|
+
const bundle_1 = require("../../sdk/bundle");
|
|
53
|
+
const tool_1 = require("./tool");
|
|
54
|
+
const javascript = __importStar(require("../codegen"));
|
|
55
|
+
const utils_1 = require("./utils");
|
|
56
|
+
const snapshot = (0, tool_1.defineTool)({
|
|
57
|
+
capability: 'core',
|
|
58
|
+
schema: {
|
|
59
|
+
name: 'browser_snapshot',
|
|
60
|
+
title: 'Page snapshot',
|
|
61
|
+
description: 'Capture accessibility snapshot of the current page, this is better than screenshot',
|
|
62
|
+
inputSchema: bundle_1.z.object({}),
|
|
63
|
+
type: 'readOnly',
|
|
64
|
+
},
|
|
65
|
+
handle: async (context, params, response) => {
|
|
66
|
+
await context.ensureTab();
|
|
67
|
+
response.setIncludeSnapshot();
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
exports.elementSchema = bundle_1.z.object({
|
|
71
|
+
element: bundle_1.z.string().describe('Human-readable element description used to obtain permission to interact with the element'),
|
|
72
|
+
ref: bundle_1.z.string().describe('Exact target element reference from the page snapshot'),
|
|
73
|
+
});
|
|
74
|
+
const clickSchema = exports.elementSchema.extend({
|
|
75
|
+
doubleClick: bundle_1.z.boolean().optional().describe('Whether to perform a double click instead of a single click'),
|
|
76
|
+
button: bundle_1.z.enum(['left', 'right', 'middle']).optional().describe('Button to click, defaults to left'),
|
|
77
|
+
});
|
|
78
|
+
const click = (0, tool_1.defineTabTool)({
|
|
79
|
+
capability: 'core',
|
|
80
|
+
schema: {
|
|
81
|
+
name: 'browser_click',
|
|
82
|
+
title: 'Click',
|
|
83
|
+
description: 'Perform click on a web page',
|
|
84
|
+
inputSchema: clickSchema,
|
|
85
|
+
type: 'destructive',
|
|
86
|
+
},
|
|
87
|
+
handle: async (tab, params, response) => {
|
|
88
|
+
response.setIncludeSnapshot();
|
|
89
|
+
const locator = await tab.refLocator(params);
|
|
90
|
+
const button = params.button;
|
|
91
|
+
const buttonAttr = button ? `{ button: '${button}' }` : '';
|
|
92
|
+
if (params.doubleClick)
|
|
93
|
+
response.addCode(`await page.${await (0, utils_1.generateLocator)(locator)}.dblclick(${buttonAttr});`);
|
|
94
|
+
else
|
|
95
|
+
response.addCode(`await page.${await (0, utils_1.generateLocator)(locator)}.click(${buttonAttr});`);
|
|
96
|
+
await tab.waitForCompletion(async () => {
|
|
97
|
+
if (params.doubleClick)
|
|
98
|
+
await locator.dblclick({ button });
|
|
99
|
+
else
|
|
100
|
+
await locator.click({ button });
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
const drag = (0, tool_1.defineTabTool)({
|
|
105
|
+
capability: 'core',
|
|
106
|
+
schema: {
|
|
107
|
+
name: 'browser_drag',
|
|
108
|
+
title: 'Drag mouse',
|
|
109
|
+
description: 'Perform drag and drop between two elements',
|
|
110
|
+
inputSchema: bundle_1.z.object({
|
|
111
|
+
startElement: bundle_1.z.string().describe('Human-readable source element description used to obtain the permission to interact with the element'),
|
|
112
|
+
startRef: bundle_1.z.string().describe('Exact source element reference from the page snapshot'),
|
|
113
|
+
endElement: bundle_1.z.string().describe('Human-readable target element description used to obtain the permission to interact with the element'),
|
|
114
|
+
endRef: bundle_1.z.string().describe('Exact target element reference from the page snapshot'),
|
|
115
|
+
}),
|
|
116
|
+
type: 'destructive',
|
|
117
|
+
},
|
|
118
|
+
handle: async (tab, params, response) => {
|
|
119
|
+
response.setIncludeSnapshot();
|
|
120
|
+
const [startLocator, endLocator] = await tab.refLocators([
|
|
121
|
+
{ ref: params.startRef, element: params.startElement },
|
|
122
|
+
{ ref: params.endRef, element: params.endElement },
|
|
123
|
+
]);
|
|
124
|
+
await tab.waitForCompletion(async () => {
|
|
125
|
+
await startLocator.dragTo(endLocator);
|
|
126
|
+
});
|
|
127
|
+
response.addCode(`await page.${await (0, utils_1.generateLocator)(startLocator)}.dragTo(page.${await (0, utils_1.generateLocator)(endLocator)});`);
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
const hover = (0, tool_1.defineTabTool)({
|
|
131
|
+
capability: 'core',
|
|
132
|
+
schema: {
|
|
133
|
+
name: 'browser_hover',
|
|
134
|
+
title: 'Hover mouse',
|
|
135
|
+
description: 'Hover over element on page',
|
|
136
|
+
inputSchema: exports.elementSchema,
|
|
137
|
+
type: 'readOnly',
|
|
138
|
+
},
|
|
139
|
+
handle: async (tab, params, response) => {
|
|
140
|
+
response.setIncludeSnapshot();
|
|
141
|
+
const locator = await tab.refLocator(params);
|
|
142
|
+
response.addCode(`await page.${await (0, utils_1.generateLocator)(locator)}.hover();`);
|
|
143
|
+
await tab.waitForCompletion(async () => {
|
|
144
|
+
await locator.hover();
|
|
145
|
+
});
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
const selectOptionSchema = exports.elementSchema.extend({
|
|
149
|
+
values: bundle_1.z.array(bundle_1.z.string()).describe('Array of values to select in the dropdown. This can be a single value or multiple values.'),
|
|
150
|
+
});
|
|
151
|
+
const selectOption = (0, tool_1.defineTabTool)({
|
|
152
|
+
capability: 'core',
|
|
153
|
+
schema: {
|
|
154
|
+
name: 'browser_select_option',
|
|
155
|
+
title: 'Select option',
|
|
156
|
+
description: 'Select an option in a dropdown',
|
|
157
|
+
inputSchema: selectOptionSchema,
|
|
158
|
+
type: 'destructive',
|
|
159
|
+
},
|
|
160
|
+
handle: async (tab, params, response) => {
|
|
161
|
+
response.setIncludeSnapshot();
|
|
162
|
+
const locator = await tab.refLocator(params);
|
|
163
|
+
response.addCode(`await page.${await (0, utils_1.generateLocator)(locator)}.selectOption(${javascript.formatObject(params.values)});`);
|
|
164
|
+
await tab.waitForCompletion(async () => {
|
|
165
|
+
await locator.selectOption(params.values);
|
|
166
|
+
});
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
exports.default = [
|
|
170
|
+
snapshot,
|
|
171
|
+
click,
|
|
172
|
+
drag,
|
|
173
|
+
hover,
|
|
174
|
+
selectOption,
|
|
175
|
+
];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Copyright (c) Microsoft Corporation.
|
|
3
4
|
*
|
|
@@ -13,17 +14,18 @@
|
|
|
13
14
|
* See the License for the specific language governing permissions and
|
|
14
15
|
* limitations under the License.
|
|
15
16
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const bundle_1 = require("../../sdk/bundle");
|
|
19
|
+
const tool_1 = require("./tool");
|
|
20
|
+
const browserTabs = (0, tool_1.defineTool)({
|
|
19
21
|
capability: 'core-tabs',
|
|
20
22
|
schema: {
|
|
21
23
|
name: 'browser_tabs',
|
|
22
24
|
title: 'Manage tabs',
|
|
23
25
|
description: 'List, create, close, or select a browser tab.',
|
|
24
|
-
inputSchema: z.object({
|
|
25
|
-
action: z.enum(['list', 'new', 'close', 'select']).describe('Operation to perform'),
|
|
26
|
-
index: z.number().optional().describe('Tab index, used for close/select. If omitted for close, current tab is closed.'),
|
|
26
|
+
inputSchema: bundle_1.z.object({
|
|
27
|
+
action: bundle_1.z.enum(['list', 'new', 'close', 'select']).describe('Operation to perform'),
|
|
28
|
+
index: bundle_1.z.number().optional().describe('Tab index, used for close/select. If omitted for close, current tab is closed.'),
|
|
27
29
|
}),
|
|
28
30
|
type: 'destructive',
|
|
29
31
|
},
|
|
@@ -54,6 +56,6 @@ const browserTabs = defineTool({
|
|
|
54
56
|
}
|
|
55
57
|
},
|
|
56
58
|
});
|
|
57
|
-
|
|
59
|
+
exports.default = [
|
|
58
60
|
browserTabs,
|
|
59
61
|
];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Copyright (c) Microsoft Corporation.
|
|
3
4
|
*
|
|
@@ -13,10 +14,13 @@
|
|
|
13
14
|
* See the License for the specific language governing permissions and
|
|
14
15
|
* limitations under the License.
|
|
15
16
|
*/
|
|
16
|
-
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.defineTool = defineTool;
|
|
19
|
+
exports.defineTabTool = defineTabTool;
|
|
20
|
+
function defineTool(tool) {
|
|
17
21
|
return tool;
|
|
18
22
|
}
|
|
19
|
-
|
|
23
|
+
function defineTabTool(tool) {
|
|
20
24
|
return {
|
|
21
25
|
...tool,
|
|
22
26
|
handle: async (context, params, response) => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Copyright (c) Microsoft Corporation.
|
|
3
4
|
*
|
|
@@ -13,9 +14,13 @@
|
|
|
13
14
|
* See the License for the specific language governing permissions and
|
|
14
15
|
* limitations under the License.
|
|
15
16
|
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.waitForCompletion = waitForCompletion;
|
|
19
|
+
exports.generateLocator = generateLocator;
|
|
20
|
+
exports.callOnPageNoTrace = callOnPageNoTrace;
|
|
16
21
|
// @ts-ignore
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
const utils_1 = require("playwright-core/lib/utils");
|
|
23
|
+
async function waitForCompletion(tab, callback) {
|
|
19
24
|
const requests = new Set();
|
|
20
25
|
let frameNavigated = false;
|
|
21
26
|
let waitCallback = () => { };
|
|
@@ -60,15 +65,15 @@ export async function waitForCompletion(tab, callback) {
|
|
|
60
65
|
dispose();
|
|
61
66
|
}
|
|
62
67
|
}
|
|
63
|
-
|
|
68
|
+
async function generateLocator(locator) {
|
|
64
69
|
try {
|
|
65
70
|
const { resolvedSelector } = await locator._resolveSelector();
|
|
66
|
-
return asLocator('javascript', resolvedSelector);
|
|
71
|
+
return (0, utils_1.asLocator)('javascript', resolvedSelector);
|
|
67
72
|
}
|
|
68
73
|
catch (e) {
|
|
69
74
|
throw new Error('Ref not found, likely because element was removed. Use browser_snapshot to see what elements are currently on the page.');
|
|
70
75
|
}
|
|
71
76
|
}
|
|
72
|
-
|
|
77
|
+
async function callOnPageNoTrace(page, callback) {
|
|
73
78
|
return await page._wrapApiCall(() => callback(page), { internal: true });
|
|
74
79
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Copyright (c) Microsoft Corporation.
|
|
3
4
|
*
|
|
@@ -13,19 +14,53 @@
|
|
|
13
14
|
* See the License for the specific language governing permissions and
|
|
14
15
|
* limitations under the License.
|
|
15
16
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
24
|
+
}) : (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
o[k2] = m[k];
|
|
27
|
+
}));
|
|
28
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
+
}) : function(o, v) {
|
|
31
|
+
o["default"] = v;
|
|
32
|
+
});
|
|
33
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
34
|
+
var ownKeys = function(o) {
|
|
35
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
36
|
+
var ar = [];
|
|
37
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
38
|
+
return ar;
|
|
39
|
+
};
|
|
40
|
+
return ownKeys(o);
|
|
41
|
+
};
|
|
42
|
+
return function (mod) {
|
|
43
|
+
if (mod && mod.__esModule) return mod;
|
|
44
|
+
var result = {};
|
|
45
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
46
|
+
__setModuleDefault(result, mod);
|
|
47
|
+
return result;
|
|
48
|
+
};
|
|
49
|
+
})();
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
const bundle_1 = require("../../sdk/bundle");
|
|
52
|
+
const tool_1 = require("./tool");
|
|
53
|
+
const javascript = __importStar(require("../codegen"));
|
|
54
|
+
const utils_1 = require("./utils");
|
|
55
|
+
const verifyElement = (0, tool_1.defineTabTool)({
|
|
21
56
|
capability: 'verify',
|
|
22
57
|
schema: {
|
|
23
58
|
name: 'browser_verify_element_visible',
|
|
24
59
|
title: 'Verify element visible',
|
|
25
60
|
description: 'Verify element is visible on the page',
|
|
26
|
-
inputSchema: z.object({
|
|
27
|
-
role: z.string().describe('ROLE of the element. Can be found in the snapshot like this: \`- {ROLE} "Accessible Name":\`'),
|
|
28
|
-
accessibleName: z.string().describe('ACCESSIBLE_NAME of the element. Can be found in the snapshot like this: \`- role "{ACCESSIBLE_NAME}"\`'),
|
|
61
|
+
inputSchema: bundle_1.z.object({
|
|
62
|
+
role: bundle_1.z.string().describe('ROLE of the element. Can be found in the snapshot like this: \`- {ROLE} "Accessible Name":\`'),
|
|
63
|
+
accessibleName: bundle_1.z.string().describe('ACCESSIBLE_NAME of the element. Can be found in the snapshot like this: \`- role "{ACCESSIBLE_NAME}"\`'),
|
|
29
64
|
}),
|
|
30
65
|
type: 'readOnly',
|
|
31
66
|
},
|
|
@@ -39,14 +74,14 @@ const verifyElement = defineTabTool({
|
|
|
39
74
|
response.addResult('Done');
|
|
40
75
|
},
|
|
41
76
|
});
|
|
42
|
-
const verifyText = defineTabTool({
|
|
77
|
+
const verifyText = (0, tool_1.defineTabTool)({
|
|
43
78
|
capability: 'verify',
|
|
44
79
|
schema: {
|
|
45
80
|
name: 'browser_verify_text_visible',
|
|
46
81
|
title: 'Verify text visible',
|
|
47
82
|
description: `Verify text is visible on the page. Prefer ${verifyElement.schema.name} if possible.`,
|
|
48
|
-
inputSchema: z.object({
|
|
49
|
-
text: z.string().describe('TEXT to verify. Can be found in the snapshot like this: \`- role "Accessible Name": {TEXT}\` or like this: \`- text: {TEXT}\`'),
|
|
83
|
+
inputSchema: bundle_1.z.object({
|
|
84
|
+
text: bundle_1.z.string().describe('TEXT to verify. Can be found in the snapshot like this: \`- role "Accessible Name": {TEXT}\` or like this: \`- text: {TEXT}\`'),
|
|
50
85
|
}),
|
|
51
86
|
type: 'readOnly',
|
|
52
87
|
},
|
|
@@ -60,16 +95,16 @@ const verifyText = defineTabTool({
|
|
|
60
95
|
response.addResult('Done');
|
|
61
96
|
},
|
|
62
97
|
});
|
|
63
|
-
const verifyList = defineTabTool({
|
|
98
|
+
const verifyList = (0, tool_1.defineTabTool)({
|
|
64
99
|
capability: 'verify',
|
|
65
100
|
schema: {
|
|
66
101
|
name: 'browser_verify_list_visible',
|
|
67
102
|
title: 'Verify list visible',
|
|
68
103
|
description: 'Verify list is visible on the page',
|
|
69
|
-
inputSchema: z.object({
|
|
70
|
-
element: z.string().describe('Human-readable list description'),
|
|
71
|
-
ref: z.string().describe('Exact target element reference that points to the list'),
|
|
72
|
-
items: z.array(z.string()).describe('Items to verify'),
|
|
104
|
+
inputSchema: bundle_1.z.object({
|
|
105
|
+
element: bundle_1.z.string().describe('Human-readable list description'),
|
|
106
|
+
ref: bundle_1.z.string().describe('Exact target element reference that points to the list'),
|
|
107
|
+
items: bundle_1.z.array(bundle_1.z.string()).describe('Items to verify'),
|
|
73
108
|
}),
|
|
74
109
|
type: 'readOnly',
|
|
75
110
|
},
|
|
@@ -92,23 +127,23 @@ ${itemTexts.map(t => ` - listitem: ${javascript.escapeWithQuotes(t, '"')}`).joi
|
|
|
92
127
|
response.addResult('Done');
|
|
93
128
|
},
|
|
94
129
|
});
|
|
95
|
-
const verifyValue = defineTabTool({
|
|
130
|
+
const verifyValue = (0, tool_1.defineTabTool)({
|
|
96
131
|
capability: 'verify',
|
|
97
132
|
schema: {
|
|
98
133
|
name: 'browser_verify_value',
|
|
99
134
|
title: 'Verify value',
|
|
100
135
|
description: 'Verify element value',
|
|
101
|
-
inputSchema: z.object({
|
|
102
|
-
type: z.enum(['textbox', 'checkbox', 'radio', 'combobox', 'slider']).describe('Type of the element'),
|
|
103
|
-
element: z.string().describe('Human-readable element description'),
|
|
104
|
-
ref: z.string().describe('Exact target element reference that points to the element'),
|
|
105
|
-
value: z.string().describe('Value to verify. For checkbox, use "true" or "false".'),
|
|
136
|
+
inputSchema: bundle_1.z.object({
|
|
137
|
+
type: bundle_1.z.enum(['textbox', 'checkbox', 'radio', 'combobox', 'slider']).describe('Type of the element'),
|
|
138
|
+
element: bundle_1.z.string().describe('Human-readable element description'),
|
|
139
|
+
ref: bundle_1.z.string().describe('Exact target element reference that points to the element'),
|
|
140
|
+
value: bundle_1.z.string().describe('Value to verify. For checkbox, use "true" or "false".'),
|
|
106
141
|
}),
|
|
107
142
|
type: 'readOnly',
|
|
108
143
|
},
|
|
109
144
|
handle: async (tab, params, response) => {
|
|
110
145
|
const locator = await tab.refLocator({ ref: params.ref, element: params.element });
|
|
111
|
-
const locatorSource = `page.${await generateLocator(locator)}`;
|
|
146
|
+
const locatorSource = `page.${await (0, utils_1.generateLocator)(locator)}`;
|
|
112
147
|
if (params.type === 'textbox' || params.type === 'slider' || params.type === 'combobox') {
|
|
113
148
|
const value = await locator.inputValue();
|
|
114
149
|
if (value !== params.value) {
|
|
@@ -129,7 +164,7 @@ const verifyValue = defineTabTool({
|
|
|
129
164
|
response.addResult('Done');
|
|
130
165
|
},
|
|
131
166
|
});
|
|
132
|
-
|
|
167
|
+
exports.default = [
|
|
133
168
|
verifyElement,
|
|
134
169
|
verifyText,
|
|
135
170
|
verifyList,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Copyright (c) Microsoft Corporation.
|
|
3
4
|
*
|
|
@@ -13,18 +14,19 @@
|
|
|
13
14
|
* See the License for the specific language governing permissions and
|
|
14
15
|
* limitations under the License.
|
|
15
16
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const bundle_1 = require("../../sdk/bundle");
|
|
19
|
+
const tool_1 = require("./tool");
|
|
20
|
+
const wait = (0, tool_1.defineTool)({
|
|
19
21
|
capability: 'core',
|
|
20
22
|
schema: {
|
|
21
23
|
name: 'browser_wait_for',
|
|
22
24
|
title: 'Wait for',
|
|
23
25
|
description: 'Wait for text to appear or disappear or a specified time to pass',
|
|
24
|
-
inputSchema: z.object({
|
|
25
|
-
time: z.number().optional().describe('The time to wait in seconds'),
|
|
26
|
-
text: z.string().optional().describe('The text to wait for'),
|
|
27
|
-
textGone: z.string().optional().describe('The text to wait for to disappear'),
|
|
26
|
+
inputSchema: bundle_1.z.object({
|
|
27
|
+
time: bundle_1.z.number().optional().describe('The time to wait in seconds'),
|
|
28
|
+
text: bundle_1.z.string().optional().describe('The text to wait for'),
|
|
29
|
+
textGone: bundle_1.z.string().optional().describe('The text to wait for to disappear'),
|
|
28
30
|
}),
|
|
29
31
|
type: 'readOnly',
|
|
30
32
|
},
|
|
@@ -50,6 +52,6 @@ const wait = defineTool({
|
|
|
50
52
|
response.setIncludeSnapshot();
|
|
51
53
|
},
|
|
52
54
|
});
|
|
53
|
-
|
|
55
|
+
exports.default = [
|
|
54
56
|
wait,
|
|
55
57
|
];
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.allTools = void 0;
|
|
22
|
+
exports.filteredTools = filteredTools;
|
|
23
|
+
const common_1 = __importDefault(require("./tools/common"));
|
|
24
|
+
const console_1 = __importDefault(require("./tools/console"));
|
|
25
|
+
const dialogs_1 = __importDefault(require("./tools/dialogs"));
|
|
26
|
+
const evaluate_1 = __importDefault(require("./tools/evaluate"));
|
|
27
|
+
const files_1 = __importDefault(require("./tools/files"));
|
|
28
|
+
const form_1 = __importDefault(require("./tools/form"));
|
|
29
|
+
const install_1 = __importDefault(require("./tools/install"));
|
|
30
|
+
const keyboard_1 = __importDefault(require("./tools/keyboard"));
|
|
31
|
+
const mouse_1 = __importDefault(require("./tools/mouse"));
|
|
32
|
+
const navigate_1 = __importDefault(require("./tools/navigate"));
|
|
33
|
+
const network_1 = __importDefault(require("./tools/network"));
|
|
34
|
+
const pdf_1 = __importDefault(require("./tools/pdf"));
|
|
35
|
+
const snapshot_1 = __importDefault(require("./tools/snapshot"));
|
|
36
|
+
const tabs_1 = __importDefault(require("./tools/tabs"));
|
|
37
|
+
const screenshot_1 = __importDefault(require("./tools/screenshot"));
|
|
38
|
+
const wait_1 = __importDefault(require("./tools/wait"));
|
|
39
|
+
const verify_1 = __importDefault(require("./tools/verify"));
|
|
40
|
+
exports.allTools = [
|
|
41
|
+
...common_1.default,
|
|
42
|
+
...console_1.default,
|
|
43
|
+
...dialogs_1.default,
|
|
44
|
+
...evaluate_1.default,
|
|
45
|
+
...files_1.default,
|
|
46
|
+
...form_1.default,
|
|
47
|
+
...install_1.default,
|
|
48
|
+
...keyboard_1.default,
|
|
49
|
+
...navigate_1.default,
|
|
50
|
+
...network_1.default,
|
|
51
|
+
...mouse_1.default,
|
|
52
|
+
...pdf_1.default,
|
|
53
|
+
...screenshot_1.default,
|
|
54
|
+
...snapshot_1.default,
|
|
55
|
+
...tabs_1.default,
|
|
56
|
+
...wait_1.default,
|
|
57
|
+
...verify_1.default,
|
|
58
|
+
];
|
|
59
|
+
function filteredTools(config) {
|
|
60
|
+
return exports.allTools.filter(tool => { var _a; return tool.capability.startsWith('core') || ((_a = config.capabilities) === null || _a === void 0 ? void 0 : _a.includes(tool.capability)); });
|
|
61
|
+
}
|