Previously, I have found a clever way to wait for a URL change by using the following code snippet:
browser.wait( function() {
return browser.getCurrentUrl().then(function(url) {
return /myURL/.test(url);
});
}, 10000, "url has not changed");`
However, I'm attempting to create a method that allows me to pass 'myURL' as a variable so I can use it with different sites, but it's not working.
In my Page Object file, I've tried the following approach:
this.waitUrl = function(myUrl) {
browser.wait( function(myUrl) {
return browser.getCurrentUrl().then(function(url, myUrl) {
return myUrl.test(url);
});
}, 10000, "url has not changed");
};
Does anyone know if this is even possible and how to do it correctly if so?