0

This is my first contact with selenium and I'm trying to get URL of the current tab opened in firefox. My OS - Ubuntu 16.04. That's what I have :

from selenium import webdriver
import os

os.system('wmctrl -a firefox')
print webdriver.Firefox.current_url

That's what I've got:

<property object at 0x7fc5041a4a48>
Kat Roz
  • 59
  • 9
  • You need to create an instance of the driver. like this `browser = webdriver.Firefox()` then you can get the current url with `browser.current_url` – Cfreak Apr 29 '17 at 14:01
  • See the example in the docs on how to set up the browser correctly: https://selenium-python.readthedocs.io/getting-started.html – Cfreak Apr 29 '17 at 14:02
  • I also tried to create an instance of driver, but it creates me a new Firefox window and print a result for this new window – Kat Roz Apr 29 '17 at 14:06
  • 2
    Doesn't look like its possible with just an existing window. In general you want to create a web driver and then connect it to the site you want. According to some answers here though there's a hack if you already created a web driver that you can connect another to it: https://stackoverflow.com/questions/8344776/can-selenium-interact-with-an-existing-browser-session – Cfreak Apr 29 '17 at 14:10
  • @Cfreak Get it, that's what I was looking for – Kat Roz Apr 29 '17 at 14:15

0 Answers0