@skrillex1224/playwright-toolkit 2.1.23 → 2.1.24
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/dist/index.cjs +8 -3
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +8 -3
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -685,10 +685,13 @@ var Humanize = {
|
|
|
685
685
|
*/
|
|
686
686
|
async humanScroll(page, target, options = {}) {
|
|
687
687
|
const { maxSteps = 25, minStep = 80, maxStep = 220 } = options;
|
|
688
|
+
const targetDesc = typeof target === "string" ? target : "ElementHandle";
|
|
689
|
+
logger4.debug("humanScroll", `target=${targetDesc}`);
|
|
688
690
|
let element;
|
|
689
691
|
if (typeof target === "string") {
|
|
690
692
|
element = await page.$(target);
|
|
691
693
|
if (!element) {
|
|
694
|
+
logger4.warn("humanScroll", `Element not found: ${target}`);
|
|
692
695
|
return { element: null, didScroll: false, restore: async () => {
|
|
693
696
|
} };
|
|
694
697
|
}
|
|
@@ -719,6 +722,7 @@ var Humanize = {
|
|
|
719
722
|
return false;
|
|
720
723
|
});
|
|
721
724
|
if (!needsScroll) {
|
|
725
|
+
logger4.debug("humanScroll", "Element already in view");
|
|
722
726
|
return { element, didScroll: false, restore: async () => {
|
|
723
727
|
} };
|
|
724
728
|
}
|
|
@@ -828,6 +832,7 @@ var Humanize = {
|
|
|
828
832
|
await scrollStateHandle.dispose();
|
|
829
833
|
}
|
|
830
834
|
};
|
|
835
|
+
logger4.success("humanScroll", "Scroll completed");
|
|
831
836
|
return { element, didScroll: true, restore };
|
|
832
837
|
},
|
|
833
838
|
/**
|
|
@@ -842,7 +847,7 @@ var Humanize = {
|
|
|
842
847
|
*/
|
|
843
848
|
async humanClick(page, target, options = {}) {
|
|
844
849
|
const cursor = $GetCursor(page);
|
|
845
|
-
const { reactionDelay = 250, throwOnMissing = true, scrollIfNeeded = true } = options;
|
|
850
|
+
const { reactionDelay = 250, throwOnMissing = true, scrollIfNeeded = true, restore = false } = options;
|
|
846
851
|
const targetDesc = target == null ? "Current Position" : typeof target === "string" ? target : "ElementHandle";
|
|
847
852
|
logger4.start("humanClick", `target=${targetDesc}`);
|
|
848
853
|
try {
|
|
@@ -877,8 +882,8 @@ var Humanize = {
|
|
|
877
882
|
}
|
|
878
883
|
};
|
|
879
884
|
if (scrollIfNeeded) {
|
|
880
|
-
const { restore, didScroll } = await this.humanScroll(page, element);
|
|
881
|
-
restoreOnce2.do = didScroll
|
|
885
|
+
const { restore: restoreFn, didScroll } = await this.humanScroll(page, element);
|
|
886
|
+
restoreOnce2.do = didScroll && restore ? restoreFn : null;
|
|
882
887
|
}
|
|
883
888
|
const box = await element.boundingBox();
|
|
884
889
|
if (!box) {
|