本文へスキップ

custom$

custom$ を使用すると、browser.addLocatorStrategy を使用して宣言されたカスタム戦略を使用できます。セレクターに関するドキュメントで、カスタムセレクター戦略について詳しく説明しています。

使用方法
browser.custom$(strategyName, strategyArguments)
パラメーター
名前詳細
strategyName文字列
strategyArgumentsパラメーター
customStrategy.js
loading...
example.html
loading...
customStrategy.js
loading...
example.js
it('should fetch the project title', async () => {
await browser.url('https://webdriverio.dokyumento.jp')
browser.addLocatorStrategy('myStrat', (selector) => {
return document.querySelectorAll(selector)
})

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

console.log(await projectTitle.getText()) // WEBDRIVER I/O
})

ようこそ!ご質問があればお気軽にお尋ねください。

WebdriverIO AI Copilot