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.waitForNavigationboolean -
Wait for navigation after the click. Default navigation timeout is 30 seconds, to override pass
{ navigationTimeout: 10000 }inoptionsparameter.- Default value
-
true
-
options.navigationTimeoutnumber -
Navigation timeout value in milliseconds for navigation after click.
- Default value
-
30000
-
options.buttonstring -
left,right, ormiddle.- Default value
-
'left'
-
options.clickCountnumber -
Number of times to click on the element.
- Default value
-
1
-
options.elementsToMatchnumber -
Number of elements to loop through to match the element with given selector.
- Default value
-
10
-
options.waitForEventsArray<string> -
Events available to wait for ['DOMContentLoaded', 'loadEventFired', 'networkAlmostIdle', 'networkIdle', 'firstPaint', 'firstContentfulPaint', 'firstMeaningfulPaint', 'targetNavigated']
- Default value
-
[]
-
options.waitForStartnumber -
time to wait for navigation to start. Accepts time in milliseconds.
- Default value
-
100
-
options.forceboolean -
Set to true to perform action on hidden/disabled elements.
- Default value
-
false
-
options.positionstring -
Available positions right, left, topRight, topLeft, bottomRight, bottomLeft
- Default value
-
'right'
-
argsArray -
Proximity selectors
Returns
Promise<void>