3 回答
![?](http://img1.sycdn.imooc.com/545863e80001889e02200220-100-100.jpg)
TA贡献1874条经验 获得超12个赞
量角器each应该可以解决问题。
let uistringvaluearray = await name_planogram_table.each(async arrayElement => {
return arrayElement.getText()
//This is just a quick example
//return the value, assign to another variable or do whatever you need to do
})
![?](http://img1.sycdn.imooc.com/5333a2320001acdd02000200-100-100.jpg)
TA贡献1848条经验 获得超2个赞
await关键字解决了一个承诺。element.all(by.xpath(planograms_Table_cart_Category))是不是一个承诺,hense不需要await它
如上所述,这将起作用
let name_planogram_table = await element.all(by.xpath(planograms_Table_cart_Category)).getText();
console.log(name_planogram_table);
// output
// [
// "value1",
// "value2",
// "value3"
// ]
但!!!一年前有一个错误(也许它仍然存在),当你调用.getText()或.getAttribute()反对很多元素(30、50、100+)时,你会得到stale element错误。在这种情况下唯一的解决方案是for循环
![?](http://img1.sycdn.imooc.com/545847d40001cbef02200220-100-100.jpg)
TA贡献1963条经验 获得超6个赞
您应该能够通过像这样在您的 elementFinderArray 上调用 getText() 来获取这些值
let name_planogram_table = await element.all(by.xpath(planograms_Table_cart_Category)).getText();
console.log(name_planogram_table);
它将产生一个字符串数组。
添加回答
举报