Skip to content

focus()

Fetches an element with the given selector and focuses it. If there’s no element matching selector, the method throws an error.

await focus(textBox('Username:'))
await focus(textBox('Username:'), { waitForEvents: ['firstMeaningfulPaint'], force: true })
NameTypeDescription
selectorselector | stringA selector of an element to focus. If there are multiple elements satisfying the selector, the first will be focused.
optionsObjectDefault: {}.
options.forcebooleanSet to true to perform action on hidden/disabled elements. Default: false.
options.waitForEventsArrayEvents available to wait for [‘DOMContentLoaded’, ‘loadEventFired’, ‘networkAlmostIdle’, ‘networkIdle’, ‘firstPaint’, ‘firstContentfulPaint’, ‘firstMeaningfulPaint’, ‘targetNavigated’] Default: [].

This API does not return any values.