Vai al contenuto principale

custom$

Il custom$ ti consente di utilizzare una strategia personalizzata dichiarata utilizzando browser.addLocatorStrategy. Leggi di più sulle strategie di selezione personalizzate nella documentazione dei Selettori.

Utilizzo
browser.custom$(strategyName, strategyArguments)
Parametri
NomeTipoDettagli
strategyNamestring
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')
browser.addLocatorStrategy('myStrat', (selector) => {
return document.querySelectorAll(selector)
})

const projectTitle = await browser.custom$('myStrat', '.projectTitle')

console.log(await projectTitle.getText()) // WEBDRIVER I/O
})
Restituisce
  • <WebdriverIO.Element>

Welcome! How can I help?

WebdriverIO AI Copilot