element.attribute

解释:获取元素属性。

  1. element.attribute(name: string): Promise<string>

参数说明

属性名类型必填默认值说明
nameString-属性名

示例代码

  1. automator.launch().then(async smartProgram => {
  2. const page = await smartProgram.reLaunch('/pages/api/api');
  3. const element = await page.$('.group-logo');
  4. // id
  5. const res = await element.attribute('id');
  6. });