@empiricalrun/playwright-utils 0.4.2 → 0.6.0
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 +12 -0
- package/dist/test/index.d.ts +2 -0
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +3 -2
- package/dist/test/scripts/index.d.ts +1 -1
- package/dist/test/scripts/index.d.ts.map +1 -1
- package/dist/test/scripts/index.js +3 -3
- package/dist/test/scripts/locator-highlights.d.ts.map +1 -1
- package/dist/test/scripts/locator-highlights.js +2 -0
- package/dist/test/scripts/pw-locator-patch/expect.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/expect.js +3 -1
- package/dist/test/scripts/pw-locator-patch/hover.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/hover.js +3 -1
- package/dist/test/scripts/pw-locator-patch/inner-text.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/inner-text.js +3 -1
- package/dist/test/scripts/pw-locator-patch/input-value.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/input-value.js +3 -1
- package/dist/test/scripts/pw-locator-patch/is-checked.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/is-checked.js +3 -1
- package/dist/test/scripts/pw-locator-patch/is-disabled.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/is-disabled.js +3 -1
- package/dist/test/scripts/pw-locator-patch/is-editable.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/is-editable.js +3 -1
- package/dist/test/scripts/pw-locator-patch/text-content.d.ts +5 -0
- package/dist/test/scripts/pw-locator-patch/text-content.d.ts.map +1 -0
- package/dist/test/scripts/pw-locator-patch/text-content.js +26 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @empiricalrun/playwright-utils
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 59206d0: feat: add highlighter support for textContent
|
|
8
|
+
|
|
9
|
+
## 0.5.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 9094774: feat: expose locator highlighter scripts
|
|
14
|
+
|
|
3
15
|
## 0.4.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/test/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, TestType } from "@playwright/test";
|
|
2
|
+
import { injectLocatorHighlightScripts } from "./scripts";
|
|
2
3
|
export declare const baseTestFixture: (testFn: TestType<PlaywrightTestArgs & PlaywrightTestOptions, PlaywrightWorkerArgs & PlaywrightWorkerOptions>) => TestType<PlaywrightTestArgs & PlaywrightTestOptions & {
|
|
3
4
|
[key: string]: any;
|
|
4
5
|
}, PlaywrightWorkerArgs & PlaywrightWorkerOptions>;
|
|
6
|
+
export { injectLocatorHighlightScripts };
|
|
5
7
|
//# sourceMappingURL=index.d.ts.map
|
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,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,QAAQ,EACT,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,QAAQ,EACT,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,6BAA6B,EAAE,MAAM,WAAW,CAAC;AAE1D,eAAO,MAAM,eAAe,WAClB,SACN,kBAAkB,GAAG,qBAAqB,EAC1C,oBAAoB,GAAG,uBAAuB,CAC/C;;kDAQF,CAAC;AAEF,OAAO,EAAE,6BAA6B,EAAE,CAAC"}
|
package/dist/test/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.baseTestFixture = void 0;
|
|
3
|
+
exports.injectLocatorHighlightScripts = exports.baseTestFixture = void 0;
|
|
4
4
|
const scripts_1 = require("./scripts");
|
|
5
|
+
Object.defineProperty(exports, "injectLocatorHighlightScripts", { enumerable: true, get: function () { return scripts_1.injectLocatorHighlightScripts; } });
|
|
5
6
|
const baseTestFixture = function (testFn) {
|
|
6
7
|
return testFn.extend({
|
|
7
8
|
page: async ({ page }, use) => {
|
|
8
|
-
(0, scripts_1.
|
|
9
|
+
(0, scripts_1.injectLocatorHighlightScripts)(page);
|
|
9
10
|
await use(page);
|
|
10
11
|
},
|
|
11
12
|
});
|
|
@@ -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;AAK7C,wBAAgB,
|
|
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;AAK7C,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,IAAI,QASvD"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.injectLocatorHighlightScripts = void 0;
|
|
4
4
|
const locator_highlights_1 = require("./locator-highlights");
|
|
5
5
|
const mouse_pointer_1 = require("./mouse-pointer");
|
|
6
|
-
function
|
|
6
|
+
function injectLocatorHighlightScripts(page) {
|
|
7
7
|
try {
|
|
8
8
|
// pointer highlighter and focus highlighter
|
|
9
9
|
(0, mouse_pointer_1.addMousePointerHighlighter)(page);
|
|
@@ -14,4 +14,4 @@ function addCustomScripts(page) {
|
|
|
14
14
|
console.error("Failed to add mouse pointer highlighter", e);
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
exports.
|
|
17
|
+
exports.injectLocatorHighlightScripts = injectLocatorHighlightScripts;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locator-highlights.d.ts","sourceRoot":"","sources":["../../../src/test/scripts/locator-highlights.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"locator-highlights.d.ts","sourceRoot":"","sources":["../../../src/test/scripts/locator-highlights.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAW7C,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,QAU9C"}
|
|
@@ -8,6 +8,7 @@ const input_value_1 = require("./pw-locator-patch/input-value");
|
|
|
8
8
|
const is_checked_1 = require("./pw-locator-patch/is-checked");
|
|
9
9
|
const is_disabled_1 = require("./pw-locator-patch/is-disabled");
|
|
10
10
|
const is_editable_1 = require("./pw-locator-patch/is-editable");
|
|
11
|
+
const text_content_1 = require("./pw-locator-patch/text-content");
|
|
11
12
|
function addLocatorHighlights(page) {
|
|
12
13
|
const LocatorClass = page.locator("").constructor;
|
|
13
14
|
(0, expect_1.patchExpect)(LocatorClass);
|
|
@@ -17,5 +18,6 @@ function addLocatorHighlights(page) {
|
|
|
17
18
|
(0, is_disabled_1.patchIsDisabled)(LocatorClass);
|
|
18
19
|
(0, hover_1.patchHover)(LocatorClass);
|
|
19
20
|
(0, inner_text_1.patchInnerText)(LocatorClass);
|
|
21
|
+
(0, text_content_1.patchTextContent)(LocatorClass);
|
|
20
22
|
}
|
|
21
23
|
exports.addLocatorHighlights = addLocatorHighlights;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expect.d.ts","sourceRoot":"","sources":["../../../../src/test/scripts/pw-locator-patch/expect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,wBAAgB,WAAW,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"expect.d.ts","sourceRoot":"","sources":["../../../../src/test/scripts/pw-locator-patch/expect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,wBAAgB,WAAW,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QA2B/D"}
|
|
@@ -14,7 +14,9 @@ function patchExpect(LocatorClass) {
|
|
|
14
14
|
await this.evaluate((node) => {
|
|
15
15
|
node.classList.add("empirical-element-grab-highlight");
|
|
16
16
|
setTimeout(() => {
|
|
17
|
-
node.
|
|
17
|
+
if (node.isConnected) {
|
|
18
|
+
node.classList.remove("empirical-element-grab-highlight");
|
|
19
|
+
}
|
|
18
20
|
}, 2000);
|
|
19
21
|
});
|
|
20
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hover.d.ts","sourceRoot":"","sources":["../../../../src/test/scripts/pw-locator-patch/hover.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,wBAAgB,UAAU,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"hover.d.ts","sourceRoot":"","sources":["../../../../src/test/scripts/pw-locator-patch/hover.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,wBAAgB,UAAU,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAmB9D"}
|
|
@@ -11,7 +11,9 @@ function patchHover(LocatorClass) {
|
|
|
11
11
|
await this.evaluate((node) => {
|
|
12
12
|
node.classList.add("empirical-element-grab-highlight");
|
|
13
13
|
setTimeout(() => {
|
|
14
|
-
node.
|
|
14
|
+
if (node.isConnected) {
|
|
15
|
+
node.classList.remove("empirical-element-grab-highlight");
|
|
16
|
+
}
|
|
15
17
|
}, 2000);
|
|
16
18
|
});
|
|
17
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inner-text.d.ts","sourceRoot":"","sources":["../../../../src/test/scripts/pw-locator-patch/inner-text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,wBAAgB,cAAc,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"inner-text.d.ts","sourceRoot":"","sources":["../../../../src/test/scripts/pw-locator-patch/inner-text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,wBAAgB,cAAc,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAoBlE"}
|
|
@@ -11,7 +11,9 @@ function patchInnerText(LocatorClass) {
|
|
|
11
11
|
await this.evaluate((node) => {
|
|
12
12
|
node.classList.add("empirical-element-grab-highlight");
|
|
13
13
|
setTimeout(() => {
|
|
14
|
-
node.
|
|
14
|
+
if (node.isConnected) {
|
|
15
|
+
node.classList.remove("empirical-element-grab-highlight");
|
|
16
|
+
}
|
|
15
17
|
}, 2000);
|
|
16
18
|
});
|
|
17
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-value.d.ts","sourceRoot":"","sources":["../../../../src/test/scripts/pw-locator-patch/input-value.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,wBAAgB,eAAe,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"input-value.d.ts","sourceRoot":"","sources":["../../../../src/test/scripts/pw-locator-patch/input-value.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,wBAAgB,eAAe,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAoBnE"}
|
|
@@ -11,7 +11,9 @@ function patchInputValue(LocatorClass) {
|
|
|
11
11
|
await this.evaluate((node) => {
|
|
12
12
|
node.classList.add("empirical-element-grab-highlight");
|
|
13
13
|
setTimeout(() => {
|
|
14
|
-
node.
|
|
14
|
+
if (node.isConnected) {
|
|
15
|
+
node.classList.remove("empirical-element-grab-highlight");
|
|
16
|
+
}
|
|
15
17
|
}, 2000);
|
|
16
18
|
});
|
|
17
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-checked.d.ts","sourceRoot":"","sources":["../../../../src/test/scripts/pw-locator-patch/is-checked.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,wBAAgB,cAAc,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"is-checked.d.ts","sourceRoot":"","sources":["../../../../src/test/scripts/pw-locator-patch/is-checked.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,wBAAgB,cAAc,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAoBlE"}
|
|
@@ -11,7 +11,9 @@ function patchIsChecked(LocatorClass) {
|
|
|
11
11
|
await this.evaluate((node) => {
|
|
12
12
|
node.classList.add("empirical-element-grab-highlight");
|
|
13
13
|
setTimeout(() => {
|
|
14
|
-
node.
|
|
14
|
+
if (node.isConnected) {
|
|
15
|
+
node.classList.remove("empirical-element-grab-highlight");
|
|
16
|
+
}
|
|
15
17
|
}, 2000);
|
|
16
18
|
});
|
|
17
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-disabled.d.ts","sourceRoot":"","sources":["../../../../src/test/scripts/pw-locator-patch/is-disabled.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,wBAAgB,eAAe,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"is-disabled.d.ts","sourceRoot":"","sources":["../../../../src/test/scripts/pw-locator-patch/is-disabled.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,wBAAgB,eAAe,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAoBnE"}
|
|
@@ -11,7 +11,9 @@ function patchIsDisabled(LocatorClass) {
|
|
|
11
11
|
await this.evaluate((node) => {
|
|
12
12
|
node.classList.add("empirical-element-grab-highlight");
|
|
13
13
|
setTimeout(() => {
|
|
14
|
-
node.
|
|
14
|
+
if (node.isConnected) {
|
|
15
|
+
node.classList.remove("empirical-element-grab-highlight");
|
|
16
|
+
}
|
|
15
17
|
}, 2000);
|
|
16
18
|
});
|
|
17
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-editable.d.ts","sourceRoot":"","sources":["../../../../src/test/scripts/pw-locator-patch/is-editable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,wBAAgB,eAAe,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"is-editable.d.ts","sourceRoot":"","sources":["../../../../src/test/scripts/pw-locator-patch/is-editable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,wBAAgB,eAAe,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAoBnE"}
|
|
@@ -11,7 +11,9 @@ function patchIsEditable(LocatorClass) {
|
|
|
11
11
|
await this.evaluate((node) => {
|
|
12
12
|
node.classList.add("empirical-element-grab-highlight");
|
|
13
13
|
setTimeout(() => {
|
|
14
|
-
node.
|
|
14
|
+
if (node.isConnected) {
|
|
15
|
+
node.classList.remove("empirical-element-grab-highlight");
|
|
16
|
+
}
|
|
15
17
|
}, 2000);
|
|
16
18
|
});
|
|
17
19
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-content.d.ts","sourceRoot":"","sources":["../../../../src/test/scripts/pw-locator-patch/text-content.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,wBAAgB,gBAAgB,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAoBpE"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.patchTextContent = void 0;
|
|
4
|
+
function patchTextContent(LocatorClass) {
|
|
5
|
+
const originalTextContent = LocatorClass.prototype.textContent;
|
|
6
|
+
//ref: https://github.com/microsoft/playwright/blob/69287f26bc514b740eac40160503d6fac8185d37/packages/playwright-core/src/client/locator.ts#L318
|
|
7
|
+
LocatorClass.prototype.textContent = async function (options) {
|
|
8
|
+
const result = await originalTextContent.apply(this, [options]);
|
|
9
|
+
try {
|
|
10
|
+
await this.scrollIntoViewIfNeeded();
|
|
11
|
+
await this.evaluate((node) => {
|
|
12
|
+
node.classList.add("empirical-element-grab-highlight");
|
|
13
|
+
setTimeout(() => {
|
|
14
|
+
if (node.isConnected) {
|
|
15
|
+
node.classList.remove("empirical-element-grab-highlight");
|
|
16
|
+
}
|
|
17
|
+
}, 2000);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
console.log("Failed to add highlight for locator method: textContent", e);
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
exports.patchTextContent = patchTextContent;
|