【问题标题】:Selenium Webdriver error: "Can't load the profile"Selenium Webdriver 错误:“无法加载配置文件”
【发布时间】:2013-08-12 11:06:06
【问题描述】:

我正在使用 Selenium Webdriver(Python 绑定),我的脚本适用于 Mac(OS X 10.6.8),但不适用于 PC(Windows 7 Enterprise)。这是我得到的错误:

C:\Python27>python myscript.py
Traceback (most recent call last):
  File "myscript.py", line 303, in <module>
    myfunction(arg1)
  File "myscript.py", line 87, in myfunction
    browser = webdriver.Firefox(firefox_profile = fp)
  File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py",
line 61, in __init__
    self.binary, timeout),
  File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\extension_conne
ction.py", line 47, in __init__
    self.binary.launch_browser(self.profile)
  File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\firefox_binary.
py", line 61, in launch_browser
    self._wait_until_connectable()
  File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\firefox_binary.
py", line 105, in _wait_until_connectable
    self.profile.path, self._get_firefox_output()))
selenium.common.exceptions.WebDriverException: Message: "Can't load the profile.
 Profile Dir: c:\\users\\marzagao.1\\appdata\\local\\temp\\tmpnn0nhk Firefox out
put: "

这是我脚本的相关部分(我正在遍历不同的下载文件夹):

for download_folder in list_of_download_folders:

    fp = webdriver.FirefoxProfile()
    fp.set_preference("browser.download.folderList", 2)
    fp.set_preference("browser.download.manager.showWhenStarting", False)
    fp.set_preference("browser.download.dir", download_folder)
    fp.set_preference("browser.helperApps.neverAsk.saveToDisk", "text/plain")
    browser = webdriver.Firefox(firefox_profile = fp)

    # gets URL, download files

我四处搜索,显然此错误消息可能有不同的原因。我尝试了这个解决方案here,但它没有用(我想它不适用于我的情况,即使错误消息相似)。有什么想法吗?

(Windows 7 企业版、Service Pack 1、Python 2.7.5、Selenium 2.34、Firefox 23.0)

【问题讨论】:

    标签: python python-2.7 selenium selenium-webdriver webdriver


    【解决方案1】:

    似乎还不支持 Firefox 23。 Selenium 2.34 增加了对 Firefox 22 的支持,现在已经发布了 2.35,但是没有提到 FF23。

    所以我建议您将 Firefox 降级到 v22 或尝试新的 2.35 selenium 库。

    https://github.com/SeleniumHQ/selenium/blob/master/py/CHANGES

    它在 mac 上是如何工作的? - 我不知道,你确定你在那里运行 ff23 吗?

    【讨论】:

    • 谢谢,埃尔基。那是一个月前的事了,但你说的很有道理,也许我在 OSX 上运行 ff22,在 Windows 上运行 ff23。最后我完全放弃了 Firefox 并且完全重写了脚本,所以我现在不能轻易地重新测试它,但我会在某个时候回到这个问题。
    猜你喜欢
    • 2014-11-25
    • 2017-01-19
    • 1970-01-01
    • 1970-01-01
    • 2013-04-04
    • 2022-06-29
    • 1970-01-01
    • 2011-11-11
    相关资源
    最近更新 更多