custom$
O custom$
permite que você use uma estratégia personalizada declarada usando browser.addLocatorStrategy
.
Leia mais sobre estratégias de seletores personalizados na documentação de Seletores.
Uso
browser.custom$(strategyName, strategyArguments)
Parâmetros
Nome | Tipo | Detalhes |
---|---|---|
strategyName | string | |
strategyArguments | * |
Exemplos
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
})
Retorna
- <WebdriverIO.Element>