Skip to main content

custom$

The custom$ allows you to use a custom strategy declared by using browser.addLocatorStrategy. Read more on custom selector stratgies in the Selector docs.

Usage
browser.custom$(strategyName, strategyArguments)
Parameters
NameTypeDetails
strategyNamestring
strategyArgumentsparam
Examples
customStrategy.js
loading...
example.html
loading...
customStrategy.js
loading...
example.js
it('should fetch the project title', async () => {
await browser.url('https://webdriver.io')
browser.addLocatorStrategy('myStrat', (selector) => {
return document.querySelectorAll(selector)
})

const projectTitle = await browser.custom$('myStrat', '.projectTitle')

console.log(await projectTitle.getText()) // WEBDRIVER I/O
})

Welcome! How can I help?

WebdriverIO AI Copilot