我有一个元素定义为
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() 返回一个promise,你需要解决它:
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 and the Control Flow documentation page should clear things up.
这篇关于量角器:element.getText() 返回一个对象而不是字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
即使在调用 abort (jQuery) 之后,浏览器也会等待Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在调用 abort (jQuery) 之后,浏览器也会等待 ajax 调用
JavaScript innerHTML 不适用于 IE?JavaScript innerHTML is not working for IE?(JavaScript innerHTML 不适用于 IE?)
XMLHttpRequest 无法加载,请求的资源上不存在“AXMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 无法加载,请求的资
XHR HEAD 请求是否有可能不遵循重定向 (301 302)Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 请求是否有可能不遵循重定向 (301 302))
XMLHttpRequest 206 部分内容XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分内容)
XMLHttpRequest 的 getResponseHeader() 的限制?Restrictions of XMLHttpRequest#39;s getResponseHeader()?(XMLHttpRequest 的 getResponseHeader() 的限制?)