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})
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'))

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 Array<string>

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

Default value
[]

options.waitForStart number

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

Default value
100

options.force boolean

Set to true to perform action on hidden/disabled elements.

Default value
false

options.position string

Available positions right, left, topRight, topLeft, bottomRight, bottomLeft

Default value
'right'

args Array

Proximity selectors


Returns

Promise<void>