custom$$
The customs$$
allows you to use a custom strategy declared by using browser.addLocatorStrategy
Usage
browser.custom$$(strategyName, strategyArguments)
Parameters
Name | Type | Details |
---|---|---|
strategyName | String | |
strategyArguments | Any |
Example
- Asynchronous Mode
- Synchronous Mode
example.js
it('should get all the plugin wrapper buttons', async () => {
await browser.url('https://webdriver.io')
await browser.addLocatorStrategy('myStrat', (selector) => {
return document.querySelectorAll(selector)
})
const pluginWrapper = await browser.custom$$('myStrat', '.pluginWrapper')
console.log(await pluginWrapper.length) // 4
})
example.js
it('should get all the plugin wrapper buttons', () => {
browser.url('https://webdriver.io')
browser.addLocatorStrategy('myStrat', (selector) => {
return document.querySelectorAll(selector)
})
const pluginWrapper = browser.custom$$('myStrat', '.pluginWrapper')
console.log(pluginWrapper.length) // 4
})
caution
Synchronous Mode will depcrecated with Node.js v16. With an update to the underlying Chromium version it became technically impossible to provide the same synchronous behavior. We recommend to start transition to asynchronous command execution. For more information, see our RFC.