fix: align humanize timeout default with Playwright's 30s auto-retry (#172)

The humanize layer hardcoded timeout=2000ms for element lookups, causing
locator.click() and page.click() to fail instantly instead of retrying
for 30s like standard Playwright. Aligned all defaults to 30000ms across
Python sync/async, JS Playwright, and JS Puppeteer paths. Bumped the
outer retry sleep from 200ms to 500ms for DOM mutation settle time.
This commit is contained in:
CloakHQ
2026-05-01 20:48:06 +02:00
parent 2df8c7e2d1
commit f01902025a
8 changed files with 30 additions and 42 deletions
+2 -2
View File
@@ -1108,7 +1108,7 @@ describe("page.click(selector, { timeout }) forwards timeout to scroll", () => {
expect(boundingBox).toHaveBeenCalledWith({ timeout: 5000 });
});
it("default timeout stays 2000ms when not specified", async () => {
it("default timeout matches Playwright's 30000ms when not specified", async () => {
const { scrollToElement } = await import("../src/human/scroll.js");
const cfg = resolveConfig("default");
@@ -1125,7 +1125,7 @@ describe("page.click(selector, { timeout }) forwards timeout to scroll", () => {
};
await scrollToElement(page, raw, "#x", 0, 0, cfg);
expect(boundingBox).toHaveBeenCalledWith({ timeout: 2000 });
expect(boundingBox).toHaveBeenCalledWith({ timeout: 30000 });
});
it("page.click({ timeout }) reaches scrollToElement", async () => {
+2
View File
@@ -1671,11 +1671,13 @@ describe("Puppeteer: isInputElement stealth integration via patchPage", () => {
}),
});
const mockEl = buildMockElementHandle();
const page = buildMockPage({
evaluate: vi.fn(async (...args: any[]) => {
evaluateCalls.push(args);
return false;
}),
$: vi.fn(async () => mockEl),
});
page.createCDPSession = vi.fn(async () => mockCdp);