跳至主要內容

custom$$

customs$$ 允許您使用透過 browser.addLocatorStrategy 宣告的自訂策略。在選取器文件中閱讀更多關於自訂選取器策略的資訊。

用法
browser.custom$$(strategyName, strategyArguments)
參數
名稱類型詳細資訊
strategyName字串
strategyArgumentsparam
範例
example.js
it('should get all the plugin wrapper buttons', async () => {
await browser.url('https://webdriverio.dev.org.tw')
await browser.addLocatorStrategy('myStrategy', (selector) => {
return document.querySelectorAll(selector)
})

const pluginWrapper = await browser.custom$$('myStrategy', '.pluginWrapper')

console.log(await pluginWrapper.length) // 4
})

歡迎!我能幫上什麼忙?

WebdriverIO AI Copilot