1

I am new to angular and protractor.We use protractor for functional testing and integrated with jenkins.

Problem

In some screens we use ng-toast to show toaster messages(mainly for server response messages like 'save filed' etc.).But protractor could not catch these, since it will wait for all angular timeouts(including toaster timeout) to complete.Showing error:

Timed out waiting for Protractor to synchronize with the page after 11 seconds.

I tried to set ignoreSynchronization too.

How to tackle this. I am really stuck on this..

Tom Sebastian
  • 3,373
  • 5
  • 29
  • 54

1 Answers1

2

After a long search on google I got answer.We can make use of promises with browser.waitin test cases those needs to wait for toaster messages.

        .....  
        browser.wait(function() {
                var deferred = protractor.promise.defer();

                  getToaster().then(function(){
                      deferred.fulfill(true);
                      expect(getToaster().isDisplayed()).toBe(true);//and other assertions
                  });
                  return deferred.promise;
                });
       .....

This is well described in this blog Also more details about protractor.promise can be found here

Alternatively I did it in another way as:

 ...
    browser.manage().timeouts().implicitlyWait(10000);//set timeout for element 
     expect(toaster.getToaster().isDisplayed()).toBe(true);
     browser.manage().timeouts().implicitlyWait(1);//reset
   ....

But in a protractor way of doing is browser.wait with ExpectedCondition which is described in the protractor api including custom conditions.I am currently using this explicit wait approach.

Community
  • 1
  • 1
Tom Sebastian
  • 3,373
  • 5
  • 29
  • 54