custom$
custom$
を使用すると、browser.addLocatorStrategy
を使用して宣言したカスタム戦略を使用できます。
カスタムセレクタ戦略の詳細については、セレクタドキュメントを ご覧ください。
使用法
browser.custom$(strategyName, strategyArguments)
パラメータ
名前 | タイプ | 詳細 |
---|---|---|
strategyName | string | |
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')
browser.addLocatorStrategy('myStrat', (selector) => {
return document.querySelectorAll(selector)
})
const projectTitle = await browser.custom$('myStrat', '.projectTitle')
console.log(await projectTitle.getText()) // WEBDRIVER I/O
})
戻り値
- <WebdriverIO.Element>