27

I am trying to run the following Python code to create a Firefox Webdriver window via Selenium:

from selenium import webdriver
driver = webdriver.Firefox()
driver.get("http://www.google.com")

While this code worked fine a few weeks ago, it now produces the following foreboding message:

 Traceback (most recent call last):
  File "test.py", line 2, in <module>
    driver = webdriver.Firefox()
  File "c:\python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 60, in __init__
    self.binary, timeout),
  File "c:\python27\lib\site-packages\selenium\webdriver\firefox\extension_connection.py", line 47, in __init__
    self.binary.launch_browser(self.profile)
  File "c:\python27\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 61, in launch_browser
    self._wait_until_connectable()
  File "c:\python27\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 105, in _wait_until_connectable
    self.profile.path, self._get_firefox_output()))
selenium.common.exceptions.WebDriverException: Message: 'Can\'t load the profile. Profile Dir: c:\\users\\douglas\\appdata\\local\\temp\\tmpuf4ipq Firefox output: *** LOG addons.xpi: startup\r\n*** WARN addons.xpi: Ignoring missing add-on in C:\\Program Files\\CheckPoint\\ZAForceField\\WOW64\\TrustChecker\r\n*** WARN addons.xpi: Ignoring missing add-on in C:\\ProgramData\\Norton\\{78CA3BF0-9C3B-40e1-B46D-38C877EF059A}\\NSM_2.9.5.20\\coFFFw\r\n*** LOG addons.xpi: Skipping unavailable install location app-system-local\r\n*** LOG addons.xpi: Skipping unavailable install location app-system-share\r\n*** LOG addons.xpi: checkForChanges\r\n*** LOG addons.xpi: No changes found\r\n*** Blocklist::_loadBlocklistFromFile: blocklist is disabled\r\n************************************************************\r\n* Call to xpconnect wrapped JSObject produced this error:  *\r\n[Exception... "\'[JavaScript Error: "this._defaultEngine is null" {file: "resource://gre/components/nsSearchService.js" line: 3527}]\' when calling method: [nsIBrowserSearchService::currentEngine]"  nsresult: "0x80570021 (NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS)"  location: "JS frame :: chrome://browser/content/search/search.xml :: get_currentEngine :: line 130"  data: yes]\r\n************************************************************\r\n************************************************************\r\n* Call to xpconnect wrapped JSObject produced this error:  *\r\n[Exception... "\'[JavaScript Error: "this._defaultEngine is null" {file: "resource://gre/components/nsSearchService.js" line: 3527}]\' when calling method: [nsIBrowserSearchService::currentEngine]"  nsresult: "0x80570021 (NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS)"  location: "JS frame :: chrome://browser/content/search/search.xml :: get_currentEngine :: line 130"  data: yes]\r\n************************************************************\r\n************************************************************\r\n* Call to xpconnect wrapped JSObject produced this error:  *\r\n[Exception... "\'[JavaScript Error: "this._defaultEngine is null" {file: "resource://gre/components/nsSearchService.js" line: 3527}]\' when calling method: [nsIBrowserSearchService::currentEngine]"  nsresult: "0x80570021 (NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS)"  location: "JS frame :: resource://app/components/nsBrowserGlue.js :: <TOP_LEVEL> :: line 354"  data: yes]\r\n************************************************************\r\n************************************************************\r\n* Call to xpconnect wrapped JSObject produced this error:  *\r\n[Exception... "\'[JavaScript Error: "this._defaultEngine is null" {file: "resource://gre/components/nsSearchService.js" line: 3527}]\' when calling method: [nsIBrowserSearchService::currentEngine]"  nsresult: "0x80570021 (NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS)"  location: "JS frame :: resource://app/components/nsBrowserGlue.js :: <TOP_LEVEL> :: line 354"  data: yes]\r\n************************************************************\r\n'

Does anyone know what this means, or what I can do to remedy the error and get the code to run as expected? I've found related error messages through Google searches, but nothing that has allowed me to resolve the issue.

For what it's worth, I can open a Chrome Webdriver without issue by changing the second line of the above to driver = webdriver.Chrome().

I'm using Python 2.7, Selenium 2.35.0 (I just ran "pip install selenium --upgrade) and Firefox 26.0 on a Windows 8 machine. Any tips or advice others can offer are most appreciated.

duhaime
  • 25,611
  • 17
  • 169
  • 224
  • A slightly tangential but very useful other [question on how to prevent Selenium from making temporary Firefox profiles](http://stackoverflow.com/questions/6787095/how-to-stop-selenium-from-creating-temporary-firefox-profiles-using-web-driver) ended up helping me a lot with this, for the next person who arrives here... for what it's worth. – slushy Jun 30 '15 at 12:10

5 Answers5

29

Selenium 2.35 is not compatible with Firefox 26. As the release notes say, FF 26 support was added in Selenium 2.39. You need to update to 2.39. Try pip install -U selenium instead.

Silas Ray
  • 25,682
  • 5
  • 48
  • 63
  • 4
    I ran `pip install -U selenium` and it appears selenium upgraded, but I'm still receiving the same error message. Any other suggestions are most welcomed – duhaime Jan 06 '14 at 20:00
  • The trace you posted is not from the code sample you posted. Do you have more than one Python installation on your machine? Are you sure you are still getting the _same_ error, and not a _similar_ one? – Silas Ray Jan 06 '14 at 20:21
  • Many thanks, @Silas Ray; I've just updated the error message that the code I posted above generates. I believe I only have 2.7 on this machine. Thanks again for your help. – duhaime Jan 06 '14 at 20:40
  • It looks like it can't load the user profile for some reason. It's squawking about a bunch of missing/incompatible Firefox plugins as well, but those are all WARNs. You aren't trying to use a custom profile, are you? – Silas Ray Jan 06 '14 at 20:57
  • Not to my knowledge! I did download a webdriver.xpi file some time ago (I needed this to compile some code that used Selenium to evoke a Firefox Webdriver session); could that be related? – duhaime Jan 06 '14 at 21:00
  • 2
    webdriver.xpi lives in the Selenium package distribution in site-packages. It gets copied to a tmp directory each time a Firefox instance is created and then loaded in to the browser when it is started. Updating selenium with pip should have updated the xpi file (which is actually the Firefox plugin that drives Selenium's actions in the browser) that gets launched when you instantiate with `webdriver.Firefox()`. Firefox profiles are different, though related, as they define which plugins to load, and Selenium adds the Selenium plugin to the list of the dynamically copied profile it uses. – Silas Ray Jan 06 '14 at 21:06
  • Upgrading Selenium solved the Firefox "Can't load the profile..." error for me. I'm on Windows 7, Python 3 and Firefox 28.0. I experienced the error. After running pip install -U selenium, the error went away. – Steve Saporta Apr 24 '14 at 14:19
  • I had a similar problem just now. Everything was running perfectly using win7 x64 with selenium 2.4. FF updated inadvertently to FF32 and nothing then worked. I updated selenium to the latest using easy_install -U selenium and it appeared to do the job perfectly. One thing I did encountere worth noting was that I needed to change wait times inside my python code to slow things down. It appears the new FF webdriver is now a little faster. – croc Sep 22 '14 at 03:28
0

Not sure if it works fine on Windows too, but for me the combination of Firefox 26 and selenium 2.37.0 works fine.

Artur Barseghyan
  • 12,746
  • 4
  • 52
  • 44
0

I also have this issue in Win8.1 FF28 and python3.4/selenium 2.41. But after I degraded FF to 24, it worked! And I also tested in Win8.1/FF27/Python3.4/Selenium 2.41, it worked too.

0

I just ran into the same thing with FF36 and selenium 2.44.0. Re-installing FF 32.0 fixed it.

JohnL
  • 13,682
  • 4
  • 19
  • 23
0

I've experienced the same problem on my Kubuntu 14.04 desktop, I removed the Firefox 47.XX and re-installed Firefox 45.XX and the problem resolved.

Download firefox debian package

  • apt-get purge firefox
  • dpkg -i firefox-XXXXXXXXXX.deb
Vincent P
  • 761
  • 1
  • 5
  • 6