@midscene/web 1.12.6-beta-20260910093036.0 → 1.12.6
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/dist/es/bridge-mode/io-client.mjs +1 -1
- package/dist/es/bridge-mode/io-server.mjs +2 -2
- package/dist/es/bridge-mode/io-server.mjs.map +1 -1
- package/dist/es/bridge-mode/page-browser-side.mjs +1 -1
- package/dist/es/bridge-mode/page-browser-side.mjs.map +1 -1
- package/dist/es/cli.mjs +1 -1
- package/dist/es/playwright/browser-agent.mjs +9 -1
- package/dist/es/playwright/browser-agent.mjs.map +1 -1
- package/dist/es/playwright/page-agent.mjs +19 -1
- package/dist/es/playwright/page-agent.mjs.map +1 -1
- package/dist/es/playwright/test-runner/agent-nodes.mjs +13 -0
- package/dist/es/playwright/test-runner/agent-nodes.mjs.map +1 -0
- package/dist/es/playwright/test-runner/clear-cookies.mjs +45 -0
- package/dist/es/playwright/test-runner/clear-cookies.mjs.map +1 -0
- package/dist/es/playwright/test-runner/cookies.mjs +162 -0
- package/dist/es/playwright/test-runner/cookies.mjs.map +1 -0
- package/dist/es/playwright/test-runner/goto-url.mjs +60 -0
- package/dist/es/playwright/test-runner/goto-url.mjs.map +1 -0
- package/dist/es/playwright/test-runner/index.mjs +6 -0
- package/dist/es/playwright/test-runner/types.mjs +0 -0
- package/dist/es/playwright/test-runner/utils.mjs +28 -0
- package/dist/es/playwright/test-runner/utils.mjs.map +1 -0
- package/dist/es/playwright/test-runner/viewport.mjs +35 -0
- package/dist/es/playwright/test-runner/viewport.mjs.map +1 -0
- package/dist/lib/bridge-mode/io-client.js +1 -1
- package/dist/lib/bridge-mode/io-server.js +2 -2
- package/dist/lib/bridge-mode/io-server.js.map +1 -1
- package/dist/lib/bridge-mode/page-browser-side.js +1 -1
- package/dist/lib/bridge-mode/page-browser-side.js.map +1 -1
- package/dist/lib/cli.js +1 -1
- package/dist/lib/playwright/browser-agent.js +9 -1
- package/dist/lib/playwright/browser-agent.js.map +1 -1
- package/dist/lib/playwright/page-agent.js +19 -1
- package/dist/lib/playwright/page-agent.js.map +1 -1
- package/dist/lib/playwright/test-runner/agent-nodes.js +47 -0
- package/dist/lib/playwright/test-runner/agent-nodes.js.map +1 -0
- package/dist/lib/playwright/test-runner/clear-cookies.js +82 -0
- package/dist/lib/playwright/test-runner/clear-cookies.js.map +1 -0
- package/dist/lib/playwright/test-runner/cookies.js +199 -0
- package/dist/lib/playwright/test-runner/cookies.js.map +1 -0
- package/dist/lib/playwright/test-runner/goto-url.js +97 -0
- package/dist/lib/playwright/test-runner/goto-url.js.map +1 -0
- package/dist/lib/playwright/test-runner/index.js +54 -0
- package/dist/lib/playwright/test-runner/index.js.map +1 -0
- package/dist/lib/playwright/test-runner/types.js +20 -0
- package/dist/lib/playwright/test-runner/types.js.map +1 -0
- package/dist/lib/playwright/test-runner/utils.js +68 -0
- package/dist/lib/playwright/test-runner/utils.js.map +1 -0
- package/dist/lib/playwright/test-runner/viewport.js +72 -0
- package/dist/lib/playwright/test-runner/viewport.js.map +1 -0
- package/dist/types/playwright/agent.d.ts +2 -0
- package/dist/types/playwright/browser-agent.d.ts +5 -0
- package/dist/types/playwright/page-agent.d.ts +8 -1
- package/dist/types/playwright/test-runner/agent-nodes.d.ts +2 -0
- package/dist/types/playwright/test-runner/clear-cookies.d.ts +16 -0
- package/dist/types/playwright/test-runner/cookies.d.ts +32 -0
- package/dist/types/playwright/test-runner/goto-url.d.ts +25 -0
- package/dist/types/playwright/test-runner/index.d.ts +10 -0
- package/dist/types/playwright/test-runner/types.d.ts +41 -0
- package/dist/types/playwright/test-runner/utils.d.ts +4 -0
- package/dist/types/playwright/test-runner/viewport.d.ts +13 -0
- package/package.json +10 -4
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
requirePlaywrightAgent: ()=>requirePlaywrightAgent,
|
|
28
|
+
resolveWebUrl: ()=>resolveWebUrl,
|
|
29
|
+
throwIfAborted: ()=>throwIfAborted
|
|
30
|
+
});
|
|
31
|
+
const SUPPORTED_WEB_PROTOCOLS = new Set([
|
|
32
|
+
'http:',
|
|
33
|
+
'https:'
|
|
34
|
+
]);
|
|
35
|
+
const throwIfAborted = (signal, operation)=>{
|
|
36
|
+
if (signal.aborted) throw signal.reason ?? new Error(`${operation} aborted.`);
|
|
37
|
+
};
|
|
38
|
+
const resolveWebUrl = (target, baseUrl, label)=>{
|
|
39
|
+
const trimmed = target.trim();
|
|
40
|
+
if (!trimmed) throw new TypeError(`${label} must not be blank.`);
|
|
41
|
+
let resolved;
|
|
42
|
+
try {
|
|
43
|
+
resolved = void 0 === baseUrl ? new URL(trimmed) : new URL(trimmed, baseUrl);
|
|
44
|
+
} catch (error) {
|
|
45
|
+
throw new TypeError(void 0 === baseUrl ? `${label} must be an absolute HTTP(S) URL.` : `${label} is not a valid URL.`, {
|
|
46
|
+
cause: error
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
if (!SUPPORTED_WEB_PROTOCOLS.has(resolved.protocol)) throw new TypeError(`${label} does not support the ${resolved.protocol} protocol.`);
|
|
50
|
+
return resolved.toString();
|
|
51
|
+
};
|
|
52
|
+
const requirePlaywrightAgent = (agent)=>{
|
|
53
|
+
if (!agent || 'object' != typeof agent || !('interface' in agent) || !agent.interface || 'object' != typeof agent.interface || !('underlyingPage' in agent.interface) || !agent.interface.underlyingPage) throw new TypeError('getAgent() must return a Playwright Agent with an underlying Page.');
|
|
54
|
+
return agent;
|
|
55
|
+
};
|
|
56
|
+
exports.requirePlaywrightAgent = __webpack_exports__.requirePlaywrightAgent;
|
|
57
|
+
exports.resolveWebUrl = __webpack_exports__.resolveWebUrl;
|
|
58
|
+
exports.throwIfAborted = __webpack_exports__.throwIfAborted;
|
|
59
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
60
|
+
"requirePlaywrightAgent",
|
|
61
|
+
"resolveWebUrl",
|
|
62
|
+
"throwIfAborted"
|
|
63
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
64
|
+
Object.defineProperty(exports, '__esModule', {
|
|
65
|
+
value: true
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playwright/test-runner/utils.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/playwright/test-runner/utils.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { PlaywrightTestRunnerAgent } from './types';\n\nconst SUPPORTED_WEB_PROTOCOLS = new Set(['http:', 'https:']);\n\nexport const throwIfAborted = (signal: AbortSignal, operation: string) => {\n if (signal.aborted) {\n throw signal.reason ?? new Error(`${operation} aborted.`);\n }\n};\n\nexport const resolveWebUrl = (\n target: string,\n baseUrl: string | undefined,\n label: string,\n): string => {\n const trimmed = target.trim();\n if (!trimmed) throw new TypeError(`${label} must not be blank.`);\n\n let resolved: URL;\n try {\n resolved =\n baseUrl === undefined ? new URL(trimmed) : new URL(trimmed, baseUrl);\n } catch (error) {\n throw new TypeError(\n baseUrl === undefined\n ? `${label} must be an absolute HTTP(S) URL.`\n : `${label} is not a valid URL.`,\n { cause: error },\n );\n }\n if (!SUPPORTED_WEB_PROTOCOLS.has(resolved.protocol)) {\n throw new TypeError(\n `${label} does not support the ${resolved.protocol} protocol.`,\n );\n }\n return resolved.toString();\n};\n\nexport const requirePlaywrightAgent = (\n agent: unknown,\n): PlaywrightTestRunnerAgent => {\n if (\n !agent ||\n typeof agent !== 'object' ||\n !('interface' in agent) ||\n !agent.interface ||\n typeof agent.interface !== 'object' ||\n !('underlyingPage' in agent.interface) ||\n !agent.interface.underlyingPage\n ) {\n throw new TypeError(\n 'getAgent() must return a Playwright Agent with an underlying Page.',\n );\n }\n return agent as PlaywrightTestRunnerAgent;\n};\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","SUPPORTED_WEB_PROTOCOLS","Set","throwIfAborted","signal","operation","Error","resolveWebUrl","target","baseUrl","label","trimmed","TypeError","resolved","undefined","URL","error","requirePlaywrightAgent","agent"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;ACJA,MAAMI,0BAA0B,IAAIC,IAAI;IAAC;IAAS;CAAS;AAEpD,MAAMC,iBAAiB,CAACC,QAAqBC;IAClD,IAAID,OAAO,OAAO,EAChB,MAAMA,OAAO,MAAM,IAAI,IAAIE,MAAM,GAAGD,UAAU,SAAS,CAAC;AAE5D;AAEO,MAAME,gBAAgB,CAC3BC,QACAC,SACAC;IAEA,MAAMC,UAAUH,OAAO,IAAI;IAC3B,IAAI,CAACG,SAAS,MAAM,IAAIC,UAAU,GAAGF,MAAM,mBAAmB,CAAC;IAE/D,IAAIG;IACJ,IAAI;QACFA,WACEJ,AAAYK,WAAZL,UAAwB,IAAIM,IAAIJ,WAAW,IAAII,IAAIJ,SAASF;IAChE,EAAE,OAAOO,OAAO;QACd,MAAM,IAAIJ,UACRH,AAAYK,WAAZL,UACI,GAAGC,MAAM,iCAAiC,CAAC,GAC3C,GAAGA,MAAM,oBAAoB,CAAC,EAClC;YAAE,OAAOM;QAAM;IAEnB;IACA,IAAI,CAACf,wBAAwB,GAAG,CAACY,SAAS,QAAQ,GAChD,MAAM,IAAID,UACR,GAAGF,MAAM,sBAAsB,EAAEG,SAAS,QAAQ,CAAC,UAAU,CAAC;IAGlE,OAAOA,SAAS,QAAQ;AAC1B;AAEO,MAAMI,yBAAyB,CACpCC;IAEA,IACE,CAACA,SACD,AAAiB,YAAjB,OAAOA,SACP,CAAE,gBAAeA,KAAI,KACrB,CAACA,MAAM,SAAS,IAChB,AAA2B,YAA3B,OAAOA,MAAM,SAAS,IACtB,CAAE,qBAAoBA,MAAM,SAAQ,KACpC,CAACA,MAAM,SAAS,CAAC,cAAc,EAE/B,MAAM,IAAIN,UACR;IAGJ,OAAOM;AACT"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
setViewportSizeInputSchema: ()=>setViewportSizeInputSchema,
|
|
28
|
+
setViewportSizeNode: ()=>setViewportSizeNode
|
|
29
|
+
});
|
|
30
|
+
const v4_namespaceObject = require("zod/v4");
|
|
31
|
+
const external_utils_js_namespaceObject = require("./utils.js");
|
|
32
|
+
const setViewportSizeInputSchema = v4_namespaceObject.z.strictObject({
|
|
33
|
+
width: v4_namespaceObject.z.number().int().positive().describe('Viewport width in CSS pixels.'),
|
|
34
|
+
height: v4_namespaceObject.z.number().int().positive().describe('Viewport height in CSS pixels.')
|
|
35
|
+
});
|
|
36
|
+
const setViewportSizeNode = {
|
|
37
|
+
name: 'setViewportSize',
|
|
38
|
+
title: 'Set the browser viewport size',
|
|
39
|
+
description: 'Set the current Playwright Page viewport size in CSS pixels and return the effective size.',
|
|
40
|
+
stringInputKey: false,
|
|
41
|
+
inputSchema: setViewportSizeInputSchema,
|
|
42
|
+
async execute (agent, input, executionContext) {
|
|
43
|
+
const ctx = {
|
|
44
|
+
...executionContext,
|
|
45
|
+
input,
|
|
46
|
+
context: (0, external_utils_js_namespaceObject.requirePlaywrightAgent)(agent)
|
|
47
|
+
};
|
|
48
|
+
(0, external_utils_js_namespaceObject.throwIfAborted)(ctx.signal, 'setViewportSize');
|
|
49
|
+
const page = ctx.context.interface.underlyingPage;
|
|
50
|
+
await page.setViewportSize({
|
|
51
|
+
width: ctx.input.width,
|
|
52
|
+
height: ctx.input.height
|
|
53
|
+
});
|
|
54
|
+
const viewport = page.viewportSize();
|
|
55
|
+
if (!viewport) throw new Error('Playwright did not report an effective viewport size.');
|
|
56
|
+
return {
|
|
57
|
+
summary: `Set viewport to ${viewport.width}x${viewport.height}`,
|
|
58
|
+
data: viewport
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
exports.setViewportSizeInputSchema = __webpack_exports__.setViewportSizeInputSchema;
|
|
63
|
+
exports.setViewportSizeNode = __webpack_exports__.setViewportSizeNode;
|
|
64
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
65
|
+
"setViewportSizeInputSchema",
|
|
66
|
+
"setViewportSizeNode"
|
|
67
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
68
|
+
Object.defineProperty(exports, '__esModule', {
|
|
69
|
+
value: true
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=viewport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playwright/test-runner/viewport.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/playwright/test-runner/viewport.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { AgentTestRunnerNodeDefinition } from '@midscene/core/agent';\nimport { z } from 'zod/v4';\nimport { requirePlaywrightAgent, throwIfAborted } from './utils';\n\n/** Input schema for the Playwright setViewportSize Node. */\nexport const setViewportSizeInputSchema = z.strictObject({\n width: z.number().int().positive().describe('Viewport width in CSS pixels.'),\n height: z\n .number()\n .int()\n .positive()\n .describe('Viewport height in CSS pixels.'),\n});\n\n/** Validated input accepted by the Playwright setViewportSize Node. */\nexport type SetViewportSizeNodeInput = z.infer<\n typeof setViewportSizeInputSchema\n>;\n\nexport const setViewportSizeNode: AgentTestRunnerNodeDefinition<\n z.output<typeof setViewportSizeInputSchema>,\n { width: number; height: number }\n> = {\n name: 'setViewportSize',\n title: 'Set the browser viewport size',\n description:\n 'Set the current Playwright Page viewport size in CSS pixels and return the effective size.',\n stringInputKey: false,\n inputSchema: setViewportSizeInputSchema,\n async execute(agent, input, executionContext) {\n const ctx = {\n ...executionContext,\n input,\n context: requirePlaywrightAgent(agent),\n };\n throwIfAborted(ctx.signal, 'setViewportSize');\n const page = ctx.context.interface.underlyingPage;\n await page.setViewportSize({\n width: ctx.input.width,\n height: ctx.input.height,\n });\n const viewport = page.viewportSize();\n if (!viewport) {\n throw new Error('Playwright did not report an effective viewport size.');\n }\n return {\n summary: `Set viewport to ${viewport.width}x${viewport.height}`,\n data: viewport,\n };\n },\n};\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","setViewportSizeInputSchema","z","setViewportSizeNode","agent","input","executionContext","ctx","requirePlaywrightAgent","throwIfAborted","page","viewport","Error"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;ACDO,MAAMI,6BAA6BC,mBAAAA,CAAAA,CAAAA,YAAc,CAAC;IACvD,OAAOA,mBAAAA,CAAAA,CAAAA,MAAQ,GAAG,GAAG,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC5C,QAAQA,mBAAAA,CAAAA,CAAAA,MACC,GACN,GAAG,GACH,QAAQ,GACR,QAAQ,CAAC;AACd;AAOO,MAAMC,sBAGT;IACF,MAAM;IACN,OAAO;IACP,aACE;IACF,gBAAgB;IAChB,aAAaF;IACb,MAAM,SAAQG,KAAK,EAAEC,KAAK,EAAEC,gBAAgB;QAC1C,MAAMC,MAAM;YACV,GAAGD,gBAAgB;YACnBD;YACA,SAASG,AAAAA,IAAAA,kCAAAA,sBAAAA,AAAAA,EAAuBJ;QAClC;QACAK,IAAAA,kCAAAA,cAAAA,AAAAA,EAAeF,IAAI,MAAM,EAAE;QAC3B,MAAMG,OAAOH,IAAI,OAAO,CAAC,SAAS,CAAC,cAAc;QACjD,MAAMG,KAAK,eAAe,CAAC;YACzB,OAAOH,IAAI,KAAK,CAAC,KAAK;YACtB,QAAQA,IAAI,KAAK,CAAC,MAAM;QAC1B;QACA,MAAMI,WAAWD,KAAK,YAAY;QAClC,IAAI,CAACC,UACH,MAAM,IAAIC,MAAM;QAElB,OAAO;YACL,SAAS,CAAC,gBAAgB,EAAED,SAAS,KAAK,CAAC,CAAC,EAAEA,SAAS,MAAM,EAAE;YAC/D,MAAMA;QACR;IACF;AACF"}
|
|
@@ -3,3 +3,5 @@ export { WebPage as PlaywrightWebPage } from './page';
|
|
|
3
3
|
export type { WebPageAgentOpt } from '../web-element';
|
|
4
4
|
export { PlaywrightPageAgent, PlaywrightAgent } from './page-agent';
|
|
5
5
|
export { PlaywrightBrowserAgent, type PlaywrightBrowserAgentCreateOpt, type PlaywrightBrowserAgentOpt, } from './browser-agent';
|
|
6
|
+
export type { PlaywrightPageAgentOpt } from './page-agent';
|
|
7
|
+
export type { PlaywrightTestRunnerOptions } from './test-runner/types';
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { WebAgentCore } from '../common/browser-agent';
|
|
2
2
|
import type { WebPageAgentOpt } from '../web-element';
|
|
3
|
+
import type { AgentTestRunnerNodeDefinition } from '@midscene/core/agent';
|
|
3
4
|
import type { BrowserContext as PlaywrightBrowserContext, Page as PlaywrightPage } from 'playwright';
|
|
4
5
|
import { WebPage as PlaywrightWebPage } from './page';
|
|
6
|
+
import type { PlaywrightTestRunnerOptions } from './test-runner/types';
|
|
5
7
|
export type PlaywrightBrowserAgentOpt = Omit<WebPageAgentOpt, 'forceSameTabNavigation'> & {
|
|
8
|
+
testRunner?: PlaywrightTestRunnerOptions;
|
|
6
9
|
autoFollowNewPage?: boolean;
|
|
7
10
|
newPageTimeout?: number;
|
|
8
11
|
};
|
|
@@ -10,6 +13,8 @@ export type PlaywrightBrowserAgentCreateOpt = PlaywrightBrowserAgentOpt & {
|
|
|
10
13
|
initialPage?: PlaywrightPage;
|
|
11
14
|
};
|
|
12
15
|
export declare class PlaywrightBrowserAgent extends WebAgentCore<PlaywrightWebPage> {
|
|
16
|
+
static getTestRunnerNodeDefinitions(): readonly AgentTestRunnerNodeDefinition[];
|
|
17
|
+
readonly testRunner?: PlaywrightTestRunnerOptions;
|
|
13
18
|
private readonly pageManager;
|
|
14
19
|
constructor(context: PlaywrightBrowserContext, initialPage: PlaywrightPage, opts?: PlaywrightBrowserAgentOpt);
|
|
15
20
|
static create(context: PlaywrightBrowserContext, opts?: PlaywrightBrowserAgentCreateOpt): Promise<PlaywrightBrowserAgent>;
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { WebAgentCore } from '../common/browser-agent';
|
|
2
2
|
import type { WebPageAgentOpt } from '../web-element';
|
|
3
|
+
import type { AgentTestRunnerNodeDefinition } from '@midscene/core/agent';
|
|
3
4
|
import type { Page as PlaywrightPage } from 'playwright';
|
|
4
5
|
import { WebPage as PlaywrightWebPage } from './page';
|
|
6
|
+
import type { PlaywrightTestRunnerOptions } from './test-runner/types';
|
|
7
|
+
export type PlaywrightPageAgentOpt = WebPageAgentOpt & {
|
|
8
|
+
testRunner?: PlaywrightTestRunnerOptions;
|
|
9
|
+
};
|
|
5
10
|
export declare class PlaywrightPageAgent extends WebAgentCore<PlaywrightWebPage> {
|
|
6
|
-
|
|
11
|
+
static getTestRunnerNodeDefinitions(): readonly AgentTestRunnerNodeDefinition[];
|
|
12
|
+
readonly testRunner?: PlaywrightTestRunnerOptions;
|
|
13
|
+
constructor(page: PlaywrightPage, opts?: PlaywrightPageAgentOpt);
|
|
7
14
|
}
|
|
8
15
|
export { PlaywrightPageAgent as PlaywrightAgent };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AgentTestRunnerNodeDefinition } from '@midscene/core/agent';
|
|
2
|
+
import type { BrowserContext } from 'playwright';
|
|
3
|
+
import { z } from 'zod/v4';
|
|
4
|
+
type CookieClearOptions = NonNullable<Parameters<BrowserContext['clearCookies']>[0]>;
|
|
5
|
+
/** Input schema for the Playwright clearCookies Node. */
|
|
6
|
+
export declare const clearCookiesInputSchema: z.ZodObject<{
|
|
7
|
+
name: z.ZodOptional<z.ZodString>;
|
|
8
|
+
domain: z.ZodOptional<z.ZodString>;
|
|
9
|
+
path: z.ZodOptional<z.ZodString>;
|
|
10
|
+
}, z.core.$strict>;
|
|
11
|
+
/** Validated input accepted by the Playwright clearCookies Node. */
|
|
12
|
+
export type ClearCookiesNodeInput = z.infer<typeof clearCookiesInputSchema>;
|
|
13
|
+
export declare const clearCookiesNode: AgentTestRunnerNodeDefinition<z.output<typeof clearCookiesInputSchema>, {
|
|
14
|
+
filters: CookieClearOptions;
|
|
15
|
+
}>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AgentTestRunnerNodeDefinition } from '@midscene/core/agent';
|
|
2
|
+
import { z } from 'zod/v4';
|
|
3
|
+
type CookieSourceReference = {
|
|
4
|
+
kind: 'env';
|
|
5
|
+
name: string;
|
|
6
|
+
} | {
|
|
7
|
+
kind: 'profile';
|
|
8
|
+
name: string;
|
|
9
|
+
} | {
|
|
10
|
+
kind: 'storage-state';
|
|
11
|
+
name: string;
|
|
12
|
+
};
|
|
13
|
+
/** Input schema for the Playwright setCookies Node. */
|
|
14
|
+
export declare const setCookiesInputSchema: z.ZodObject<{
|
|
15
|
+
cookiesEnv: z.ZodOptional<z.ZodString>;
|
|
16
|
+
profile: z.ZodOptional<z.ZodString>;
|
|
17
|
+
storageStatePath: z.ZodOptional<z.ZodString>;
|
|
18
|
+
url: z.ZodOptional<z.ZodString>;
|
|
19
|
+
}, z.core.$strict>;
|
|
20
|
+
/** Validated input accepted by the Playwright setCookies Node. */
|
|
21
|
+
export type SetCookiesNodeInput = z.infer<typeof setCookiesInputSchema>;
|
|
22
|
+
/** Secret-free metadata returned by the Playwright setCookies Node. */
|
|
23
|
+
export interface SetCookiesNodeResult {
|
|
24
|
+
/** Kind of configured reference used to resolve the cookies. */
|
|
25
|
+
source: CookieSourceReference['kind'];
|
|
26
|
+
/** Environment variable, profile, or storage-state reference name. */
|
|
27
|
+
sourceName: string;
|
|
28
|
+
/** Number of cookies passed to the BrowserContext. */
|
|
29
|
+
count: number;
|
|
30
|
+
}
|
|
31
|
+
export declare const setCookiesNode: AgentTestRunnerNodeDefinition<z.output<typeof setCookiesInputSchema>, SetCookiesNodeResult>;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AgentTestRunnerNodeDefinition } from '@midscene/core/agent';
|
|
2
|
+
import { z } from 'zod/v4';
|
|
3
|
+
/** Input schema for the Playwright gotoUrl Node. */
|
|
4
|
+
export declare const gotoUrlInputSchema: z.ZodObject<{
|
|
5
|
+
url: z.ZodString;
|
|
6
|
+
waitUntil: z.ZodDefault<z.ZodEnum<{
|
|
7
|
+
domcontentloaded: "domcontentloaded";
|
|
8
|
+
load: "load";
|
|
9
|
+
networkidle: "networkidle";
|
|
10
|
+
commit: "commit";
|
|
11
|
+
}>>;
|
|
12
|
+
timeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
13
|
+
}, z.core.$strict>;
|
|
14
|
+
/** Validated input accepted by the Playwright gotoUrl Node. */
|
|
15
|
+
export type GotoUrlNodeInput = z.infer<typeof gotoUrlInputSchema>;
|
|
16
|
+
/** Structured navigation details returned by the Playwright gotoUrl Node. */
|
|
17
|
+
export interface GotoUrlNodeResult {
|
|
18
|
+
/** Final Page URL after navigation and redirects. */
|
|
19
|
+
url: string;
|
|
20
|
+
/** Main-resource HTTP status, or null when Playwright returns no response. */
|
|
21
|
+
status: number | null;
|
|
22
|
+
/** Document title after navigation completes. */
|
|
23
|
+
title: string;
|
|
24
|
+
}
|
|
25
|
+
export declare const gotoUrlNode: AgentTestRunnerNodeDefinition<z.output<typeof gotoUrlInputSchema>, GotoUrlNodeResult>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { clearCookiesInputSchema } from './clear-cookies';
|
|
2
|
+
export type { ClearCookiesNodeInput } from './clear-cookies';
|
|
3
|
+
export { setCookiesInputSchema } from './cookies';
|
|
4
|
+
export type { SetCookiesNodeInput, SetCookiesNodeResult, } from './cookies';
|
|
5
|
+
export { gotoUrlInputSchema } from './goto-url';
|
|
6
|
+
export type { GotoUrlNodeInput, GotoUrlNodeResult } from './goto-url';
|
|
7
|
+
export type { PlaywrightTestRunnerOptions, PlaywrightTestRunnerAgent, PlaywrightCookieProfileContext, PlaywrightNodeContext, } from './types';
|
|
8
|
+
export { setViewportSizeInputSchema } from './viewport';
|
|
9
|
+
export type { SetViewportSizeNodeInput } from './viewport';
|
|
10
|
+
export { playwrightAgentTestRunnerNodeDefinitions } from './agent-nodes';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { BrowserContext, Page } from 'playwright';
|
|
2
|
+
type Awaitable<T> = T | Promise<T>;
|
|
3
|
+
export type PlaywrightCookie = Parameters<BrowserContext['addCookies']>[0][number];
|
|
4
|
+
/** Runtime resources supplied by the test runner to Playwright Nodes. */
|
|
5
|
+
export interface PlaywrightNodeContext<TContext> {
|
|
6
|
+
input: unknown;
|
|
7
|
+
context: TContext;
|
|
8
|
+
signal: AbortSignal;
|
|
9
|
+
}
|
|
10
|
+
/** Context passed to a configured Playwright cookie profile resolver. */
|
|
11
|
+
export interface PlaywrightCookieProfileContext<TContext> {
|
|
12
|
+
/** Profile reference from the setCookies Node input. */
|
|
13
|
+
profile: string;
|
|
14
|
+
/** The Agent executing the current Node. */
|
|
15
|
+
context: TContext;
|
|
16
|
+
/** Cancellation signal for the current Node execution. */
|
|
17
|
+
signal: AbortSignal;
|
|
18
|
+
}
|
|
19
|
+
/** Dependencies and source resolvers used by the Playwright preset Nodes. */
|
|
20
|
+
export interface PlaywrightTestRunnerOptions {
|
|
21
|
+
/**
|
|
22
|
+
* Return the environment used by setCookies. Defaults to process.env when
|
|
23
|
+
* omitted.
|
|
24
|
+
*/
|
|
25
|
+
getEnv?(ctx: PlaywrightNodeContext<PlaywrightTestRunnerAgent>): Awaitable<Readonly<Record<string, string | undefined>>>;
|
|
26
|
+
/** Resolve a named cookie profile without placing cookie values in YAML. */
|
|
27
|
+
getCookieProfile?(input: PlaywrightCookieProfileContext<PlaywrightTestRunnerAgent>): Awaitable<readonly PlaywrightCookie[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Resolve a storage-state reference to a file path. References are resolved
|
|
30
|
+
* from process.cwd() when omitted.
|
|
31
|
+
*/
|
|
32
|
+
resolveStorageStatePath?(path: string, ctx: PlaywrightNodeContext<PlaywrightTestRunnerAgent>): Awaitable<string>;
|
|
33
|
+
}
|
|
34
|
+
/** The runtime resources used by Playwright Agent Nodes. */
|
|
35
|
+
export interface PlaywrightTestRunnerAgent {
|
|
36
|
+
interface: {
|
|
37
|
+
underlyingPage: Page;
|
|
38
|
+
};
|
|
39
|
+
readonly testRunner?: PlaywrightTestRunnerOptions;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PlaywrightTestRunnerAgent } from './types';
|
|
2
|
+
export declare const throwIfAborted: (signal: AbortSignal, operation: string) => void;
|
|
3
|
+
export declare const resolveWebUrl: (target: string, baseUrl: string | undefined, label: string) => string;
|
|
4
|
+
export declare const requirePlaywrightAgent: (agent: unknown) => PlaywrightTestRunnerAgent;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AgentTestRunnerNodeDefinition } from '@midscene/core/agent';
|
|
2
|
+
import { z } from 'zod/v4';
|
|
3
|
+
/** Input schema for the Playwright setViewportSize Node. */
|
|
4
|
+
export declare const setViewportSizeInputSchema: z.ZodObject<{
|
|
5
|
+
width: z.ZodNumber;
|
|
6
|
+
height: z.ZodNumber;
|
|
7
|
+
}, z.core.$strict>;
|
|
8
|
+
/** Validated input accepted by the Playwright setViewportSize Node. */
|
|
9
|
+
export type SetViewportSizeNodeInput = z.infer<typeof setViewportSizeInputSchema>;
|
|
10
|
+
export declare const setViewportSizeNode: AgentTestRunnerNodeDefinition<z.output<typeof setViewportSizeInputSchema>, {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
}>;
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"Browser use",
|
|
9
9
|
"Android use"
|
|
10
10
|
],
|
|
11
|
-
"version": "1.12.6
|
|
11
|
+
"version": "1.12.6",
|
|
12
12
|
"repository": "https://github.com/web-infra-dev/midscene",
|
|
13
13
|
"homepage": "https://midscenejs.com/",
|
|
14
14
|
"main": "./dist/lib/index.js",
|
|
@@ -89,6 +89,11 @@
|
|
|
89
89
|
"types": "./dist/types/static/index.d.ts",
|
|
90
90
|
"require": "./dist/lib/static/index.js",
|
|
91
91
|
"import": "./dist/es/static/index.mjs"
|
|
92
|
+
},
|
|
93
|
+
"./playwright/test": {
|
|
94
|
+
"types": "./dist/types/playwright/test-runner/index.d.ts",
|
|
95
|
+
"require": "./dist/lib/playwright/test-runner/index.js",
|
|
96
|
+
"import": "./dist/es/playwright/test-runner/index.mjs"
|
|
92
97
|
}
|
|
93
98
|
},
|
|
94
99
|
"bin": {
|
|
@@ -111,9 +116,10 @@
|
|
|
111
116
|
"socket.io": "^4.8.1",
|
|
112
117
|
"socket.io-client": "4.8.1",
|
|
113
118
|
"ws": "^8.18.1",
|
|
114
|
-
"
|
|
115
|
-
"@midscene/
|
|
116
|
-
"@midscene/shared": "1.12.6
|
|
119
|
+
"zod": "^3.25.1",
|
|
120
|
+
"@midscene/core": "1.12.6",
|
|
121
|
+
"@midscene/shared": "1.12.6",
|
|
122
|
+
"@midscene/playground": "1.12.6"
|
|
117
123
|
},
|
|
118
124
|
"devDependencies": {
|
|
119
125
|
"@playwright/test": "^1.45.0",
|