量角器控制台日志 [英] Protractor console log

查看:137
本文介绍了量角器控制台日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要输出在我的测试量角器一个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 语句的承诺分辨率内的:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆