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..
After a long search on google I got answer.We can make use of promises with browser.wait
in 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.