click
Click on an element. Scrolls into view before clicking.
Signature
await utils.click(target, options?)Parameters
| Param | Type | Default | Description |
|---|---|---|---|
target | string | ElementHandle | — | CSS selector, XPath, or an existing ElementHandle |
options.waitTimeout | number | 2000 | Max wait time for element (ms) |
options.delay | number | 1000 | Delay before clicking (ms), useful for page animations |
options.frame | Frame | — | 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