メインコンテンツにスキップ

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