加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python – Selenium Webdriver错误:“无法加载配置文件”

发布时间:2020-12-16 21:37:10 所属栏目:Python 来源:网络整理
导读:我正在使用Selenium Webdriver( Python绑定),我的脚本适用于Mac(OS X 10.6.8),但不适用于PC(Windows 7 Enterprise).这是我得到的错误: C:Python27python myscript.pyTraceback (most recent call last): File "myscript.py",line 303,in module myfunction
我正在使用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:Python27libsite-packagesseleniumwebdriverfirefoxwebdriver.py",line 61,in __init__
    self.binary,timeout),File "C:Python27libsite-packagesseleniumwebdriverfirefoxextension_conne
ction.py",line 47,in __init__
    self.binary.launch_browser(self.profile)
  File "C:Python27libsite-packagesseleniumwebdriverfirefoxfirefox_binary.
py",in launch_browser
    self._wait_until_connectable()
  File "C:Python27libsite-packagesseleniumwebdriverfirefoxfirefox_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:usersmarzagao.1appdatalocaltemptmpnn0nhk 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

我google了一下,显然这个错误信息可能有不同的原因.我尝试了这个解决方案here,但它不起作用(我想这不适用于我的情况,即使错误消息类似).有什么想法吗?

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

解决方法

似乎还不支持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吗?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读