Skip to content

Instantly share code, notes, and snippets.

@cvakiitho
Last active September 10, 2015 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cvakiitho/9fbd85994a834eb29774 to your computer and use it in GitHub Desktop.
Save cvakiitho/9fbd85994a834eb29774 to your computer and use it in GitHub Desktop.
useful snippets for protractor
//when you expect error on some command:
element.click().then(function(){
console.log('shouldn`t get here raise error:');
expect(1).toBe(0);
},function(err){
console.log('expected error, as element should not receive click');
});
//Expecting some URL change:
urlChanged = function(url) {
return function () {
return browser.getCurrentUrl().then(function(actualUrl) {
return url != actualUrl;
});
};
};
var urlNow = browser.getCurrentUrl();
browser.wait(com.urlChanged(urlNow), 5000);
//loop for promises:
var i = 0;
(function loop() {
if (i < 10) {
//some function call
element.click().then(function(){
// promise is evalled as success, lets call loop again
i++;
loop()
})
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment