Skip to content

click()

Fetches an element with the given selector, scrolls it into view if needed, and then clicks in the center of the element. If there’s no element matching selector, the method throws an error.

await click('Get Started')
await click(link('Get Started'))
await click({x : 170, y : 567})
await click('Get Started', { navigationTimeout: 60000, force: true })
await click('Get Started', { navigationTimeout: 60000 }, below('text'))
await click('Get Started', { navigationTimeout: 60000, position: 'right' }, below('text'))
Name Type Description
selector selector | string | Object A selector to search for element to click / coordinates of the elemets to click on. If there are multiple elements satisfying the selector, the first will be clicked.
options Object Default: {}.
options.waitForNavigation boolean Wait for navigation after the click. Default navigation timeout is 30 seconds, to override pass { navigationTimeout: 10000 } in options parameter. Default: true.
options.navigationTimeout number Navigation timeout value in milliseconds for navigation after click. Default: 30000.
options.button string left, right, or middle. Default: 'left'.
options.clickCount number Number of times to click on the element. Default: 1.
options.elementsToMatch number Number of elements to loop through to match the element with given selector. Default: 10.
options.waitForEvents Array Events available to wait for [‘DOMContentLoaded’, ‘loadEventFired’, ‘networkAlmostIdle’, ‘networkIdle’, ‘firstPaint’, ‘firstContentfulPaint’, ‘firstMeaningfulPaint’, ‘targetNavigated’] Default: [].
options.waitForStart number time to wait for navigation to start. Accepts time in milliseconds. Default: 100.
options.force boolean Set to true to perform action on hidden/disabled elements. Default: false.
options.position string Available positions right, left, topRight, topLeft, bottomRight, bottomLeft Default: 'right'.
args Array Proximity selectors
Type Description
Promise<void>