Taiko
Documentation

Home / API Reference

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.

Examples

await click('Get Started')
await click(link('Get Started'))
await click({x : 170, y : 567})

Parameters


selector

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

options.waitForNavigation boolean

Wait for navigation after the click. Default navigation timeout is 30 seconds, to override pass { navigationTimeout: 10000 } in options parameter.

Default value
true

options.navigationTimeout number

Navigation timeout value in milliseconds for navigation after click.

Default value
30000

options.button string

left, right, or middle.

Default value
'left'

options.clickCount number

Number of times to click on the element.

Default value
1

options.elementsToMatch number

Number of elements to loop through to match the element with given selector.

Default value
10

options.waitForEvents

Events available to wait for ['DOMContentLoaded', 'loadEventFired', 'networkAlmostIdle', 'networkIdle', 'firstPaint', 'firstContentfulPaint', 'firstMeaningfulPaint']

Default value
['firstMeaningfulPaint']

options.waitForStart number

time to wait for navigation to start. Accepts time in milliseconds.

Default value
100

args Array

Returns

Promise