2011-07-11 16 views
2

で失敗Iました次のコードは、私はまだ/tmpフォルダ内の設定を保存しようとwebdriverをprofile_directoryのFirefoxを設定してもセレンは:FirefoxProfileが見つからない例外

profile = FirefoxProfile(profile_directory = '/home/sultan/profiles') 
    profile.set_preference('network.proxy.http', scheme); 
    profile.set_preference('network.proxy.http_port', self.proxy.get('port')); 

例外コード

 

    File "/home/sultan/Repository/Django/monitor/app/utils.py", line 79, in start 
    request.perform(scan = scan, schedule = schedule) 
    File "/home/sultan/Repository/Django/monitor/app/request.py", line 230, in perform 
    profile1 = FirefoxProfile(profile_directory = '/home/sultan/profiles') 
    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_profile.py", line 97, in __init__ 
    self._read_existing_userjs() 
    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_profile.py", line 178, in _read_existing_userjs 
    f = open(os.path.join(self.profile_dir, 'user.js'), "r") 
IOError: [Errno 2] No such file or directory: '/tmp/webdriver-py-profilecopy/user.js' 

何が間違っているのですか、またはセレンの特定の設定を追加する必要がありますか?

スルタン

+0

は/ホーム/スルタン/プロファイルは、複数のプロファイルが含まれていますか? –

+0

はい、複数のプロファイルを含むはずですが、今でも/ tmpにプロファイルを保存しています。その理由は、スレッドを使ってWebサイトをテストしようとしているからです。 – sultan

+0

複数のプロファイルを含むフォルダ? –

答えて

2

私は同じ問題があります。 FF5にはプロファイル内に "user.js"がありません - >私たちはそれを読む必要はありません。

firefox_profile.pyので、オープンセレン/ webdriverを/ Firefoxの/と、このように、デフ_read_existing_userjs(自己)の後以外試みを追加します。

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

これはhttp://code.google.com/p/selenium/source/detail?r=12909 – sultan

関連する問題