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>