Przejdź do głównej treści

custom$

Funkcja custom$ pozwala na użycie niestandardowej strategii zadeklarowanej przy użyciu browser.addLocatorStrategy. Przeczytaj więcej o niestandardowych strategiach selektorów w dokumentacji Selektorów.

Użycie
$(selector).custom$(strategyName, strategyArguments)
Parametry
NazwaTypSzczegóły
strategyNamestring
strategyArguments*
Przykłady
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
})
Zwraca
  • <WebdriverIO.Element>

Welcome! How can I help?

WebdriverIO AI Copilot