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
})