Selenium: FirefoxProfile fails with not found exception

后端 未结 1 789
慢半拍i
慢半拍i 2021-01-21 09:14

I\'ve the following code, though I set the profile_directory Firefox webdriver still attempts to store setting within the /tmp folder

p         


        
相关标签:
1条回答
  • 2021-01-21 09:49

    I have same problem. As FF5 doesn't have "user.js" in profile -> we don't have to read it.

    so open selenium/webdriver/firefox/firefox_profile.py and add try except after def _read_existing_userjs(self), like this:

    def _read_existing_userjs(self):
        try:
            f = open(os.path.join(self.profile_dir, 'user.js'), "r")
        except IOError, e:
            print "We didn't find user.js in your profile, but that is ok"
            return
    
        tmp_usr = f.readlines()
        f.close()
        for usr in tmp_usr:
            matches = re.search('user_pref\("(.*)",\s(.*)\)', usr)
            self.default_preferences[matches.group(1)] = matches.group(2)
    
    0 讨论(0)
提交回复
热议问题