@bigbinary/neeto-playwright-commons 1.26.11 → 1.26.12

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/index.cjs.js CHANGED
@@ -4907,7 +4907,7 @@ const removeCredentialFile = () => {
4907
4907
  require$$0__namespace.unlink(STORAGE_STATE, error => {
4908
4908
  if (!error)
4909
4909
  return;
4910
- console.log(error);
4910
+ console.error(error);
4911
4911
  });
4912
4912
  };
4913
4913
  const clearCredentials = () => {
@@ -4976,7 +4976,43 @@ const getListCount = async ({ page, countSelector, }) => {
4976
4976
  return Number(countText === null || countText === void 0 ? void 0 : countText.trim().split(" ")[0]);
4977
4977
  };
4978
4978
  const getGlobalUserProps = async (page) => (await page.evaluate(() => window.globalProps.user));
4979
- const getClipboardContent = (page) => page.evaluate(() => navigator.clipboard.readText());
4979
+ const createTextareaAndEvaluateCopiedText = async (page) => {
4980
+ const textareaHandle = await page.evaluateHandle(() => {
4981
+ const textarea = document.createElement("textarea");
4982
+ Object.assign(textarea.style, {
4983
+ position: "fixed",
4984
+ top: "0",
4985
+ left: "0",
4986
+ opacity: "0",
4987
+ pointerEvents: "none",
4988
+ zIndex: "9999",
4989
+ });
4990
+ document.body.appendChild(textarea);
4991
+ textarea.focus();
4992
+ return textarea;
4993
+ });
4994
+ try {
4995
+ await page.keyboard.press("ControlOrMeta+v");
4996
+ return await page.evaluate(el => el.value, textareaHandle);
4997
+ }
4998
+ finally {
4999
+ await textareaHandle.evaluate(el => el.remove());
5000
+ await textareaHandle.dispose();
5001
+ }
5002
+ };
5003
+ const getClipboardContent = async (page) => {
5004
+ // Attempt 1: Native Clipboard API
5005
+ const clipboardText = await page.evaluate(async () => {
5006
+ var _a;
5007
+ if (!((_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.readText))
5008
+ return null;
5009
+ return await navigator.clipboard.readText();
5010
+ });
5011
+ if (ramda.isNotNil(clipboardText))
5012
+ return clipboardText;
5013
+ // Attempt 2: Keyboard paste fallback
5014
+ return createTextareaAndEvaluateCopiedText(page);
5015
+ };
4980
5016
  const grantClipboardPermissions = (context) => context.grantPermissions(["clipboard-read", "clipboard-write"]);
4981
5017
  const getFullUrl = (path) => shouldSkipCustomDomainSetup() ? path : `${process.env.BASE_URL}${path}`;
4982
5018
  const globalShortcuts = (t) => [