browser.getValue('#username').then(function (elementValue) {
    console.log('elementValue : '+elementValue);
});


在将来自webdriverio的浏览器对象与摩卡赛跑者一起使用以获取元素值时,传递元素ID然后获取该值。

最佳答案

它应该和webdriverio api文档中一样简单。可以找到here

browser.getValue(selector);


以上应符合您的要求。而且它不返回任何承诺,因此无需将其与then链接。它在您的元素中返回属性value的值。

如果您正在寻找其他任何东西的价值,请根据您的实际需求发表评论。由于尚不清楚您要查找value as an attribute还是value of anything else that element contains

09-20 13:09