Skip to Content

click

Click on an element. Scrolls into view before clicking.

Signature

await utils.click(target, options?)

Parameters

ParamTypeDefaultDescription
targetstring | ElementHandle—CSS selector, XPath, or an existing ElementHandle
options.waitTimeoutnumber2000Max wait time for element (ms)
options.delaynumber1000Delay before clicking (ms), useful for page animations
options.frameFrame—Optional frame to search within

Examples

// Basic click (waits up to 2s for element, 1s delay before click) await utils.click("#submit"); // Instant click, no delay await utils.click("#btn", { delay: 0 }); // Wait up to 8s for element, then click await utils.click("#lazy-btn", { waitTimeout: 8000 }); // Click an existing ElementHandle const el = await utils.waitForElement("#btn"); await utils.click(el);

Error Handling

Throws if the element is not found within waitTimeout.

Last updated on