对于下面的量角器mocha测试用例,greeting.getText()将始终返回
低于结果而不是字符串。有人能给我一些线索吗?
describe('angularjs home', function () {
it('Should welcome a user', function (done) {
browser.get('http://www.angularjs.org');
element(by.model('yourName')).sendKeys('tanshuai');
var greeting = element(by.binding('yourName'));
console.log(greeting.getText());
expect(greeting.getText()).to.eventually.equal('Hello tanshuai!');
});
});
console.log输出================
ElementFinder {
browser_:
ProtractorBrowser {
controlFlow: [Function],
schedule: [Function],
setFileDetector: [Function],
getExecutor: [Function],
................................
getId: [Function],
takeScreenshot: [Function] }
答案 0 :(得分:0)
Protractor: element.getText() returns an object and not String
看起来getText()
会返回一个承诺,您需要解决它。看看上面的链接