【发布时间】:2017-04-06 05:00:37
【问题描述】:
量角器显示错误信息 没有列表项。
conFusion App E2E 测试菜单 0 项应显示 cmets 的数量 信息: 预期 0 等于 5。 堆: 错误:预期失败 在对象。 (/Users/fullStock/anglerJs/conFusion/test/e2e/scenarios.js:37:23)
我进行了e2e测试以确保页面上将出现的评论列表数量为5。我使用json服务器来提供数据。我认为问题是元素还没有出现在 DOM 中。有没有办法告诉量角器等到元素最终出现在 DOM 中?
代码 e2e 测试
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);
});
用于评论的代码 html
<h4> Customer Comments
<span style="font-size:15px;">sorted by:<input type="text" ng-model="FiltText"></span></h4>
<blockquote ng-repeat="commet in dish.comments |orderBy:FiltText">
<h5>{{commet.rating}} Stars</h5>
<h5>{{commet.comment}}</h5>
<footer>{{commet.author}}, <span>{{commet.date|date}}.</span></footer>
</blockquote>
量角器配置
exports.config = {
allScriptsTimeout: 11000,
specs: [
'e2e/*.js'
],
capabilities: {
browserName: 'chrome'
},
baseUrl: 'http://localhost:3001/',
framework: 'jasmine',
directConnect: true,
jasmineNodeOpts: {
defaultTimeoutInterval:30000
}
};
【问题讨论】:
-
您有机会手动检查吗?还有一件事是您的定位器似乎得到了改进。让我用那个特定的定位器来回答这个问题。请检查并告诉我
-
是的。我手动检查。实际上我输入了终端 gulp watch 来提供这个 web application.comment list is there.every things right,但是当我做量角器做测试时,测试失败了。
标签: angularjs jasmine protractor