javascript - how can I get the current url using protractor? -


i testing website using protractor, , jasmine. know current url in order verify test.

i have tried

function waitforurltochangeto(urlregex) {     var currenturl;      return browser.getcurrenturl().then(function storecurrenturl(url) {             currenturl = url;         }     ).then(function waitforurltochangeto() {             return browser.wait(function waitforurltochangeto() {                 return browser.getcurrenturl().then(function comparecurrenturl(url) {                     return urlregex.test(url);                 });             });         }     ); } 

and using function in way

it('should log', function() {     //element(by.model('user.username')).sendkeys('asd');     //element(by.model('user.password')).sendkeys('asd');     element(by.linktext('acceder')).click();     waitforurltochangeto("http://localhost:9000/#/solicitudes"); }); 

here working code based on example provided author of expected conditions:

var urlchanged = function(url) {   return function () {     return browser.getcurrenturl().then(function(actualurl) {       return url != actualurl;     });   }; }; 

usage:

element(by.linktext('acceder')).click(); browser.wait(urlchanged("http://localhost:9000/#/solicitudes"), 5000);  

Comments

Popular posts from this blog

How to run C# code using mono without Xamarin in Android? -

c# - SharpSsh Command Execution -

python - Specify path of savefig with pylab or matplotlib -