@empiricalrun/playwright-utils 0.6.0 → 0.6.2
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/constants.d.ts +2 -0
- package/dist/test/constants.d.ts.map +1 -0
- package/dist/test/constants.js +4 -0
- package/dist/test/scripts/mouse-pointer.d.ts.map +1 -1
- package/dist/test/scripts/mouse-pointer.js +31 -26
- package/dist/test/scripts/pw-locator-patch/expect.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/expect.js +5 -4
- package/dist/test/scripts/pw-locator-patch/hover.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/hover.js +5 -4
- package/dist/test/scripts/pw-locator-patch/inner-text.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/inner-text.js +5 -4
- package/dist/test/scripts/pw-locator-patch/input-value.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/input-value.js +5 -4
- package/dist/test/scripts/pw-locator-patch/is-checked.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/is-checked.js +5 -4
- package/dist/test/scripts/pw-locator-patch/is-disabled.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/is-disabled.js +5 -4
- package/dist/test/scripts/pw-locator-patch/is-editable.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/is-editable.js +5 -4
- package/dist/test/scripts/pw-locator-patch/text-content.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/text-content.js +5 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @empiricalrun/playwright-utils
|
|
2
2
|
|
|
3
|
+
## 0.6.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- cfc58de: fix: reduce highlighter log size and internal timeout fix
|
|
8
|
+
|
|
9
|
+
## 0.6.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- de76cd6: fix: wrap mouse-pointer highlighter in try/catch
|
|
14
|
+
|
|
3
15
|
## 0.6.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/test/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gCAAgC,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mouse-pointer.d.ts","sourceRoot":"","sources":["../../../src/test/scripts/mouse-pointer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"mouse-pointer.d.ts","sourceRoot":"","sources":["../../../src/test/scripts/mouse-pointer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,IAAI,QAoGpD"}
|
|
@@ -3,11 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.addMousePointerHighlighter = void 0;
|
|
4
4
|
function addMousePointerHighlighter(page) {
|
|
5
5
|
page.on("load", async () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
try {
|
|
7
|
+
await page?.evaluate(() => {
|
|
8
|
+
const box = document.createElement("div");
|
|
9
|
+
box.classList.add("empirical-mouse-pointer");
|
|
10
|
+
const styleElement = document.createElement("style");
|
|
11
|
+
styleElement.textContent = `
|
|
11
12
|
.empirical-mouse-pointer {
|
|
12
13
|
pointer-events: none;
|
|
13
14
|
position: absolute;
|
|
@@ -53,28 +54,32 @@ function addMousePointerHighlighter(page) {
|
|
|
53
54
|
outline: 2px dashed #FF000D !important;
|
|
54
55
|
}
|
|
55
56
|
`;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
57
|
+
document.head.appendChild(styleElement);
|
|
58
|
+
document.body.appendChild(box);
|
|
59
|
+
document.addEventListener("mousemove", (event) => {
|
|
60
|
+
box.style.left = `${event.pageX}px`;
|
|
61
|
+
box.style.top = `${event.pageY}px`;
|
|
62
|
+
updateButtons(event.buttons);
|
|
63
|
+
}, true);
|
|
64
|
+
document.addEventListener("mousedown", (event) => {
|
|
65
|
+
updateButtons(event.buttons);
|
|
66
|
+
box.classList.add(`button-${event.button + 1}`);
|
|
67
|
+
}, true);
|
|
68
|
+
document.addEventListener("mouseup", (event) => {
|
|
69
|
+
updateButtons(event.buttons);
|
|
70
|
+
box.classList.remove(`button-${event.button + 1}`);
|
|
71
|
+
}, true);
|
|
72
|
+
// @ts-ignore
|
|
73
|
+
function updateButtons(buttons) {
|
|
74
|
+
for (let i = 0; i < 5; i++) {
|
|
75
|
+
box.classList.toggle(`button-${i + 1}`, (buttons / Math.pow(2, i)) % 2 >= 1);
|
|
76
|
+
}
|
|
75
77
|
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
console.log(`Error adding mouse pointer highlighter`, e);
|
|
82
|
+
}
|
|
78
83
|
});
|
|
79
84
|
}
|
|
80
85
|
exports.addMousePointerHighlighter = addMousePointerHighlighter;
|
|
@@ -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;
|
|
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;AAIhD,wBAAgB,WAAW,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QA+B/D"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.patchExpect = void 0;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
4
5
|
function patchExpect(LocatorClass) {
|
|
5
6
|
//@ts-ignore _expect returnsPromise<{ matches: boolean, received?: any, log?: string[], timedOut?: boolean }>
|
|
6
7
|
const originalExpect = LocatorClass.prototype._expect;
|
|
@@ -10,18 +11,18 @@ function patchExpect(LocatorClass) {
|
|
|
10
11
|
const result = await originalExpect.apply(this, [expression, options]);
|
|
11
12
|
if (result.matches) {
|
|
12
13
|
try {
|
|
13
|
-
await this.scrollIntoViewIfNeeded();
|
|
14
14
|
await this.evaluate((node) => {
|
|
15
|
+
node.scrollIntoViewIfNeeded();
|
|
15
16
|
node.classList.add("empirical-element-grab-highlight");
|
|
16
17
|
setTimeout(() => {
|
|
17
|
-
if (node.isConnected) {
|
|
18
|
+
if (node && node.isConnected && node.classList) {
|
|
18
19
|
node.classList.remove("empirical-element-grab-highlight");
|
|
19
20
|
}
|
|
20
21
|
}, 2000);
|
|
21
|
-
});
|
|
22
|
+
}, undefined, { timeout: constants_1.DEFAULT_SCRIPT_EXECUTION_TIMEOUT });
|
|
22
23
|
}
|
|
23
24
|
catch (e) {
|
|
24
|
-
console.
|
|
25
|
+
console.warn("Failed to add highlight for locator method: _expect");
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
return result;
|
|
@@ -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;
|
|
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;AAI3C,wBAAgB,UAAU,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAuB9D"}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.patchHover = void 0;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
4
5
|
function patchHover(LocatorClass) {
|
|
5
6
|
const originalHover = LocatorClass.prototype.hover;
|
|
6
7
|
LocatorClass.prototype.hover = async function (options) {
|
|
7
8
|
// ref: https://github.com/microsoft/playwright/blob/69287f26bc514b740eac40160503d6fac8185d37/packages/playwright-core/src/client/locator.ts#L243
|
|
8
9
|
await originalHover.apply(this, [options]);
|
|
9
10
|
try {
|
|
10
|
-
await this.scrollIntoViewIfNeeded();
|
|
11
11
|
await this.evaluate((node) => {
|
|
12
|
+
node.scrollIntoViewIfNeeded();
|
|
12
13
|
node.classList.add("empirical-element-grab-highlight");
|
|
13
14
|
setTimeout(() => {
|
|
14
|
-
if (node.isConnected) {
|
|
15
|
+
if (node && node.isConnected && node.classList) {
|
|
15
16
|
node.classList.remove("empirical-element-grab-highlight");
|
|
16
17
|
}
|
|
17
18
|
}, 2000);
|
|
18
|
-
});
|
|
19
|
+
}, undefined, { timeout: constants_1.DEFAULT_SCRIPT_EXECUTION_TIMEOUT });
|
|
19
20
|
}
|
|
20
21
|
catch (e) {
|
|
21
|
-
console.
|
|
22
|
+
console.warn("Failed to add highlight for locator method: hover");
|
|
22
23
|
}
|
|
23
24
|
};
|
|
24
25
|
}
|
|
@@ -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;
|
|
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;AAIhD,wBAAgB,cAAc,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAwBlE"}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.patchInnerText = void 0;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
4
5
|
function patchInnerText(LocatorClass) {
|
|
5
6
|
const originalInputValue = LocatorClass.prototype.innerText;
|
|
6
7
|
//ref: https://github.com/microsoft/playwright/blob/69287f26bc514b740eac40160503d6fac8185d37/packages/playwright-core/src/client/locator.ts#L251
|
|
7
8
|
LocatorClass.prototype.innerText = async function (options) {
|
|
8
9
|
const result = await originalInputValue.apply(this, [options]);
|
|
9
10
|
try {
|
|
10
|
-
await this.scrollIntoViewIfNeeded();
|
|
11
11
|
await this.evaluate((node) => {
|
|
12
|
+
node.scrollIntoViewIfNeeded();
|
|
12
13
|
node.classList.add("empirical-element-grab-highlight");
|
|
13
14
|
setTimeout(() => {
|
|
14
|
-
if (node.isConnected) {
|
|
15
|
+
if (node && node.isConnected && node.classList) {
|
|
15
16
|
node.classList.remove("empirical-element-grab-highlight");
|
|
16
17
|
}
|
|
17
18
|
}, 2000);
|
|
18
|
-
});
|
|
19
|
+
}, undefined, { timeout: constants_1.DEFAULT_SCRIPT_EXECUTION_TIMEOUT });
|
|
19
20
|
}
|
|
20
21
|
catch (e) {
|
|
21
|
-
console.
|
|
22
|
+
console.warn("Failed to add highlight for locator method: innerText");
|
|
22
23
|
}
|
|
23
24
|
return result;
|
|
24
25
|
};
|
|
@@ -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;
|
|
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;AAIhD,wBAAgB,eAAe,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAwBnE"}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.patchInputValue = void 0;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
4
5
|
function patchInputValue(LocatorClass) {
|
|
5
6
|
const originalInputValue = LocatorClass.prototype.inputValue;
|
|
6
7
|
//ref: github.com/microsoft/playwright/blob/69287f26bc514b740eac40160503d6fac8185d37/packages/playwright-core/src/client/locator.ts#L255
|
|
7
8
|
LocatorClass.prototype.inputValue = async function (options) {
|
|
8
9
|
const result = await originalInputValue.apply(this, [options]);
|
|
9
10
|
try {
|
|
10
|
-
await this.scrollIntoViewIfNeeded();
|
|
11
11
|
await this.evaluate((node) => {
|
|
12
|
+
node.scrollIntoViewIfNeeded();
|
|
12
13
|
node.classList.add("empirical-element-grab-highlight");
|
|
13
14
|
setTimeout(() => {
|
|
14
|
-
if (node.isConnected) {
|
|
15
|
+
if (node && node.isConnected && node.classList) {
|
|
15
16
|
node.classList.remove("empirical-element-grab-highlight");
|
|
16
17
|
}
|
|
17
18
|
}, 2000);
|
|
18
|
-
});
|
|
19
|
+
}, undefined, { timeout: constants_1.DEFAULT_SCRIPT_EXECUTION_TIMEOUT });
|
|
19
20
|
}
|
|
20
21
|
catch (e) {
|
|
21
|
-
console.
|
|
22
|
+
console.warn("Failed to add highlight for locator method: inputValue");
|
|
22
23
|
}
|
|
23
24
|
return result;
|
|
24
25
|
};
|
|
@@ -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;
|
|
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;AAI3C,wBAAgB,cAAc,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAwBlE"}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.patchIsChecked = void 0;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
4
5
|
function patchIsChecked(LocatorClass) {
|
|
5
6
|
const originalIsChecked = LocatorClass.prototype.isChecked;
|
|
6
7
|
LocatorClass.prototype.isChecked = async function (options) {
|
|
7
8
|
// ref: https://github.com/microsoft/playwright/blob/69287f26bc514b740eac40160503d6fac8185d37/packages/playwright-core/src/client/locator.ts#L259
|
|
8
9
|
const result = await originalIsChecked.apply(this, [options]);
|
|
9
10
|
try {
|
|
10
|
-
await this.scrollIntoViewIfNeeded();
|
|
11
11
|
await this.evaluate((node) => {
|
|
12
|
+
node.scrollIntoViewIfNeeded();
|
|
12
13
|
node.classList.add("empirical-element-grab-highlight");
|
|
13
14
|
setTimeout(() => {
|
|
14
|
-
if (node.isConnected) {
|
|
15
|
+
if (node && node.isConnected && node.classList) {
|
|
15
16
|
node.classList.remove("empirical-element-grab-highlight");
|
|
16
17
|
}
|
|
17
18
|
}, 2000);
|
|
18
|
-
});
|
|
19
|
+
}, undefined, { timeout: constants_1.DEFAULT_SCRIPT_EXECUTION_TIMEOUT });
|
|
19
20
|
}
|
|
20
21
|
catch (e) {
|
|
21
|
-
console.
|
|
22
|
+
console.warn("Failed to add highlight for locator method: isChecked");
|
|
22
23
|
}
|
|
23
24
|
return result;
|
|
24
25
|
};
|
|
@@ -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;
|
|
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;AAI3C,wBAAgB,eAAe,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAwBnE"}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.patchIsDisabled = void 0;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
4
5
|
function patchIsDisabled(LocatorClass) {
|
|
5
6
|
const originalIsDisabled = LocatorClass.prototype.isDisabled;
|
|
6
7
|
LocatorClass.prototype.isDisabled = async function (options) {
|
|
7
8
|
// ref: https://github.com/microsoft/playwright/blob/69287f26bc514b740eac40160503d6fac8185d37/packages/playwright-core/src/client/locator.ts#L263
|
|
8
9
|
const result = await originalIsDisabled.apply(this, [options]);
|
|
9
10
|
try {
|
|
10
|
-
await this.scrollIntoViewIfNeeded();
|
|
11
11
|
await this.evaluate((node) => {
|
|
12
|
+
node.scrollIntoViewIfNeeded();
|
|
12
13
|
node.classList.add("empirical-element-grab-highlight");
|
|
13
14
|
setTimeout(() => {
|
|
14
|
-
if (node.isConnected) {
|
|
15
|
+
if (node && node.isConnected && node.classList) {
|
|
15
16
|
node.classList.remove("empirical-element-grab-highlight");
|
|
16
17
|
}
|
|
17
18
|
}, 2000);
|
|
18
|
-
});
|
|
19
|
+
}, undefined, { timeout: constants_1.DEFAULT_SCRIPT_EXECUTION_TIMEOUT });
|
|
19
20
|
}
|
|
20
21
|
catch (e) {
|
|
21
|
-
console.
|
|
22
|
+
console.warn("Failed to add highlight for locator method: isDisabled");
|
|
22
23
|
}
|
|
23
24
|
return result;
|
|
24
25
|
};
|
|
@@ -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;
|
|
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;AAI3C,wBAAgB,eAAe,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAwBnE"}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.patchIsEditable = void 0;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
4
5
|
function patchIsEditable(LocatorClass) {
|
|
5
6
|
const originalIsEditable = LocatorClass.prototype.isEditable;
|
|
6
7
|
LocatorClass.prototype.isEditable = async function (options) {
|
|
7
8
|
// ref: https://github.com/microsoft/playwright/blob/69287f26bc514b740eac40160503d6fac8185d37/packages/playwright-core/src/client/locator.ts#L267
|
|
8
9
|
const result = await originalIsEditable.apply(this, [options]);
|
|
9
10
|
try {
|
|
10
|
-
await this.scrollIntoViewIfNeeded();
|
|
11
11
|
await this.evaluate((node) => {
|
|
12
|
+
node.scrollIntoViewIfNeeded();
|
|
12
13
|
node.classList.add("empirical-element-grab-highlight");
|
|
13
14
|
setTimeout(() => {
|
|
14
|
-
if (node.isConnected) {
|
|
15
|
+
if (node && node.isConnected && node.classList) {
|
|
15
16
|
node.classList.remove("empirical-element-grab-highlight");
|
|
16
17
|
}
|
|
17
18
|
}, 2000);
|
|
18
|
-
});
|
|
19
|
+
}, undefined, { timeout: constants_1.DEFAULT_SCRIPT_EXECUTION_TIMEOUT });
|
|
19
20
|
}
|
|
20
21
|
catch (e) {
|
|
21
|
-
console.
|
|
22
|
+
console.warn("Failed to add highlight for locator method: isEditable");
|
|
22
23
|
}
|
|
23
24
|
return result;
|
|
24
25
|
};
|
|
@@ -1 +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;
|
|
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;AAIhD,wBAAgB,gBAAgB,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAwBpE"}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.patchTextContent = void 0;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
4
5
|
function patchTextContent(LocatorClass) {
|
|
5
6
|
const originalTextContent = LocatorClass.prototype.textContent;
|
|
6
7
|
//ref: https://github.com/microsoft/playwright/blob/69287f26bc514b740eac40160503d6fac8185d37/packages/playwright-core/src/client/locator.ts#L318
|
|
7
8
|
LocatorClass.prototype.textContent = async function (options) {
|
|
8
9
|
const result = await originalTextContent.apply(this, [options]);
|
|
9
10
|
try {
|
|
10
|
-
await this.scrollIntoViewIfNeeded();
|
|
11
11
|
await this.evaluate((node) => {
|
|
12
|
+
node.scrollIntoViewIfNeeded();
|
|
12
13
|
node.classList.add("empirical-element-grab-highlight");
|
|
13
14
|
setTimeout(() => {
|
|
14
|
-
if (node.isConnected) {
|
|
15
|
+
if (node && node.isConnected && node.classList) {
|
|
15
16
|
node.classList.remove("empirical-element-grab-highlight");
|
|
16
17
|
}
|
|
17
18
|
}, 2000);
|
|
18
|
-
});
|
|
19
|
+
}, undefined, { timeout: constants_1.DEFAULT_SCRIPT_EXECUTION_TIMEOUT });
|
|
19
20
|
}
|
|
20
21
|
catch (e) {
|
|
21
|
-
console.
|
|
22
|
+
console.warn("Failed to add highlight for locator method: textContent");
|
|
22
23
|
}
|
|
23
24
|
return result;
|
|
24
25
|
};
|