How to use browser.wait() to wait for URL to change?
See original GitHub issueHi
I want to write a Protractor test that waits until the current URL to change, so I have been looking at browser.wait()
, combined with browser.getCurrentUrl()
.
However, I am not sure of how to use the two together: the browser.wait()
method accepts as its first parameter a function that will return a boolean value – however, browser.getCurrentUrl()
returns a promise.
My first attempt, which failed (as I expected), looks like this:
var currentUrl;
browser.getCurrentUrl().then(function (url) {
currentUrl = url;
}).then(function () {
return browser.wait(function () {
return browser.getCurrentUrl().then(function (url) {
return url !== currentUrl;
});
});
}).then(function () {
// continue testing
});
Can anyone help?
many thanks
Matt
Issue Analytics
- State:
- Created 10 years ago
- Comments:26 (15 by maintainers)
Top Results From Across the Web
Protractor- Generic wait for URL to change - Stack Overflow
var expectedCondition = protractor.ExpectedConditions; // Waits for the URL to contain 'login page'. browser.wait(expectedCondition.urlContains( ...
Read more >thewaiter: waiting for a URL in the browser to equal or contain ...
The classic approach for such a task would be something like: open the page or interact with the UI in a way that...
Read more >How to get Selenium to wait for a page to load - BrowserStack
Using Implicit Wait. The Implicit Wait tells WebDriver to wait a specific amount of time (say, 30 seconds) before proceeding with the next...
Read more >5. Waits — Selenium Python Bindings 2 documentation
An explicit wait is a code you define to wait for a certain condition to occur before proceeding further in the code. The...
Read more >waitUntil - WebdriverIO
This wait command is your universal weapon if you want to wait on something. ... Usage. browser.waitUntil(condition, { timeout, timeoutMsg, interval }) ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok, I know this is way way late but I believe you can do something like this:
In case it may help others in future, here is the method I have written to wait for the URL to change to a particular value (as specified by a regex) :