title: How to wait for a specific URL to load before calling a function using Selenium and Python
body: <p>This is my first time posting on stackoverflow, and I'm somewhat new to Selenium and Python.</p>
  
  <p>I wan't a function to be runned when the URL is equal to fx: <a href="https://www.example.com" rel="nofollow noreferrer">https://www.example.com</a>. </p>
  
  <p>I have read  <a href="https://stackoverflow.com/a/36316518/12710400">this</a> answer in another discussion, but i didn't quite understand what was going on.</p>
  
  <p>I hope you take the time to answer my question.</p>
  
  <p>Ok, so i have just tried this:</p>
  
  <pre class="lang-py prettyprint-override"><code>driver.get('https://www.google.com')
  time.sleep(4)
  driver.get('https://www.stackoverflow.com')
  
  if WebDriverWait(driver, 10).until(EC.url_to_be('https://stackoverflow.com')):
      print('Desired url was rendered within allocated time')
  else:
      print('Desired url was not rendered within allocated time')
  </code></pre>
  
  <p>But it did not work. Any ideas?<br>
  The console says</p>
  
  <pre><code>Traceback (most recent call last):
    File "/Users/holger/PycharmProjects/waitTest/wait.py", line 15, in &lt;module&gt;
      if WebDriverWait(browser, 10).until(EC.url_to_be('https://www.stackoverflow.com')):
    File "/Users/holger/PycharmProjects/waitTest/venv/lib/python3.8/site-packages/selenium/webdriver/support/wait.py", line 80, in until
      raise TimeoutException(message, screen, stacktrace)
  selenium.common.exceptions.TimeoutException: Message: 
  </code></pre>