Selenium – Solving the “Can’t load the profile” Exception

I had a wierd “Can’t load the profile” exception in a selenium script that simply would go away.
Turns out the reason is a version problem between the selenium server and python library

Exception Error

a@a:/home/dev/code$ python selenium_test.py
Traceback (most recent call last):
  File "/home/dev/code/selenium_test.py", line 905, in 
    main()
  File "/home/dev/code/selenium_test.py", line 56, in main
    driver = webdriver.Firefox(firefox_profile=profile)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 59, in __init__
    self.binary, timeout),
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/extension_connection.py", line 47, in __init__
    self.binary.launch_browser(self.profile)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 44, in launch_browser
    self._wait_until_connectable()
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 86, in _wait_until_connectable
    self.profile.path, self._get_firefox_output()))
selenium.common.exceptions.WebDriverException: Message: 'Can\'t load the profile. Profile Dir: /tmp/tmpStkw4q Firefox output: Xlib:  extension "RANDR" missing on display ":1709".\n*** LOG addons.xpi: startup\n*** LOG addons.xpi: checkForChanges\n*** LOG addons.xpi: No changes found\n*** LOG addons.xpi: Loading bootstrap scope from /tmp/tmpStkw4q/extensions/firebug@software.joehewitt.com\n*** LOG addons.xpi: Calling bootstrap method startup on firebug@software.joehewitt.com version 1.10.6\n*** LOG addons.xpi: Loading bootstrap scope from /tmp/tmpStkw4q/extensions/{d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}\n*** LOG addons.xpi: Calling bootstrap method startup on {d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d} version 2.2.1\n*** LOG addons.xpi-utils: Opening database\n'

Fix: Just update the python selenium package


a@a:/home/dev/code$ sudo pip install -U selenium
[sudo] password for a:
Downloading/unpacking selenium from http://pypi.python.org/packages/source/s/selenium/selenium-2.31.0.tar.gz#md5=8ed4e8e1907dd06b0d9801b4d6b512ad
  Downloading selenium-2.31.0.tar.gz (2.5MB): 2.5MB downloaded
  Running setup.py egg_info for package selenium

Installing collected packages: selenium
  Found existing installation: selenium 2.28.0
    Uninstalling selenium:
      Successfully uninstalled selenium
  Running setup.py install for selenium

Successfully installed selenium
Cleaning up...

References

1. http://stackoverflow.com/questions/6682009/selenium-firefoxprofile-exception-cant-load-the-profile


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *