Firefox Build does not work with Selenium Firefox Build does not work with Selenium python python

Firefox Build does not work with Selenium


Ubuntu 14.04, firefox 36.0, selenium 2.44.0.The same problem, was solved by:

sudo pip install -U selenium

Selenium 2.45.0 is OK with FF36.

update: Selenium 2.53+ is compatible with FF45

You can get older FF versions here


I have spent a long time debugging this and ultimately gave up trying to make incompatible versions of selenium/firefox work. I just don't have the expertise in firefox to go any further. My recommendation is downloading stable versions from https://ftp.mozilla.org/pub/mozilla.org/firefox/releases/ and keep trying combinations of firefox/selenium that work for your environment. For me, this is:

firefox==32.0.3selenium==2.43.0

I'm referring to the changelog here: http://selenium.googlecode.com/git/java/CHANGELOG to see which versions are supposedly compatible.

Basically, what is happening is webdriver is polling on its port until it can establish a socket connection.

def _wait_until_connectable(self):    """Blocks until the extension is connectable in the firefox."""    count = 0    while not utils.is_connectable(self.profile.port):        if self.process.poll() is not None:            # Browser has exited            raise WebDriverException("The browser appears to have exited "                  "before we could connect. If you specified a log_file in "                  "the FirefoxBinary constructor, check it for details.")        if count == 30:            self.kill()            raise WebDriverException("Can't load the profile. Profile "                  "Dir: %s If you specified a log_file in the "                  "FirefoxBinary constructor, check it for details.")        count += 1        time.sleep(1)    return True

And then if there is an socket error, keep going. So what you are probably seeing (at least what I am) is the browser hanging for 30 secs.

def is_connectable(port):    """    Tries to connect to the server at port to see if it is running.    :Args:     - port: The port to connect.    """    try:        socket_ = socket.socket(socket.AF_INET, socket.SOCK_STREAM)        socket_.settimeout(1)        socket_.connect(("127.0.0.1", port))        socket_.close()        return True    except socket.error:        return False

Bleh. Alright, well I finally just decided to store the specific version I want and switch to the compatible selenium version.

bin_dir = os.path.join(const.WEBDRIVER_DIR, 'firefox', 'binary', '32.0.3', 'linux-x86_64', 'firefox')binary = FirefoxBinary(firefox_path=bin_dir)driver = webdriver.Firefox(firefox_binary=binary)

I also highly recommend adding a log file to the firefox binary and checking that. Your issue might be unique and any bizarre errors will be logged there:

log_dir = os.path.join(const.LOGS_DIR, 'firefox')    try:    os.makedirs(directory)except OSError, e:    if e.errno == errno.EEXIST and os.path.isdir(directory):        passlog_path = os.path.join(log_dir, '{}.log'.format(datetime.datetime.now().isoformat('_'))log_file = open(log_path, 'w')binary = FirefoxBinary(firefox_path=bin_dir, log_file=log_file)


Spent an hour on this same issue. For Python3 remember to pip3, otherwise it will only upgrade selenium on Python2, and you'll be left wondering why it's still not working.

sudo pip3 install -U selenium