How do I get current URL in Selenium Webdriver 2 Python?


Question

I'm trying to get the current url after a series of navigations in Selenium. I know there's a command called getLocation for ruby, but I can't find the syntax for Python.

1
128
4/13/2013 7:20:01 AM

Accepted Answer

Use current_url element. Example:

print browser.current_url
221
4/13/2013 8:53:39 AM

According to documentation (a place full of goodies:)):

driver.current_url

And new documentation contain it to: https://seleniumhq.github.io/docs/site/en/webdriver/browser_manipulation/#get-current-url


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon