Protractor: element.getText() returns an object but not String [duplicate]

断了今生、忘了曾经 提交于 2019-12-25 09:13:52

问题


I have also checked link: Protractor: element.getText() returns an object and not String but i found no answer for that on above link and i want string in return??


回答1:


All the protractor's methods return promises, to resolve that promise you need to send something like this:

element.getText().then(function(text) {
console.log(text);
});
or use "expect"-->jasmine's assertion
expect(element.getText()).toEqual("Your Text");

for detailed idea on promises i suggest please go through this link : http://www.html5rocks.com/en/tutorials/es6/promises/



来源:https://stackoverflow.com/questions/37627969/protractor-element-gettext-returns-an-object-but-not-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!