WebDriverException:Selenium Python脚本无法加载配置文件错误

9 投票
1 回答
2934 浏览
提问于 2025-04-17 01:38

我在用Python的selenium webdriver来自动操作Firefox浏览器,脚本是从Firefox的selenium IDE插件导出的。但是当我运行这个脚本时,出现了一个错误:

        ======================================================================
    ERROR: test_selenium (__main__.SeleniumTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "selenium_test.py", line 8, in setUp
        self.driver = webdriver.Firefox()
      File "C:\Python26\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 46, in __init__

        self.binary, timeout),
      File "C:\Python26\lib\site-packages\selenium\webdriver\firefox\extension_connection.py", line 46,
    in __init__
        self.binary.launch_browser(self.profile)
      File "C:\Python26\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 44, in lau
    nch_browser
        self._wait_until_connectable()
      File "C:\Python26\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 87, in _wa
    it_until_connectable
        raise WebDriverException("Can't load the profile. Profile Dir : %s" % self.profile.path)
    WebDriverException: Can't load the profile. Profile Dir : c:\users\ataosky\appdata\local\temp\tmpwpz
    zrv

    ----------------------------------------------------------------------
    Ran 1 test in 67.876s

    FAILED (errors=1)

WebDriverException: 无法加载配置文件。配置文件目录:c:\users\ataosky\appdata\local\temp\tmpwpz

有没有人遇到过这个问题?怎么解决呢?提前谢谢大家。

补充说明: selenium 2.5版本已经解决了这个问题。

1 个回答

11

我在升级到Firefox 8后,使用selenium v 2.9.0时遇到了这个问题。

这个问题通过升级到最新版本的selenium(2.13)解决了。

 sudo pip install selenium --upgrade

(如果你使用的是Python版本)

撰写回答