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

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

driver.current_url

or, see official documentation: https://www.selenium.dev/documentation/en/webdriver/browser_manipulation/#get-current-url


Selenium2Library has get_location():

import Selenium2Library
s = Selenium2Library.Selenium2Library()
url = s.get_location()

Use current_url element for Python 2:

print browser.current_url

For Python 3 and later versions of selenium:

print(driver.current_url)

Another way to do it would be to inspect the url bar in chrome to find the id of the element, have your WebDriver click that element, and then send the keys you use to copy and paste using the keys common function from selenium, and then printing it out or storing it as a variable, etc.