@empiricalrun/playwright-utils 0.17.0 → 0.18.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/CHANGELOG.md +19 -0
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +0 -1
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +5 -1
- package/dist/test/scripts/agent-capabilities.d.ts +3 -0
- package/dist/test/scripts/agent-capabilities.d.ts.map +1 -0
- package/dist/test/scripts/agent-capabilities.js +15 -0
- package/dist/test/scripts/index.d.ts.map +1 -1
- package/dist/test/scripts/index.js +6 -0
- package/dist/test/scripts/pw-locator-patch/highlight/click.d.ts +5 -0
- package/dist/test/scripts/pw-locator-patch/highlight/click.d.ts.map +1 -0
- package/dist/test/scripts/pw-locator-patch/highlight/click.js +46 -0
- package/dist/test/types.d.ts +1 -0
- package/dist/test/types.d.ts.map +1 -1
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @empiricalrun/playwright-utils
|
|
2
2
|
|
|
3
|
+
## 0.18.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [6060a78]
|
|
8
|
+
- @empiricalrun/test-gen@0.38.31
|
|
9
|
+
|
|
10
|
+
## 0.18.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- dbe713b: fix: auto dismiss popup at test runtime
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 041cd97: fix: remove log line
|
|
19
|
+
- Updated dependencies [dbe713b]
|
|
20
|
+
- @empiricalrun/test-gen@0.38.30
|
|
21
|
+
|
|
3
22
|
## 0.17.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
package/dist/auth/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","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,CAAC,EAAE,OAAO,CAAC;KACnB;IAQK,eAAe;IAIf,YAAY,IAAI,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC;IAqC/C,MAAM,CAAC,qBAAqB,CAC1B,WAAW,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,EAC5B,KAAK,EAAE,WAAW,GACjB,MAAM,GAAG,SAAS;YAyBP,oBAAoB;YAsBpB,aAAa;IA6B3B,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM;WAIxC,eAAe,CAC1B,OAAO,EAAE,cAAc,EACvB,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC;CAoB5B"}
|
package/dist/auth/index.js
CHANGED
package/dist/test/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,IAAI,EACJ,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,QAAQ,EACT,MAAM,kBAAkB,CAAC;AAK1B,OAAO,EAAE,6BAA6B,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,IAAI,CAAC;IACX,yBAAyB,EAAE,CACzB,OAAO,CAAC,EAAE,qBAAqB,KAC5B,OAAO,CAAC;QAAE,OAAO,EAAE,cAAc,CAAC;QAAC,IAAI,EAAE,IAAI,CAAA;KAAE,CAAC,CAAC;IACtD,UAAU,EAAE,IAAI,CAAC;CAClB,CAAC;AAIF,eAAO,MAAM,eAAe,WAClB,SACN,kBAAkB,GAAG,qBAAqB,EAC1C,oBAAoB,GAAG,uBAAuB,CAC/C,YACQ,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,IAAI,EACJ,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,QAAQ,EACT,MAAM,kBAAkB,CAAC;AAK1B,OAAO,EAAE,6BAA6B,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,IAAI,CAAC;IACX,yBAAyB,EAAE,CACzB,OAAO,CAAC,EAAE,qBAAqB,KAC5B,OAAO,CAAC;QAAE,OAAO,EAAE,cAAc,CAAC;QAAC,IAAI,EAAE,IAAI,CAAA;KAAE,CAAC,CAAC;IACtD,UAAU,EAAE,IAAI,CAAC;CAClB,CAAC;AAIF,eAAO,MAAM,eAAe,WAClB,SACN,kBAAkB,GAAG,qBAAqB,EAC1C,oBAAoB,GAAG,uBAAuB,CAC/C,YACQ,eAAe,uHA4DzB,CAAC;AAEF,OAAO,EAAE,6BAA6B,EAAE,CAAC"}
|
package/dist/test/index.js
CHANGED
|
@@ -14,8 +14,9 @@ const baseTestFixture = function (testFn, options = {
|
|
|
14
14
|
mousePointerHighlighter: true,
|
|
15
15
|
locatorHighlighter: true,
|
|
16
16
|
visionMethods: true,
|
|
17
|
+
agentCapabilities: true,
|
|
17
18
|
}) {
|
|
18
|
-
|
|
19
|
+
const extendedTestFn = testFn.extend({
|
|
19
20
|
page: async ({ page }, use) => {
|
|
20
21
|
(0, scripts_1.injectLocatorHighlightScripts)(page, options);
|
|
21
22
|
await use(page);
|
|
@@ -57,5 +58,8 @@ const baseTestFixture = function (testFn, options = {
|
|
|
57
58
|
{ auto: true },
|
|
58
59
|
],
|
|
59
60
|
});
|
|
61
|
+
//@ts-ignore
|
|
62
|
+
global.testFn = extendedTestFn;
|
|
63
|
+
return extendedTestFn;
|
|
60
64
|
};
|
|
61
65
|
exports.baseTestFixture = baseTestFixture;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-capabilities.d.ts","sourceRoot":"","sources":["../../../src/test/scripts/agent-capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAI7C,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,QAK9C"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addAgentCapabilities = void 0;
|
|
4
|
+
const click_1 = require("./pw-locator-patch/highlight/click");
|
|
5
|
+
function addAgentCapabilities(page) {
|
|
6
|
+
applyPatchForAutoDismissOverlay(page);
|
|
7
|
+
page.context().on("page", async (newPage) => {
|
|
8
|
+
applyPatchForAutoDismissOverlay(newPage);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
exports.addAgentCapabilities = addAgentCapabilities;
|
|
12
|
+
function applyPatchForAutoDismissOverlay(page) {
|
|
13
|
+
const LocatorClass = page.locator("").constructor;
|
|
14
|
+
(0, click_1.patchClick)(LocatorClass);
|
|
15
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/test/scripts/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAG7C,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/test/scripts/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAG7C,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAa3C,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,IAAI,EACV,OAAO,GAAE,eAAgC,QA4B1C"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.injectLocatorHighlightScripts = void 0;
|
|
4
4
|
const logger_1 = require("../../logger");
|
|
5
|
+
const agent_capabilities_1 = require("./agent-capabilities");
|
|
5
6
|
const locator_highlights_1 = require("./locator-highlights");
|
|
6
7
|
const locator_vision_1 = require("./locator-vision");
|
|
7
8
|
const mouse_pointer_1 = require("./mouse-pointer");
|
|
@@ -9,6 +10,7 @@ const defaultOptions = {
|
|
|
9
10
|
mousePointerHighlighter: true,
|
|
10
11
|
locatorHighlighter: true,
|
|
11
12
|
visionMethods: true,
|
|
13
|
+
agentCapabilities: true,
|
|
12
14
|
};
|
|
13
15
|
function injectLocatorHighlightScripts(page, options = defaultOptions) {
|
|
14
16
|
// TODO: if this method is used standalone (not through the fixture),
|
|
@@ -30,6 +32,10 @@ function injectLocatorHighlightScripts(page, options = defaultOptions) {
|
|
|
30
32
|
// patch with vision methods
|
|
31
33
|
(0, locator_vision_1.addLocatorVisionMethods)(page);
|
|
32
34
|
}
|
|
35
|
+
if (opts.agentCapabilities) {
|
|
36
|
+
//patch to enable agents at runtime
|
|
37
|
+
(0, agent_capabilities_1.addAgentCapabilities)(page);
|
|
38
|
+
}
|
|
33
39
|
}
|
|
34
40
|
catch (e) {
|
|
35
41
|
logger_1.logger.debug("Failed to add mouse pointer highlighter", e);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"click.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/highlight/click.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,wBAAgB,UAAU,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QA4C9D"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.patchClick = void 0;
|
|
4
|
+
const planner_1 = require("@empiricalrun/test-gen/agent/master/planner");
|
|
5
|
+
const run_1 = require("@empiricalrun/test-gen/agent/master/run");
|
|
6
|
+
function patchClick(LocatorClass) {
|
|
7
|
+
const originalClick = LocatorClass.prototype.click;
|
|
8
|
+
//ref: github.com/microsoft/playwright/blob/69287f26bc514b740eac40160503d6fac8185d37/packages/playwright-core/src/client/locator.ts#L255
|
|
9
|
+
LocatorClass.prototype.click = async function (options) {
|
|
10
|
+
try {
|
|
11
|
+
await originalClick.apply(this, [options]);
|
|
12
|
+
}
|
|
13
|
+
catch (e) {
|
|
14
|
+
// If its a test gen, don't trigger the flow
|
|
15
|
+
if (process.env.TEST_GEN_TOKEN) {
|
|
16
|
+
throw new Error(`waiting for ${this.toString()} with options ${JSON.stringify(options)}`);
|
|
17
|
+
}
|
|
18
|
+
const plannerResp = await (0, planner_1.runtimePlannerWithScreenshot)({
|
|
19
|
+
task: "Find a way to dismiss the popup. If the popup is non dismissible or there is no popup then return immediately. Also note that you just need to dismiss popup and do nothing else.",
|
|
20
|
+
conversation: [],
|
|
21
|
+
//Need to add the type for frame
|
|
22
|
+
//@ts-ignore
|
|
23
|
+
page: this._frame._page,
|
|
24
|
+
});
|
|
25
|
+
if (plannerResp.isDone) {
|
|
26
|
+
throw new Error(`waiting for ${this.toString()} with options ${JSON.stringify(options)}`);
|
|
27
|
+
}
|
|
28
|
+
await (0, run_1.createTestUsingMasterAgent)({
|
|
29
|
+
task: "Find a way to dismiss the popup. If the popup is non dismissible or there is no popup then return immediately. Also note that you just need to dismiss popup and do nothing else.",
|
|
30
|
+
//Need to add the type for frame
|
|
31
|
+
//@ts-ignore
|
|
32
|
+
page: this._frame._page,
|
|
33
|
+
options: {
|
|
34
|
+
useHints: true,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
//@ts-ignore
|
|
38
|
+
global.testFn?.info().annotations.push({
|
|
39
|
+
type: "auto-overlay-dismissed",
|
|
40
|
+
description: "This test run had an overlay that was dismissed during runtime",
|
|
41
|
+
});
|
|
42
|
+
await originalClick.apply(this, [options]);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
exports.patchClick = patchClick;
|
package/dist/test/types.d.ts
CHANGED
package/dist/test/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/test/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC5B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,aAAa,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/test/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC5B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/playwright-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -42,7 +42,8 @@
|
|
|
42
42
|
"puppeteer-extra-plugin-recaptcha": "^3.6.8",
|
|
43
43
|
"rimraf": "^6.0.1",
|
|
44
44
|
"@empiricalrun/llm": "^0.9.27",
|
|
45
|
-
"@empiricalrun/r2-uploader": "^0.3.7"
|
|
45
|
+
"@empiricalrun/r2-uploader": "^0.3.7",
|
|
46
|
+
"@empiricalrun/test-gen": "^0.38.31"
|
|
46
47
|
},
|
|
47
48
|
"scripts": {
|
|
48
49
|
"dev": "tsc --build --watch",
|