How do I get current URL in Selenium Webdriver 2 Python?
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Romantic Lands Beckon
--
Chapters
00:00 Question
00:24 Accepted answer (Score 431)
00:44 Answer 2 (Score 96)
01:02 Answer 3 (Score 7)
01:18 Answer 4 (Score 2)
01:41 Thank you
--
Full question
https://stackoverflow.com/questions/1598...
Answer 1 links:
[documentation]: http://selenium-python.readthedocs.io/ap...
https://www.selenium.dev/documentation/e...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #selenium #seleniumwebdriver
#avk47
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Romantic Lands Beckon
--
Chapters
00:00 Question
00:24 Accepted answer (Score 431)
00:44 Answer 2 (Score 96)
01:02 Answer 3 (Score 7)
01:18 Answer 4 (Score 2)
01:41 Thank you
--
Full question
https://stackoverflow.com/questions/1598...
Answer 1 links:
[documentation]: http://selenium-python.readthedocs.io/ap...
https://www.selenium.dev/documentation/e...
--
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.