Home > Blockchain >  cannot get current_url correctly
cannot get current_url correctly

Time:09-29

I am trying to get current url using selenium. Here is my code:

#landing on page
driver.get("http://web.archive.org/web/20200922013649/https://www.shadesofstone.com/hardscape/flagstones-more/landscape-galore.html")

#get current url
main_link = driver.current_url
print(main_link)

but I am getting only this:

https://www.shadesofstone.com/hardscape/flagstones-more/landscape-galore.html

instead of this

http://web.archive.org/web/20200922013649/https://www.shadesofstone.com/hardscape/flagstones-more/landscape-galore.html

What is going wrong here?

CodePudding user response:

Looks like a bug with driver.current_url.

Here's a workaround you can use: driver.execute_script("return document.location.href;")

driver.get("http://web.archive.org/web/20200922013649/https://www.shadesofstone.com/hardscape/flagstones-more/landscape-galore.html")

main_link = driver.execute_script("return document.location.href;")
print(main_link)
  • Related