Skip to content

Instantly share code, notes, and snippets.

@jsok
Created March 11, 2015 01:08
Show Gist options
  • Save jsok/412cdbb01c8496c07d05 to your computer and use it in GitHub Desktop.
Save jsok/412cdbb01c8496c07d05 to your computer and use it in GitHub Desktop.
Protractor and deferred-angular-bootstrap load support
browser.get('/').then(function() {
return browser.waitForDeferredAngular();
});
// angular-deferred-bootstrap sets a class named
// "deferred-bootstrap-loading" to the body while data is loading
// See: https://github.com/philippd/angular-deferred-bootstrap#loading-and-error-indicators
browser.waitForDeferredAngular = function waitForDeferredAngular() {
return browser.driver.wait(function() {
return element(by.css('.deferred-bootstrap-loading')).then(function() {
return browser.driver.wait(function() {
return element(by.css('.deferred-bootstrap-error')).then(function(el) {
// errors during bootstrap, fail
return false;
}, function(err) {
// no errors, loading done and no errors found
return true;
});
});
}, function() {
// It has probably already bootstrapped, we just got to the party late
return true;
});
});
};
// Tell protractor we are doing it ourself
browser.ignoreSynchronization = true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment