跳到主要内容

custom$$

customs$$ 允许你使用通过 browser.addLocatorStrategy 声明的自定义策略。 在选择器文档中可以了解更多关于自定义选择器策略的信息。

用法
browser.custom$$(strategyName, strategyArguments)
参数
名称类型详情
strategyNamestring
strategyArguments*
示例
example.js
it('should get all the plugin wrapper buttons', async () => {
await browser.url('https://webdriver.io')
await browser.addLocatorStrategy('myStrategy', (selector) => {
return document.querySelectorAll(selector)
})

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

console.log(await pluginWrapper.length) // 4
})
返回值
  • <WebdriverIO.ElementArray>

Welcome! How can I help?

WebdriverIO AI Copilot