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
$(selector).custom$(strategyName, strategyArguments)
Parameters
Name | Type | Details |
---|---|---|
strategyName | string | |
strategyArguments | param |
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')
await browser.addLocatorStrategy('myStrat', (selector) => {
return document.querySelectorAll(selector)
})
const header = await browser.custom$('myStrat', 'header')
const projectTitle = await header.custom$('myStrat', '.projectTitle')
console.log(projectTitle.getText()) // WEBDRIVER I/O
})