Protractor times out waiting for sync with page when using $resource

前端 未结 4 1436
庸人自扰
庸人自扰 2020-12-09 11:04

I\'m testing Protractor with a small AngularJS app.

This is the test:

describe(\'Testing Protractor\', function() {
  var draftList;

  it(\'should c         


        
相关标签:
4条回答
  • 2020-12-09 11:23

    Instead of using browser.ignoreSynchronization, use browser.waitForAngularEnabled(*boolean*). browser.waitForAngularEnabled(false) sets browser.ignoreSynchronization to true, browser.waitForAngularEnabled(true) sets browser.ignoreSynchronization to false.

    you can also include this as part of your test suites' config file:

    onPrepare: function () {
        'use strict';
        browser.waitForAngularEnabled(false);
    }
    
    0 讨论(0)
  • 2020-12-09 11:28

    This is a known issue, but there is a temporary workaround. Set ptor.ignoreSynchronization = true.

    For example:

    describe('Testing Protractor', function() {
      var draftList;
      var ptor;
    
      beforeEach(function() {
        ptor = protractor.getInstance();
        ptor.ignoreSynchronization = true;
      });
    
      it('should count the number of drafts', function() {
        ptor.get('#/');
        draftList = element.all(by.repeater('newsletter in drafts'));
        expect(draftList.count()).toEqual(2);
      });
    });
    
    0 讨论(0)
  • 2020-12-09 11:32

    browser.ignoreSynchronization = true; worked out for me.

    0 讨论(0)
  • 2020-12-09 11:41

    I'm using Protractor 3.3.0 and to get this to work in my test I had to defer the ignore synchronisation until after I had done the setup.

    So in my beforeEach I call my action:

    var searchBox = element(by.css('#inpt_search'));
    searchBox.sendKeys('test');
    

    I then have to wait for the mock backend to populate the view (I'm not happy about these sleep calls so if anyone has a better way of doing this please comment, I can't get expectedConditions.presenceOf to work as it's part of the same bug) using browser.sleep(500). Then in the test I set browser.ignoreSynchronization = true which unblocks whatever is blocked and sees the browser content.

    describe('standard search', function (){
        beforeEach(function (){
            openApp();
            var searchBox = element(by.css('#inpt_search'));
            searchBox.sendKeys('test');
            browser.sleep(500);
        });
        it('should work or summat', function () {
            browser.ignoreSynchronization = true;
            var fileItems = element.all(by.repeater('item in list'));
            expect(fileItems.count()).toEqual(50);
        });
    });
    
    0 讨论(0)
提交回复
热议问题