custom$
Le custom$
vous permet d'utiliser une stratégie personnalisée déclarée à l'aide de browser.addLocatorStrategy
.
Pour en savoir plus sur les stratégies de sélecteur personnalisées, consultez la documentation des Sélecteurs.
Utilisation
browser.custom$(strategyName, strategyArguments)
Paramètres
Nom | Type | Détails |
---|---|---|
strategyName | string | |
strategyArguments | * |
Exemples
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
})
Retourne
- <WebdriverIO.Element>