8

I am using python2.7 with beautiful Soup4 and Selenium webdriver. Now in my webautomation script i will open the link or URL and get into the home page. Now I need to click onto some anchor Labels to navigate through other pages.I did till now. now when i will be going to a new page, I need to get the new URL from the browser as I need to pass it Beautiful Soup4 for webpage scraping. So now my concern is how to get such URLs dynamic way?

Please advice if any!

Arup Rakshit
  • 113,563
  • 27
  • 250
  • 306
  • possible duplicate of [How do I get current URL in Selenium Webdriver 2 Python?](http://stackoverflow.com/questions/15985339/how-do-i-get-current-url-in-selenium-webdriver-2-python) – kenorb May 13 '15 at 11:06

1 Answers1

17

You get current_url attribute on the driver:

from selenium import webdriver
browser = webdriver.Firefox()
browser.get('http://www.google.com')
print(browser.current_url)
Smart Manoj
  • 4,375
  • 4
  • 27
  • 51
Zeugma
  • 29,409
  • 8
  • 62
  • 77