跳到主要内容

custom$$自定义多元素选择器

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

用法
$(selector).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('myStrat', (selector) => {
return document.querySelectorAll(selector)
})

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

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

Welcome! How can I help?

WebdriverIO AI Copilot