Selenium: Python Firefox webdriver can fail on slow systems

Created on 21 Nov 2015  Â·  12Comments  Â·  Source: SeleniumHQ/selenium

When I try to load Firefox webdriver in python using:
webdriver.Firefox()

It occasionally fails after around 30 seconds with below traceback:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 77, in __init__
    self.binary, timeout),
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/extension_connection.py", line 49, in __init__
    self.binary.launch_browser(self.profile)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 68, in launch_browser
    self._wait_until_connectable()
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 103, in _wait_until_connectable
    raise WebDriverException("Can't load the profile. Profile "
selenium.common.exceptions.WebDriverException: Message: Can't load the profile. Profile Dir: %s If you specified a log_file in the FirefoxBinary constructor, check it for details.

I am almost sure it's to do with hardcoded 30 seconds timeout in firefox_binary.py:101. When I changed that value to 60 it started working.

I tried to load webdriver like this:
webdriver.Firefox(timeout=60)

but after looking at the code the timeout is not actually used so made no difference

How to replicate:

  • this issue can only be seen on slow systems (like RaspberryPi) where firefox takes over 30 seconds to start
  • the following python code can be used to replicate the problem:
from selenium import webdriver
browser = webdriver.Firefox()
C-py D-firefox

Most helpful comment

Issue does not seem to be caused by a slow machine. I'm running into the same problem with an i5-4570T.

All 12 comments

I started working on possible fix here:
https://github.com/jacekn/selenium/commits/issue1300

Note that the above branch is untested and not ready for merge, posting here for reference to help anybody else interested in troubleshooting

Seeing the same issue

I am getting this error everytime I start FF with this command: "browser = webdriver.Firefox()" , even if I change this hardcoded timeout value to a bigger number (in my test was 100s).
Test environment:

  • Raspberry Pi model B running Raspbian Wheezy
  • python 2.7 or python 3.2
  • Selenium 2.48
  • Iceweasel 38.4.0

Seeing the exact same issue..

Issue does not seem to be caused by a slow machine. I'm running into the same problem with an i5-4570T.

Sorry, if this has been asked elsewhere, but is there a way to temporarily work around this issue?

@willa75 The only way I know is to apply the patch yourself to where ever the code resides on your system.

The simplest workaround is to change this hardcoded value (count == 30) to something higher: https://github.com/SeleniumHQ/selenium/blob/9c2e49e4504e644fb79b9384c447da8114a254fb/py/selenium/webdriver/firefox/firefox_binary.py#L101 This is the solution I used until the patch was merged.

Thanks @agude but even after I hardcoded the value to 120 I still got the error, I will probably just have to wait for the issue to be resolved or use Chrome only for testing at the moment. Thanks for the help!

Please make sure to update this ticket when the issue is resolved. I'm having the same problem with the WebDriverException: Message: Can't load the profile. Thank you!!

Getting the same behaviour as @willa75. It's not a slow machine & changing the timeout to 120 doesn't change the error. Happy to test potential fixes.

I am getting the same error after a Firefox update 48.0.2 was working fine. Is there are fix for this that can be used while running the code without changing the waiting time?

I am using selenium 2.53.1 and Firefox 45.0。2, can hit above issue occasionally

Was this page helpful?
0 / 5 - 0 ratings