@empiricalrun/playwright-utils 0.5.0 → 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 +6 -0
- 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 +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;
|