Перейти до основного вмісту

custom$

Команда custom$ дозволяє використовувати власну стратегію, оголошену за допомогою browser.addLocatorStrategy. Дізнайтеся більше про власні стратегії селекторів у документації по селекторам.

Використання
$(selector).custom$(strategyName, strategyArguments)
Параметри
НазваТипДеталі
strategyNamestring
strategyArguments*
Приклади
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
})
Повертає
  • <WebdriverIO.Element>

Welcome! How can I help?

WebdriverIO AI Copilot