阅读(1183) (21)

百度智能小程序 获取页面元素数组

2020-09-04 14:48:09 更新

page.$$

解释:获取页面元素数组。

page.$$(selector: string): Promise<Element[]>

参数说明:

属性名类型必填默认值说明
selectorString-选择器

示例代码:

automator.launch().then(async smartProgram => {
    const page = await smartProgram.reLaunch('/pages/api/api');
    const elements = await page.$$('.item-desc');
    console.log(elements.length);
})