最开始元素定位正常,后来因为要操作原生组件,调用
然后调用restoreWxMethod消除,后面就出现了元素定位不准确的问题,重复执行以下代码const pageHead = await employee_page.$('.pageHead')
const bannerBox = await pageHead.$('.bannerBox')
const store_name = await bannerBox.$('.store-name')
await employee_page.waitFor(2000)
console.log(await store_name.attribute('class'))
const icons = await store_name.$$('.van-icon')
console.log(await store_name.text())
console.log(await icons.length)
console.log('Cccccccccccccccccc')
const icon1 = await icons[0]
console.log(await icon1.attribute('class'))
console.log('===========================================')
const texts = await store_name.$$('text')
console.log(await texts.length)
const text1 = await texts[0]
console.log(await text1.attribute('class'))
console.log(await text1.wxml())
会得到不同的结果,如图
好像是因为元素数据没加载出来,取到了骨架框的值,加入等待之后就可以正常定位了