custom$
Il custom$
ti permette di utilizzare una strategia personalizzata dichiarata utilizzando browser.addLocatorStrategy
.
Leggi di più sulle strategie di selezione personalizzate nella documentazione dei Selettori.
Utilizzo
$(selector).custom$(strategyName, strategyArguments)
Parametri
Nome | Tipo | Dettagli |
---|---|---|
strategyName | string | |
strategyArguments | * |
Esempi
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
})
Restituisce
- <WebdriverIO.Element>