How do I get current URL in Selenium Webdriver 2 Python?
--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Magic Ocean Looping
--
Chapters
00:00 How Do I Get Current Url In Selenium Webdriver 2 Python?
00:20 Accepted Answer Score 447
00:34 Answer 2 Score 7
00:46 Answer 3 Score 99
00:59 Answer 4 Score 2
01:19 Thank you
--
Full question
https://stackoverflow.com/questions/1598...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #selenium #seleniumwebdriver
#avk47
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Magic Ocean Looping
--
Chapters
00:00 How Do I Get Current Url In Selenium Webdriver 2 Python?
00:20 Accepted Answer Score 447
00:34 Answer 2 Score 7
00:46 Answer 3 Score 99
00:59 Answer 4 Score 2
01:19 Thank you
--
Full question
https://stackoverflow.com/questions/1598...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #selenium #seleniumwebdriver
#avk47
ACCEPTED ANSWER
Score 447
Use current_url element for Python 2:
print browser.current_url
For Python 3 and later versions of selenium:
print(driver.current_url)
ANSWER 2
Score 99
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
ANSWER 3
Score 7
Selenium2Library has get_location():
import Selenium2Library
s = Selenium2Library.Selenium2Library()
url = s.get_location()
ANSWER 4
Score 2
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.