0

I am trying to get the URL of a website as soon as the URL on tab changes. But currently the script waits for the page to load and then gives me the URL. I want to get the URL in real time even before the page gets loaded.

iniurl = driver.current_url
SOME AUTOMATION STEPS
while url_change:
   if driver.current_url != ini_url:
       url_change = False
       print(driver.current_url)
       driver.quit()

Currently this is very slow, not realtime.

catzilla
  • 1,901
  • 18
  • 31
  • what do you do on driver to change url: 1) get(other url) 2) click some element? pd: check this https://stackoverflow.com/questions/46322165/dont-wait-for-a-page-to-load-using-selenium-in-python maybe already solved – Wonka Jun 02 '23 at 10:51

1 Answers1

0

I found an answer to this finally after some testing. This is in real time and does not wait for page to load so its faster than using the page load strategy = 'eager'

iniurl = driver.current_url
SOME AUTOMATION STEPS
while url_change:
   if driver.execute_script("return window.location.href") != ini_url:
       url_change = False
       print(driver.current_url)
       driver.quit()