@skrillex1224/playwright-toolkit 2.1.32 → 2.1.33
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 +9 -4
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +9 -4
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -655,7 +655,7 @@ var Humanize = {
|
|
|
655
655
|
* @param {number} [options.maxStep=220] - 单次滚动最大步长
|
|
656
656
|
*/
|
|
657
657
|
async humanScroll(page, target, options = {}) {
|
|
658
|
-
const { maxSteps = 30, minStep =
|
|
658
|
+
const { maxSteps = 30, minStep = 150, maxStep = 400 } = options;
|
|
659
659
|
const targetDesc = typeof target === "string" ? target : "ElementHandle";
|
|
660
660
|
logger4.debug(`humanScroll | \u76EE\u6807=${targetDesc}`);
|
|
661
661
|
let element;
|
|
@@ -693,7 +693,10 @@ var Humanize = {
|
|
|
693
693
|
tag: pointElement.tagName,
|
|
694
694
|
id: pointElement.id,
|
|
695
695
|
className: pointElement.className
|
|
696
|
-
}
|
|
696
|
+
},
|
|
697
|
+
cy,
|
|
698
|
+
// Return Center Y for smart direction calculation
|
|
699
|
+
viewH
|
|
697
700
|
};
|
|
698
701
|
}
|
|
699
702
|
return { code: "VISIBLE" };
|
|
@@ -720,7 +723,9 @@ var Humanize = {
|
|
|
720
723
|
deltaY = 100;
|
|
721
724
|
}
|
|
722
725
|
} else if (status.code === "OBSTRUCTED") {
|
|
723
|
-
|
|
726
|
+
const isBottomHalf = status.cy > status.viewH / 2;
|
|
727
|
+
const direction = isBottomHalf ? 1 : -1;
|
|
728
|
+
deltaY = direction * (minStep + Math.random() * 50);
|
|
724
729
|
}
|
|
725
730
|
if (i === 0 || Math.random() < 0.2) {
|
|
726
731
|
const viewSize = page.viewportSize();
|
|
@@ -732,7 +737,7 @@ var Humanize = {
|
|
|
732
737
|
}
|
|
733
738
|
await page.mouse.wheel(0, deltaY);
|
|
734
739
|
didScroll = true;
|
|
735
|
-
await delay2(this.jitterMs(
|
|
740
|
+
await delay2(this.jitterMs(100 + Math.random() * 150, 0.2));
|
|
736
741
|
}
|
|
737
742
|
logger4.warn(`humanScroll | \u5728 ${maxSteps} \u6B65\u540E\u65E0\u6CD5\u786E\u4FDD\u53EF\u89C1\u6027`);
|
|
738
743
|
return { element, didScroll };
|