量角器:element.getText()返回一个对象而不是String [英] Protractor: element.getText() returns an object and not String
本文介绍了量角器:element.getText()返回一个对象而不是String的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个元素定义为
this.clientRowName = element(by.id('CLIENT_NAME')); //page object file
我想读取这个元素中的文字ABC但正在做:
var client = page.clientRowName.getText();
I want to read the text in this element which is "ABC" but doing: var client = page.clientRowName.getText();
返回一个对象而不是一个字符串。有没有其他方法可以获得元素的文本
returns an object instead of a string. Is there any other way that I can get the text for the element
推荐答案
getText()
返回承诺,你需要解决它:
page.clientRowName.getText().then(function (text) {
console.log(text);
});
或者,如果您只想断言文本,请让 expect()
解决你的承诺:
Or, if you just want to assert the text, let expect()
resolve the promise for you:
expect(page.clientRowName.getText()).toEqual("ABC");
Promises和Control Flow 文档页面应该清理。
这篇关于量角器:element.getText()返回一个对象而不是String的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文