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.dev.org.tw')
browser.addLocatorStrategy('myStrat', (selector) => {
return document.querySelectorAll(selector)
})
const projectTitle = await browser.custom$('myStrat', '.projectTitle')
console.log(await projectTitle.getText()) // WEBDRIVER I/O
})