Aller au contenu principal

custom$

Le custom$ vous permet d'utiliser une stratégie personnalisée déclarée en utilisant browser.addLocatorStrategy. Pour en savoir plus sur les stratégies de sélection personnalisées, consultez la documentation des sélecteurs.

Utilisation
$(selector).custom$(strategyName, strategyArguments)
Paramètres
NomTypeDétails
strategyNamestring
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')
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
})
Retourne
  • <WebdriverIO.Element>

Welcome! How can I help?

WebdriverIO AI Copilot