Is there any way to wait until the current url changes? #1830
-
There was something like WebDriverWait(driver, 10).until(EC.url_changes(old_url)) in Selenium which waits until the url changes, is in Seleniumbase have something like that? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
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 |
Beta Was this translation helpful? Give feedback.
You could just use code like this:
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…