How can I save the current URL as a String? I want to navigate somewhere else and later navigate back to the saved URL. I dont want to use browser.navigate().back() for this.
When I for example do
var urlString;
browser.getCurrentUrl().then(function(url) {
urlString = url;
});
....redirecting...navigating...
browser.waitForAngular();
browser.get(urlString); // get back to beginning URL
it fails because the promise has not been fullfilled and urlString is undefined
Is there a possiblity to do this without breaking the test-flow?
Try this:
describe('my test', function() {
var urlString;
beforeEach(function() {
browser.getCurrentUrl().then(function(url) {
urlString = url;
});
});
it('should go and come back', function() {
// Here the value has already been resolved.
....redirecting...navigating...
browser.waitForAngular();
browser.get(urlString); // get back to beginning URL
});
})
... or you can put all of your test inside the then of the getCurrentUrl()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With