Here is the modified version of your code that should work:
browser.getCurrentUrl().then(function (currentUrl) {
browser.wait(function () {
return browser.getCurrentUrl().then(function (newUrl) {
return (newUrl !== currentUrl);
});
});
});
In my test code I also have a utility function similar to this one:
browser.waitForUrl = function (expectedUrl) {
browser.wait(function () {
return browser.getCurrentUrl().then(function (url) {
return url.indexOf(expectedUrl) !== -1;
});
});
};
and then I simply do:
browser.waitForUrl("/login");
Em quinta-feira, 13 de março de 2014 13h16min22s UTC-3, Matt Calthrop
escreveu:
>
> I've been trying this, and hit a wall.
>
> What I want to do is to wait until the URL changes.
>
> So the pseudo-code would look something like this:
>
> var currentUrl = browser.getCurrentUrl();
> browser.wait(function () {
> var newUrl = browser.getCurrentUrl();
> return (newUrl !== currentUrl);
> });
> // then continue doing stuff
>
> However, I'm not sure how to use *browser.getCurrentUrl()* (which returns
> a promise) within *browser.wait()*.
>
> Here's my first go, but as I expected, it didn't work (the browser timed
> out) :
>
> var currentUrl;
> browser.getCurrentUrl().then(function (url) {
> currentUrl = url;
> }).then(function () {
> return browser.wait(function () {
> return browser.getCurrentUrl().then(function (url) {
> return url !== currentUrl;
> });
> });
> });
>
> I've looked at the object returned by browser.getCurrentUrl(), and it
> doesn't have any methods that allow comparison with another value.
>
> Any suggestions? I'm still getting to grips with the new frontier of JS
> Promises...
>
> cheers
>
> Matt
>
> On Thursday, 13 March 2014 14:03:14 UTC, Matt Calthrop wrote:
>>
>> Thanks Demetrius... I had stumbled upon that function, and was going to
>> give it a go.
>>
>> cheers!
>>
>> Matt
>>
>>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.