custom$$
The customs$$
allows you to use a custom strategy declared by using browser.addLocatorStrategy
Usage
$(selector).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 pluginRowBlock = await browser.custom$('myStrat', '.pluginRowBlock')
const pluginWrapper = await pluginRowBlock.custom$$('myStrat', '.pluginWrapper')
console.log(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 pluginRowBlock = browser.custom$('myStrat', '.pluginRowBlock')
const pluginWrapper = pluginRowBlock.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.