量角器控制台日志 [英] Protractor console log
本文介绍了量角器控制台日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的量角器测试中输出一个 div 的文本,到目前为止我有:
I want to output the text of a div in my protractor test, so far I have:
console.log(ptor.findElement(protractor.By.id('view-container')).getText());
但是这个输出
[object Object]
我尝试了toString()",结果相同.
I tried "toString()" and same result.
有没有办法将文本输出到控制台?
Is there a way to output the text to the console?
推荐答案
getText
和大多数其他量角器方法返回承诺.您想将 console.log
语句放在 promise 解析中:
getText
and most other Protractor methods return promises. You want to put your console.log
statement inside the promise resolution:
使用新的量角器语法:
element(by.id('view-container')).getText().then(function(text) {
console.log(text);
});
这篇关于量角器控制台日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文