@empiricalrun/playwright-utils 0.20.0 → 0.20.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 +14 -0
- package/dist/test/scripts/pw-locator-patch/highlight/expect.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/highlight/expect.js +2 -21
- package/dist/test/scripts/pw-locator-patch/highlight/hover.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/highlight/hover.js +2 -15
- package/dist/test/scripts/pw-locator-patch/highlight/inner-text.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/highlight/inner-text.js +2 -21
- package/dist/test/scripts/pw-locator-patch/highlight/input-value.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/highlight/input-value.js +2 -21
- package/dist/test/scripts/pw-locator-patch/highlight/is-checked.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/highlight/is-checked.js +2 -21
- package/dist/test/scripts/pw-locator-patch/highlight/is-disabled.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/highlight/is-disabled.js +2 -21
- package/dist/test/scripts/pw-locator-patch/highlight/is-editable.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/highlight/is-editable.js +2 -21
- package/dist/test/scripts/pw-locator-patch/highlight/text-content.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/highlight/text-content.js +3 -22
- package/dist/test/scripts/pw-locator-patch/utils/index.d.ts +4 -0
- package/dist/test/scripts/pw-locator-patch/utils/index.d.ts.map +1 -0
- package/dist/test/scripts/pw-locator-patch/utils/index.js +43 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @empiricalrun/playwright-utils
|
|
2
2
|
|
|
3
|
+
## 0.20.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 1e3466d: fix: shared highlight method for all patch methods
|
|
8
|
+
|
|
9
|
+
## 0.20.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [46c0dab]
|
|
14
|
+
- @empiricalrun/llm@0.9.35
|
|
15
|
+
- @empiricalrun/test-gen@0.43.0
|
|
16
|
+
|
|
3
17
|
## 0.20.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expect.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/highlight/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/highlight/expect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAMhD,wBAAgB,WAAW,CAAC,YAAY,EAAE,QAAQ,GAAG;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAmB1E"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.patchExpect = void 0;
|
|
4
|
-
const
|
|
5
|
-
const constants_1 = require("../../../constants");
|
|
4
|
+
const utils_1 = require("../utils");
|
|
6
5
|
const isExpectPatched = new WeakMap();
|
|
7
6
|
function patchExpect(LocatorClass) {
|
|
8
7
|
if (isExpectPatched.get(LocatorClass)) {
|
|
@@ -15,25 +14,7 @@ function patchExpect(LocatorClass) {
|
|
|
15
14
|
LocatorClass.prototype._expect = async function (expression, options) {
|
|
16
15
|
const result = await originalExpect.apply(this, [expression, options]);
|
|
17
16
|
if (result.matches) {
|
|
18
|
-
|
|
19
|
-
await this.evaluate((node) => {
|
|
20
|
-
if (node.scrollIntoViewIfNeeded) {
|
|
21
|
-
node.scrollIntoViewIfNeeded();
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
node.scrollIntoView();
|
|
25
|
-
}
|
|
26
|
-
node.classList.add("empirical-element-grab-highlight");
|
|
27
|
-
setTimeout(() => {
|
|
28
|
-
if (node && node.isConnected && node.classList) {
|
|
29
|
-
node.classList.remove("empirical-element-grab-highlight");
|
|
30
|
-
}
|
|
31
|
-
}, 2000);
|
|
32
|
-
}, undefined, { timeout: constants_1.DEFAULT_SCRIPT_EXECUTION_TIMEOUT });
|
|
33
|
-
}
|
|
34
|
-
catch (e) {
|
|
35
|
-
logger_1.logger.debug("Failed to add highlight for locator method: _expect");
|
|
36
|
-
}
|
|
17
|
+
await (0, utils_1.scrollAndHighlight)(this);
|
|
37
18
|
}
|
|
38
19
|
return result;
|
|
39
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hover.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/highlight/hover.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"hover.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/highlight/hover.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAMhD,wBAAgB,UAAU,CAAC,YAAY,EAAE,QAAQ,GAAG;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAUzE"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.patchHover = void 0;
|
|
4
|
-
const
|
|
5
|
-
const constants_1 = require("../../../constants");
|
|
4
|
+
const utils_1 = require("../utils");
|
|
6
5
|
const isHoverPatched = new WeakMap();
|
|
7
6
|
function patchHover(LocatorClass) {
|
|
8
7
|
if (isHoverPatched.get(LocatorClass)) {
|
|
@@ -11,19 +10,7 @@ function patchHover(LocatorClass) {
|
|
|
11
10
|
const originalHover = LocatorClass.prototype.hover;
|
|
12
11
|
LocatorClass.prototype.hover = async function (options) {
|
|
13
12
|
await originalHover.apply(this, [options]);
|
|
14
|
-
|
|
15
|
-
await this.evaluate((node) => {
|
|
16
|
-
node.classList.add("empirical-element-grab-highlight");
|
|
17
|
-
setTimeout(() => {
|
|
18
|
-
if (node && node.isConnected && node.classList) {
|
|
19
|
-
node.classList.remove("empirical-element-grab-highlight");
|
|
20
|
-
}
|
|
21
|
-
}, 2000);
|
|
22
|
-
}, undefined, { timeout: constants_1.DEFAULT_SCRIPT_EXECUTION_TIMEOUT });
|
|
23
|
-
}
|
|
24
|
-
catch (e) {
|
|
25
|
-
logger_1.logger.debug("Failed to add highlight for locator method: hover");
|
|
26
|
-
}
|
|
13
|
+
await (0, utils_1.highlight)(this);
|
|
27
14
|
};
|
|
28
15
|
isHoverPatched.set(LocatorClass, true);
|
|
29
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inner-text.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/highlight/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/highlight/inner-text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAMhD,wBAAgB,cAAc,CAC5B,YAAY,EAAE,QAAQ,GAAG;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAahD"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.patchInnerText = void 0;
|
|
4
|
-
const
|
|
5
|
-
const constants_1 = require("../../../constants");
|
|
4
|
+
const utils_1 = require("../utils");
|
|
6
5
|
const isInnerTextPatched = new WeakMap();
|
|
7
6
|
function patchInnerText(LocatorClass) {
|
|
8
7
|
if (isInnerTextPatched.get(LocatorClass)) {
|
|
@@ -12,25 +11,7 @@ function patchInnerText(LocatorClass) {
|
|
|
12
11
|
//ref: https://github.com/microsoft/playwright/blob/69287f26bc514b740eac40160503d6fac8185d37/packages/playwright-core/src/client/locator.ts#L251
|
|
13
12
|
LocatorClass.prototype.innerText = async function (options) {
|
|
14
13
|
const result = await originalInnerText.apply(this, [options]);
|
|
15
|
-
|
|
16
|
-
await this.evaluate((node) => {
|
|
17
|
-
if (node.scrollIntoViewIfNeeded) {
|
|
18
|
-
node.scrollIntoViewIfNeeded();
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
node.scrollIntoView();
|
|
22
|
-
}
|
|
23
|
-
node.classList.add("empirical-element-grab-highlight");
|
|
24
|
-
setTimeout(() => {
|
|
25
|
-
if (node && node.isConnected && node.classList) {
|
|
26
|
-
node.classList.remove("empirical-element-grab-highlight");
|
|
27
|
-
}
|
|
28
|
-
}, 2000);
|
|
29
|
-
}, undefined, { timeout: constants_1.DEFAULT_SCRIPT_EXECUTION_TIMEOUT });
|
|
30
|
-
}
|
|
31
|
-
catch (e) {
|
|
32
|
-
logger_1.logger.debug("Failed to add highlight for locator method: innerText");
|
|
33
|
-
}
|
|
14
|
+
await (0, utils_1.scrollAndHighlight)(this);
|
|
34
15
|
return result;
|
|
35
16
|
};
|
|
36
17
|
isInnerTextPatched.set(LocatorClass, true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-value.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/highlight/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/highlight/input-value.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAMhD,wBAAgB,eAAe,CAC7B,YAAY,EAAE,QAAQ,GAAG;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAahD"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.patchInputValue = void 0;
|
|
4
|
-
const
|
|
5
|
-
const constants_1 = require("../../../constants");
|
|
4
|
+
const utils_1 = require("../utils");
|
|
6
5
|
const isInputValuePatched = new WeakMap();
|
|
7
6
|
function patchInputValue(LocatorClass) {
|
|
8
7
|
if (isInputValuePatched.get(LocatorClass)) {
|
|
@@ -12,25 +11,7 @@ function patchInputValue(LocatorClass) {
|
|
|
12
11
|
//ref: github.com/microsoft/playwright/blob/69287f26bc514b740eac40160503d6fac8185d37/packages/playwright-core/src/client/locator.ts#L255
|
|
13
12
|
LocatorClass.prototype.inputValue = async function (options) {
|
|
14
13
|
const result = await originalInputValue.apply(this, [options]);
|
|
15
|
-
|
|
16
|
-
await this.evaluate((node) => {
|
|
17
|
-
if (node.scrollIntoViewIfNeeded) {
|
|
18
|
-
node.scrollIntoViewIfNeeded();
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
node.scrollIntoView();
|
|
22
|
-
}
|
|
23
|
-
node.classList.add("empirical-element-grab-highlight");
|
|
24
|
-
setTimeout(() => {
|
|
25
|
-
if (node && node.isConnected && node.classList) {
|
|
26
|
-
node.classList.remove("empirical-element-grab-highlight");
|
|
27
|
-
}
|
|
28
|
-
}, 2000);
|
|
29
|
-
}, undefined, { timeout: constants_1.DEFAULT_SCRIPT_EXECUTION_TIMEOUT });
|
|
30
|
-
}
|
|
31
|
-
catch (e) {
|
|
32
|
-
logger_1.logger.debug("Failed to add highlight for locator method: inputValue");
|
|
33
|
-
}
|
|
14
|
+
await (0, utils_1.scrollAndHighlight)(this);
|
|
34
15
|
return result;
|
|
35
16
|
};
|
|
36
17
|
isInputValuePatched.set(LocatorClass, true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-checked.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/highlight/is-checked.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"is-checked.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/highlight/is-checked.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAMhD,wBAAgB,cAAc,CAC5B,YAAY,EAAE,QAAQ,GAAG;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAahD"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.patchIsChecked = void 0;
|
|
4
|
-
const
|
|
5
|
-
const constants_1 = require("../../../constants");
|
|
4
|
+
const utils_1 = require("../utils");
|
|
6
5
|
const isIsCheckedPatched = new WeakMap();
|
|
7
6
|
function patchIsChecked(LocatorClass) {
|
|
8
7
|
if (isIsCheckedPatched.get(LocatorClass)) {
|
|
@@ -12,25 +11,7 @@ function patchIsChecked(LocatorClass) {
|
|
|
12
11
|
LocatorClass.prototype.isChecked = async function (options) {
|
|
13
12
|
// ref: https://github.com/microsoft/playwright/blob/69287f26bc514b740eac40160503d6fac8185d37/packages/playwright-core/src/client/locator.ts#L259
|
|
14
13
|
const result = await originalIsChecked.apply(this, [options]);
|
|
15
|
-
|
|
16
|
-
await this.evaluate((node) => {
|
|
17
|
-
if (node.scrollIntoViewIfNeeded) {
|
|
18
|
-
node.scrollIntoViewIfNeeded();
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
node.scrollIntoView();
|
|
22
|
-
}
|
|
23
|
-
node.classList.add("empirical-element-grab-highlight");
|
|
24
|
-
setTimeout(() => {
|
|
25
|
-
if (node && node.isConnected && node.classList) {
|
|
26
|
-
node.classList.remove("empirical-element-grab-highlight");
|
|
27
|
-
}
|
|
28
|
-
}, 2000);
|
|
29
|
-
}, undefined, { timeout: constants_1.DEFAULT_SCRIPT_EXECUTION_TIMEOUT });
|
|
30
|
-
}
|
|
31
|
-
catch (e) {
|
|
32
|
-
logger_1.logger.debug("Failed to add highlight for locator method: isChecked");
|
|
33
|
-
}
|
|
14
|
+
await (0, utils_1.scrollAndHighlight)(this);
|
|
34
15
|
return result;
|
|
35
16
|
};
|
|
36
17
|
isIsCheckedPatched.set(LocatorClass, true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-disabled.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/highlight/is-disabled.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"is-disabled.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/highlight/is-disabled.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAMhD,wBAAgB,eAAe,CAC7B,YAAY,EAAE,QAAQ,GAAG;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAahD"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.patchIsDisabled = void 0;
|
|
4
|
-
const
|
|
5
|
-
const constants_1 = require("../../../constants");
|
|
4
|
+
const utils_1 = require("../utils");
|
|
6
5
|
const isIsDisabledPatched = new WeakMap();
|
|
7
6
|
function patchIsDisabled(LocatorClass) {
|
|
8
7
|
if (isIsDisabledPatched.get(LocatorClass)) {
|
|
@@ -12,25 +11,7 @@ function patchIsDisabled(LocatorClass) {
|
|
|
12
11
|
LocatorClass.prototype.isDisabled = async function (options) {
|
|
13
12
|
// ref: https://github.com/microsoft/playwright/blob/69287f26bc514b740eac40160503d6fac8185d37/packages/playwright-core/src/client/locator.ts#L263
|
|
14
13
|
const result = await originalIsDisabled.apply(this, [options]);
|
|
15
|
-
|
|
16
|
-
await this.evaluate((node) => {
|
|
17
|
-
if (node.scrollIntoViewIfNeeded) {
|
|
18
|
-
node.scrollIntoViewIfNeeded();
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
node.scrollIntoView();
|
|
22
|
-
}
|
|
23
|
-
node.classList.add("empirical-element-grab-highlight");
|
|
24
|
-
setTimeout(() => {
|
|
25
|
-
if (node && node.isConnected && node.classList) {
|
|
26
|
-
node.classList.remove("empirical-element-grab-highlight");
|
|
27
|
-
}
|
|
28
|
-
}, 2000);
|
|
29
|
-
}, undefined, { timeout: constants_1.DEFAULT_SCRIPT_EXECUTION_TIMEOUT });
|
|
30
|
-
}
|
|
31
|
-
catch (e) {
|
|
32
|
-
logger_1.logger.debug("Failed to add highlight for locator method: isDisabled");
|
|
33
|
-
}
|
|
14
|
+
await (0, utils_1.scrollAndHighlight)(this);
|
|
34
15
|
return result;
|
|
35
16
|
};
|
|
36
17
|
isIsDisabledPatched.set(LocatorClass, true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-editable.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/highlight/is-editable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"is-editable.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/highlight/is-editable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAMhD,wBAAgB,eAAe,CAC7B,YAAY,EAAE,QAAQ,GAAG;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAYhD"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.patchIsEditable = void 0;
|
|
4
|
-
const
|
|
5
|
-
const constants_1 = require("../../../constants");
|
|
4
|
+
const utils_1 = require("../utils");
|
|
6
5
|
const isIsEditablePatched = new WeakMap();
|
|
7
6
|
function patchIsEditable(LocatorClass) {
|
|
8
7
|
if (isIsEditablePatched.get(LocatorClass)) {
|
|
@@ -11,25 +10,7 @@ function patchIsEditable(LocatorClass) {
|
|
|
11
10
|
const originalIsEditable = LocatorClass.prototype.isEditable;
|
|
12
11
|
LocatorClass.prototype.isEditable = async function (options) {
|
|
13
12
|
const result = await originalIsEditable.apply(this, [options]);
|
|
14
|
-
|
|
15
|
-
await this.evaluate((node) => {
|
|
16
|
-
if (node.scrollIntoViewIfNeeded) {
|
|
17
|
-
node.scrollIntoViewIfNeeded();
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
node.scrollIntoView();
|
|
21
|
-
}
|
|
22
|
-
node.classList.add("empirical-element-grab-highlight");
|
|
23
|
-
setTimeout(() => {
|
|
24
|
-
if (node && node.isConnected && node.classList) {
|
|
25
|
-
node.classList.remove("empirical-element-grab-highlight");
|
|
26
|
-
}
|
|
27
|
-
}, 2000);
|
|
28
|
-
}, undefined, { timeout: constants_1.DEFAULT_SCRIPT_EXECUTION_TIMEOUT });
|
|
29
|
-
}
|
|
30
|
-
catch (e) {
|
|
31
|
-
logger_1.logger.debug("Failed to add highlight for locator method: isEditable");
|
|
32
|
-
}
|
|
13
|
+
await (0, utils_1.scrollAndHighlight)(this);
|
|
33
14
|
return result;
|
|
34
15
|
};
|
|
35
16
|
isIsEditablePatched.set(LocatorClass, true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-content.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/highlight/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/highlight/text-content.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAMhD,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,QAAQ,GAAG;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAahD"}
|
|
@@ -1,36 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.patchTextContent = void 0;
|
|
4
|
-
const
|
|
5
|
-
const constants_1 = require("../../../constants");
|
|
4
|
+
const utils_1 = require("../utils");
|
|
6
5
|
const isTextContentPatched = new WeakMap();
|
|
7
6
|
function patchTextContent(LocatorClass) {
|
|
8
7
|
if (isTextContentPatched.get(LocatorClass)) {
|
|
9
8
|
return;
|
|
10
9
|
}
|
|
11
10
|
const originalTextContent = LocatorClass.prototype.textContent;
|
|
12
|
-
//ref: https://github.com/microsoft/playwright/blob/69287f26bc514b740eac40160503d6fac8185d37/packages/playwright-core/src/client/locator.ts#L318
|
|
11
|
+
// ref: https://github.com/microsoft/playwright/blob/69287f26bc514b740eac40160503d6fac8185d37/packages/playwright-core/src/client/locator.ts#L318
|
|
13
12
|
LocatorClass.prototype.textContent = async function (options) {
|
|
14
13
|
const result = await originalTextContent.apply(this, [options]);
|
|
15
|
-
|
|
16
|
-
await this.evaluate((node) => {
|
|
17
|
-
if (node.scrollIntoViewIfNeeded) {
|
|
18
|
-
node.scrollIntoViewIfNeeded();
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
node.scrollIntoView();
|
|
22
|
-
}
|
|
23
|
-
node.classList.add("empirical-element-grab-highlight");
|
|
24
|
-
setTimeout(() => {
|
|
25
|
-
if (node && node.isConnected && node.classList) {
|
|
26
|
-
node.classList.remove("empirical-element-grab-highlight");
|
|
27
|
-
}
|
|
28
|
-
}, 2000);
|
|
29
|
-
}, undefined, { timeout: constants_1.DEFAULT_SCRIPT_EXECUTION_TIMEOUT });
|
|
30
|
-
}
|
|
31
|
-
catch (e) {
|
|
32
|
-
logger_1.logger.debug("Failed to add highlight for locator method: textContent");
|
|
33
|
-
}
|
|
14
|
+
await (0, utils_1.scrollAndHighlight)(this);
|
|
34
15
|
return result;
|
|
35
16
|
};
|
|
36
17
|
isTextContentPatched.set(LocatorClass, true);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAK1C,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,OAAO,iBAsBxD;AAED,wBAAsB,SAAS,CAAC,OAAO,EAAE,OAAO,iBAiB/C"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.highlight = exports.scrollAndHighlight = void 0;
|
|
4
|
+
const logger_1 = require("../../../../logger");
|
|
5
|
+
const constants_1 = require("../../../constants");
|
|
6
|
+
async function scrollAndHighlight(locator) {
|
|
7
|
+
try {
|
|
8
|
+
await locator.evaluate((node) => {
|
|
9
|
+
if (node.scrollIntoViewIfNeeded) {
|
|
10
|
+
node.scrollIntoViewIfNeeded();
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
node.scrollIntoView();
|
|
14
|
+
}
|
|
15
|
+
node.classList.add("empirical-element-grab-highlight");
|
|
16
|
+
setTimeout(() => {
|
|
17
|
+
if (node && node.isConnected && node.classList) {
|
|
18
|
+
node.classList.remove("empirical-element-grab-highlight");
|
|
19
|
+
}
|
|
20
|
+
}, 2000);
|
|
21
|
+
}, undefined, { timeout: constants_1.DEFAULT_SCRIPT_EXECUTION_TIMEOUT });
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
logger_1.logger.debug("Failed to scroll and highlight for locator method");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.scrollAndHighlight = scrollAndHighlight;
|
|
28
|
+
async function highlight(locator) {
|
|
29
|
+
try {
|
|
30
|
+
await locator.evaluate((node) => {
|
|
31
|
+
node.classList.add("empirical-element-grab-highlight");
|
|
32
|
+
setTimeout(() => {
|
|
33
|
+
if (node && node.isConnected && node.classList) {
|
|
34
|
+
node.classList.remove("empirical-element-grab-highlight");
|
|
35
|
+
}
|
|
36
|
+
}, 2000);
|
|
37
|
+
}, undefined, { timeout: constants_1.DEFAULT_SCRIPT_EXECUTION_TIMEOUT });
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
logger_1.logger.debug("Failed to add highlight for locator method");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.highlight = highlight;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/playwright-utils",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"playwright-core": "1.47.1",
|
|
43
43
|
"puppeteer-extra-plugin-recaptcha": "^3.6.8",
|
|
44
44
|
"rimraf": "^6.0.1",
|
|
45
|
-
"@empiricalrun/
|
|
46
|
-
"@empiricalrun/test-gen": "^0.
|
|
47
|
-
"@empiricalrun/
|
|
45
|
+
"@empiricalrun/llm": "^0.9.35",
|
|
46
|
+
"@empiricalrun/test-gen": "^0.43.0",
|
|
47
|
+
"@empiricalrun/r2-uploader": "^0.3.8"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"dev": "tsc --build --watch",
|