After sending a click that causes the creation of a new resource, I'm using this to wait for the browser to get redirected to the newly created resource:
browser.driver.wait(function() {
return browser.driver.getCurrentUrl().then(function(url) {
return url == 'https://dev.mysite.com/resource/'+/^[0-9a-fA-F]{24}$/
});
});
The problem is that I can't get the url==/myUrl to resolve to true
Here's a sample url I'm trying to return true on, the portion after the resource/ changes with each test:
https://dev.mysite.com/resource/54d4ee554bf01d2a7e4e8058
Thanks!
You need to use match()
:
browser.driver.wait(function() {
return browser.driver.getCurrentUrl().then(function(url) {
var re = /resource\/[0-9a-fA-F]{24}$/;
return url.match(re);
});
});
Note that slash inside the url has to be escaped with a backslash.