Selenium:FirefoxProfile异常 无法加载配置文件

102 投票
10 回答
79334 浏览
提问于 2025-04-16 21:26

根据之前的一个问题,我把Selenium更新到了2.0.1版本。可是现在我又遇到了一个错误,尽管在/tmp/webdriver-py-profilecopy目录下确实有配置文件:

  File "/home/sultan/Repository/Django/monitor/app/request.py", line 236, in perform
    browser = Firefox(profile)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 46, in __init__
    self.binary, timeout),
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/extension_connection.py", line 46, 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 87, in _wait_until_connectable
    raise WebDriverException("Can't load the profile. Profile Dir : %s" % self.profile.path)
selenium.common.exceptions.WebDriverException: Can't load the profile. Profile Dir : /tmp/webdriver-py-profilecopy

这是什么问题呢?我该怎么解决这个问题呢?

10 个回答

26

我遇到了和你一样的问题,使用的是Firefox 32.0和Selenium selenium-2.42.1-py2.7.egg。我尝试更新Selenium,但发现已经是最新版本了。最后的解决办法是把Firefox降级到30版本。以下是具体步骤:

#Download version 30 for Linux (This is the 64 bit)
wget http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/30.0/linux-x86_64/en-US/firefox-30.0.tar.bz2

tar -xjvf firefox-30.0.tar.bz2
#Remove the old version
sudo rm -rf /opt/firefox*
sudo mv firefox /opt/firefox30.0
#Create a permanent link
sudo ln -sf /opt/firefox30.0/firefox /usr/bin/firefox

这样做解决了所有问题,这个组合效果更好!

32

我在把Ubuntu升级到12.04后也遇到了同样的问题。

这个问题出在软件包上,已经在最新版本的库里修复了。只需要更新一下selenium库就可以了。对于几乎所有的Python环境来说,更新的命令是:

pip install -U selenium
137

更新:

Selenium团队在最新版本中修复了这个问题。对于几乎所有的环境,解决方法是:

pip install -U selenium

不太清楚具体是哪个版本修复的(看起来是r13122),但肯定在2.26.0版本(更新时的最新版本)中已经修复了。


这个错误的意思是,_wait_until_connectable这个过程超时了,因为某种原因,代码无法连接到已经加载到Firefox中的webdriver扩展。

我刚刚向Selenium报告了一个错误,我遇到这个问题是因为我在尝试使用代理,而在配置文件中设置的4个更改中,只有2个被Firefox接受了,所以代理没有配置好,无法与扩展进行通信。不太清楚为什么会这样……

https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/2061

撰写回答