0

Software version details: Python: 2.7.12 OS: Windows 10. Selenium: selenium-2.53.6 Firefox: 47.0

Code snippet:

import sys, urllib2

from selenium import webdriver

driver = webdriver.Firefox()

The last line throws this error:

Traceback (most recent call last): File "queryWebsite.py", line 8, in

driver = webdriver.Firefox()

File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 80, in __ init __

self.binary, timeout)   File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\extension_connection.py",

line 48, in __ init __

self.profile.update_preferences()   File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\firefox_profile.py",

line 97, in update_preferences

self._write_user_prefs(self.default_preferences)   File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\firefox_profile.py",

line 221, in _write_user_prefs with open(self.userPrefs, "w") as f:

IOError: [Errno 22] invalid mode ('w') or filename: 'c:\users\xyz\appdata\local\temp\tmpgwa_ot\user.js'

Any idea what is going wrong here?

Moses Koledoye
  • 77,341
  • 8
  • 133
  • 139
muthu_rk
  • 21
  • 1
  • 3
  • have you tried reinstalling your webdriver? I wonder if it got messed up somehow. – Breaks Software Jul 13 '16 at 12:10
  • Yes. Same error persists. I did the following. pip uninstall selenium && pip install -U selenium --no-cache-dir (to download fresh) – muthu_rk Jul 13 '16 at 12:12
  • I don't happen to have Python or a selenium driver for Python installed, but the problem being reported is that the call to open(self.userPrefs, "w") doesn't like the form of the string returned by self.userPrefs. those single \'s shouldn't be used, or the string should be a raw string (see http://stackoverflow.com/questions/15598160/ioerror-errno-22-invalid-mode-r-or-filename-c-python27-test-txt). Now, why this is happening in selenium code is strange. You might want to look at firefox_profile.py to see how it's returning that self.userPrefs – Breaks Software Jul 13 '16 at 15:49

0 Answers0