What is the best way to check URL change with Selenium in Python?
<p>So, what's I want to do is to run a function on a specific webpage (which is a match with my regex).</p>

<p>Right now I'm checking it every second and it works, but I'm sure that there is a better way (as it's flooding that website with getting requests).</p>

<pre><code>while flag:
    time.sleep(1)
    print(driver.current_url)
    if driver.current_url == "mydesiredURL_by_Regex":
        time.sleep(1)
        myfunction()
</code></pre>

<p>I was thinking to do that somehow with <code>WebDriverWait</code> but not really sure how.</p>