【问题标题】:protractor -errors Message:Expected 0 to equal 5protractor -errors 消息:预期 0 等于 5
【发布时间】: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 &nbsp; 
                <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


【解决方案1】:

检查此更新的测试用例。问题是,你还没有拿走整个中继器。

it('should show the number of comments as', function() {
     expect(element.all(by.repeater('commet in dish.comments |orderBy:FiltText'))
        .count()).toEqual(5);
});

【讨论】:

  • 我做到了,但没有解决问题。出现同样的问题。
猜你喜欢
  • 2017-04-19
  • 2019-12-08
  • 1970-01-01
  • 2016-09-11
  • 2019-05-25
  • 2021-08-20
  • 1970-01-01
  • 1970-01-01
  • 2012-09-02
相关资源
最近更新 更多