@empiricalrun/playwright-utils 0.6.1 → 0.6.3

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @empiricalrun/playwright-utils
2
2
 
3
+ ## 0.6.3
4
+
5
+ ### Patch Changes
6
+
7
+ - e605188: fix: errors in firefox browser for scroll into view
8
+
9
+ ## 0.6.2
10
+
11
+ ### Patch Changes
12
+
13
+ - cfc58de: fix: reduce highlighter log size and internal timeout fix
14
+
3
15
  ## 0.6.1
4
16
 
5
17
  ### Patch Changes
@@ -0,0 +1,2 @@
1
+ export declare const DEFAULT_SCRIPT_EXECUTION_TIMEOUT = 500;
2
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/test/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gCAAgC,MAAM,CAAC"}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_SCRIPT_EXECUTION_TIMEOUT = void 0;
4
+ exports.DEFAULT_SCRIPT_EXECUTION_TIMEOUT = 500;
@@ -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,QA2B/D"}
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,QAmC/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,23 @@ 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
+ if (node.scrollIntoViewIfNeeded) {
16
+ node.scrollIntoViewIfNeeded();
17
+ }
18
+ else {
19
+ node.scrollIntoView();
20
+ }
15
21
  node.classList.add("empirical-element-grab-highlight");
16
22
  setTimeout(() => {
17
- if (node.isConnected) {
23
+ if (node && node.isConnected && node.classList) {
18
24
  node.classList.remove("empirical-element-grab-highlight");
19
25
  }
20
26
  }, 2000);
21
- });
27
+ }, undefined, { timeout: constants_1.DEFAULT_SCRIPT_EXECUTION_TIMEOUT });
22
28
  }
23
29
  catch (e) {
24
- console.error("Failed to add highlight for locator method: _expect", e);
30
+ console.warn("Failed to add highlight for locator method: _expect");
25
31
  }
26
32
  }
27
33
  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;AAE3C,wBAAgB,UAAU,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAmB9D"}
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,QA2B9D"}
@@ -1,24 +1,30 @@
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
+ if (node.scrollIntoViewIfNeeded) {
13
+ node.scrollIntoViewIfNeeded();
14
+ }
15
+ else {
16
+ node.scrollIntoView();
17
+ }
12
18
  node.classList.add("empirical-element-grab-highlight");
13
19
  setTimeout(() => {
14
- if (node.isConnected) {
20
+ if (node && node.isConnected && node.classList) {
15
21
  node.classList.remove("empirical-element-grab-highlight");
16
22
  }
17
23
  }, 2000);
18
- });
24
+ }, undefined, { timeout: constants_1.DEFAULT_SCRIPT_EXECUTION_TIMEOUT });
19
25
  }
20
26
  catch (e) {
21
- console.log("Failed to add highlight for locator method: hover", e);
27
+ console.warn("Failed to add highlight for locator method: hover");
22
28
  }
23
29
  };
24
30
  }
@@ -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,QAoBlE"}
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,QA4BlE"}
@@ -1,24 +1,30 @@
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
+ if (node.scrollIntoViewIfNeeded) {
13
+ node.scrollIntoViewIfNeeded();
14
+ }
15
+ else {
16
+ node.scrollIntoView();
17
+ }
12
18
  node.classList.add("empirical-element-grab-highlight");
13
19
  setTimeout(() => {
14
- if (node.isConnected) {
20
+ if (node && node.isConnected && node.classList) {
15
21
  node.classList.remove("empirical-element-grab-highlight");
16
22
  }
17
23
  }, 2000);
18
- });
24
+ }, undefined, { timeout: constants_1.DEFAULT_SCRIPT_EXECUTION_TIMEOUT });
19
25
  }
20
26
  catch (e) {
21
- console.log("Failed to add highlight for locator method: innerText", e);
27
+ console.warn("Failed to add highlight for locator method: innerText");
22
28
  }
23
29
  return result;
24
30
  };
@@ -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,QAoBnE"}
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,QA4BnE"}
@@ -1,24 +1,30 @@
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
+ if (node.scrollIntoViewIfNeeded) {
13
+ node.scrollIntoViewIfNeeded();
14
+ }
15
+ else {
16
+ node.scrollIntoView();
17
+ }
12
18
  node.classList.add("empirical-element-grab-highlight");
13
19
  setTimeout(() => {
14
- if (node.isConnected) {
20
+ if (node && node.isConnected && node.classList) {
15
21
  node.classList.remove("empirical-element-grab-highlight");
16
22
  }
17
23
  }, 2000);
18
- });
24
+ }, undefined, { timeout: constants_1.DEFAULT_SCRIPT_EXECUTION_TIMEOUT });
19
25
  }
20
26
  catch (e) {
21
- console.log("Failed to add highlight for locator method: inputValue", e);
27
+ console.warn("Failed to add highlight for locator method: inputValue");
22
28
  }
23
29
  return result;
24
30
  };
@@ -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,QAoBlE"}
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,QA4BlE"}
@@ -1,24 +1,30 @@
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
+ if (node.scrollIntoViewIfNeeded) {
13
+ node.scrollIntoViewIfNeeded();
14
+ }
15
+ else {
16
+ node.scrollIntoView();
17
+ }
12
18
  node.classList.add("empirical-element-grab-highlight");
13
19
  setTimeout(() => {
14
- if (node.isConnected) {
20
+ if (node && node.isConnected && node.classList) {
15
21
  node.classList.remove("empirical-element-grab-highlight");
16
22
  }
17
23
  }, 2000);
18
- });
24
+ }, undefined, { timeout: constants_1.DEFAULT_SCRIPT_EXECUTION_TIMEOUT });
19
25
  }
20
26
  catch (e) {
21
- console.log("Failed to add highlight for locator method: isChecked", e);
27
+ console.warn("Failed to add highlight for locator method: isChecked");
22
28
  }
23
29
  return result;
24
30
  };
@@ -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,QAoBnE"}
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,QA4BnE"}
@@ -1,24 +1,30 @@
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
+ if (node.scrollIntoViewIfNeeded) {
13
+ node.scrollIntoViewIfNeeded();
14
+ }
15
+ else {
16
+ node.scrollIntoView();
17
+ }
12
18
  node.classList.add("empirical-element-grab-highlight");
13
19
  setTimeout(() => {
14
- if (node.isConnected) {
20
+ if (node && node.isConnected && node.classList) {
15
21
  node.classList.remove("empirical-element-grab-highlight");
16
22
  }
17
23
  }, 2000);
18
- });
24
+ }, undefined, { timeout: constants_1.DEFAULT_SCRIPT_EXECUTION_TIMEOUT });
19
25
  }
20
26
  catch (e) {
21
- console.log("Failed to add highlight for locator method: isDisabled", e);
27
+ console.warn("Failed to add highlight for locator method: isDisabled");
22
28
  }
23
29
  return result;
24
30
  };
@@ -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,QAoBnE"}
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,QA4BnE"}
@@ -1,24 +1,30 @@
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
+ if (node.scrollIntoViewIfNeeded) {
13
+ node.scrollIntoViewIfNeeded();
14
+ }
15
+ else {
16
+ node.scrollIntoView();
17
+ }
12
18
  node.classList.add("empirical-element-grab-highlight");
13
19
  setTimeout(() => {
14
- if (node.isConnected) {
20
+ if (node && node.isConnected && node.classList) {
15
21
  node.classList.remove("empirical-element-grab-highlight");
16
22
  }
17
23
  }, 2000);
18
- });
24
+ }, undefined, { timeout: constants_1.DEFAULT_SCRIPT_EXECUTION_TIMEOUT });
19
25
  }
20
26
  catch (e) {
21
- console.log("Failed to add highlight for locator method: isEditable", e);
27
+ console.warn("Failed to add highlight for locator method: isEditable");
22
28
  }
23
29
  return result;
24
30
  };
@@ -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;AAEhD,wBAAgB,gBAAgB,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAoBpE"}
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,QA4BpE"}
@@ -1,24 +1,30 @@
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
+ if (node.scrollIntoViewIfNeeded) {
13
+ node.scrollIntoViewIfNeeded();
14
+ }
15
+ else {
16
+ node.scrollIntoView();
17
+ }
12
18
  node.classList.add("empirical-element-grab-highlight");
13
19
  setTimeout(() => {
14
- if (node.isConnected) {
20
+ if (node && node.isConnected && node.classList) {
15
21
  node.classList.remove("empirical-element-grab-highlight");
16
22
  }
17
23
  }, 2000);
18
- });
24
+ }, undefined, { timeout: constants_1.DEFAULT_SCRIPT_EXECUTION_TIMEOUT });
19
25
  }
20
26
  catch (e) {
21
- console.log("Failed to add highlight for locator method: textContent", e);
27
+ console.warn("Failed to add highlight for locator method: textContent");
22
28
  }
23
29
  return result;
24
30
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/playwright-utils",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"