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
  • 116,827
  • 30
  • 260
  • 317
  • 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
  • 5,230
  • 4
  • 34
  • 59
Zeugma
  • 31,231
  • 9
  • 69
  • 81