Skip to content

Is there any way to wait until the current url changes? #1830

Answered by mdmintz
noobSrijon asked this question in Q&A
Discussion options

You must be logged in to vote

You could just use code like this:

current_url = self.get_current_url()
while (self.get_current_url() == current_url):
    self.sleep(0.5)

And it'll sleep until the URL changes.

But generally the only way the URL would change once you enter the loop would be if someone manually changed it, unless the website had some kind of timer where after a certain number of seconds, the URL changed on it's own. I haven't really encountered that, but theoretically possible. If you perform regular actions, such as clicks that change the URL, then the pageLoadStrategy set by Selenium already waits for the page load to happen before continuing with the script, which would make special methods for waiting…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@noobSrijon
Comment options

Answer selected by noobSrijon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants