How do I get current URL in Selenium Webdriver 2 Python?
https://www.tutorialspoint.com/how-do-i-get-current-url-in-selenium-webdriver-2-python
-
18-09-2020 - |
Question
How do I get current URL in Selenium Webdriver 2 Python?
We can get the current URL of a page with Selenium webdriver. The method current_url is available which obtains the present page URL and then we can print the result in the console.
Syntax
s = driver.current_url
Let us find the URL of the page presently navigated and we shall get https://www.tutorialspoint.com/index.htm as the output.
Example
from selenium import webdriver driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe") driver.implicitly_wait(0.5) driver.get("https://www.tutorialspoint.com/index.htm") #identify current URL with current_url l= driver.current_url print(Current URL is: " + l) driver.close()
Output
Advertisements
Not affiliated with Tutorialspoint