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

0 votes

I'm trying to get the current URL after a series of navigations in Selenium. I know there's a command called getLocation for ruby, but I can't find the syntax for Python.

Aug 8, 2018 in Selenium by GandalfDwhite
• 1,320 points
19,999 views

1 answer to this question.

0 votes

Use current_url element. Example:

print browser.current_url
answered Aug 8, 2018 by Meci Matt
• 9,460 points
i am using the headless browser (Chrome) now how i get the URL

Hello @Raj,

You can  get the URL in the same way as you would get it if is not headless:

print (browser.current_url)
OR
print(driver.current_url)

Hope it help!

Thank You!!

Related Questions In Selenium

0 votes
2 answers
0 votes
1 answer
0 votes
1 answer

How do I find an element that contains specific text in Selenium WebDriver (Python)?

Try the following: driver.find_elements_by_xpath("//*[contains(tex ...READ MORE

answered 4 days ago in Selenium by Gitika
• 51,880 points
25 views
0 votes
1 answer

How do i change the location where my file gets downloaded in Selenium Webdriver and firefox driver?

There are a couple of errors there. ...READ MORE

answered Apr 12, 2018 in Selenium by nsv999
• 5,520 points
3,626 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,520 points
4,043 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31 in Selenium by Sri
• 2,970 points
4,989 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,890 points
2,925 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 2 in Selenium by Sri
• 2,970 points
3,365 views
+10 votes
15 answers

How to automate gmail login process using selenium webdriver in java?

Check the below code: Here is the working ...READ MORE

answered Apr 24, 2018 in Selenium by Vardy
• 2,360 points
125,332 views
0 votes
1 answer