Last active
September 10, 2015 12:42
-
-
Save cvakiitho/9fbd85994a834eb29774 to your computer and use it in GitHub Desktop.
useful snippets for protractor
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
//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