【发布时间】:2017-09-04 13:45:34
【问题描述】:
我使用量角器进行端到端测试。当我开始测试时,我会看到这条消息
conFusion App E2E 测试菜单 0 项应显示第一评论作者为 信息: 失败:使用定位器找不到元素:by.model("FiltText")
如何让量角器等到元素出现在 DOM 中?
对应的量角器配置代码为:
exports.config = {
allScriptsTimeout:11000,
specs: [
'e2e/*.js'
],
capabilities: {
'browserName': 'chrome'
},
baseUrl: 'http://localhost:3001/',
framework: 'jasmine',
directConnect: true,
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000
}
};
包含e2e测试的scenarios.js代码
describe('menu 0 item', function() {
beforeEach(function() {
browser.get('index.html#/menu/0');
});
it('should have a name', function() {
var name = element(by.binding('dish.name'));
expect(name.getText()).
toEqual('Uthapizza Hot $4.99');
});
it('should show the number of comments as', function() {
expect(element.all(by.repeater('comment in dish.comments'))
.count()).toEqual(5);
});
it('should show the first comment author as', function() {
element(by.model('FiltText')).sendKeys('author');
expect(element.all(by.repeater('comment in dish.comments'))
.count()).toEqual(5);
var author = element.all(by.repeater('comment in dish.comments'))
.first().element(by.binding('comment.author'));
expect(author.getText()).toContain('25 Cent');
});
});
【问题讨论】:
-
错误中的测试名称不在您提供的规范中的任何位置。代码在哪里?
-
我添加了测试代码。请检查一下。
标签: angularjs testing protractor