WebDriverException:无法在selenium python脚本中加载配置文件错误

时间:2011-09-07 03:46:04

标签: python unit-testing selenium webdriver web-testing

我在python中使用selenium webdriver自动驱动Firefox,python脚本从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

有人遇到过这个问题吗?怎么解决这个?提前谢谢。

EDIE :selenium 2.5版已经解决了这个问题。

1 个答案:

答案 0 :(得分:11)

运行selenium v​​ 2.9.0后升级到Firefox 8后出现此问题。

通过升级到最新版本的selenium (2.13)来解决。

 sudo pip install selenium --upgrade

(如果您使用的是Python风格)