Was it helpful?

Question

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

SeleniumAutomation TestingTesting Tools

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

 

 


raja
Published on 18-Sep-2020 14:30:22
Advertisements
Was it helpful?
Not affiliated with Tutorialspoint
scroll top