Created
March 11, 2015 01:08
-
-
Save jsok/412cdbb01c8496c07d05 to your computer and use it in GitHub Desktop.
Protractor and deferred-angular-bootstrap load support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
browser.get('/').then(function() { | |
return browser.waitForDeferredAngular(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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