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'))
NameTypeDescription
selectorselector | string | ObjectA 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.
optionsObjectDefault: {}.
options.waitForNavigationbooleanWait for navigation after the click. Default navigation timeout is 30 seconds, to override pass { navigationTimeout: 10000 } in options parameter. Default: true.
options.navigationTimeoutnumberNavigation timeout value in milliseconds for navigation after click. Default: 30000.
options.buttonstringleft, right, or middle. Default: 'left'.
options.clickCountnumberNumber of times to click on the element. Default: 1.
options.elementsToMatchnumberNumber of elements to loop through to match the element with given selector. Default: 10.
options.waitForEventsArrayEvents available to wait for [‘DOMContentLoaded’, ‘loadEventFired’, ‘networkAlmostIdle’, ‘networkIdle’, ‘firstPaint’, ‘firstContentfulPaint’, ‘firstMeaningfulPaint’, ‘targetNavigated’] Default: [].
options.waitForStartnumbertime to wait for navigation to start. Accepts time in milliseconds. Default: 100.
options.forcebooleanSet to true to perform action on hidden/disabled elements. Default: false.
options.positionstringAvailable positions right, left, topRight, topLeft, bottomRight, bottomLeft Default: 'right'.
argsArrayProximity selectors
TypeDescription
Promise<void>