通过geckodriver的Selenium Firefox webdriver导致错误:无法启动浏览器:找不到实体

时间:2016-11-05 16:55:58

标签: python firefox webdriver

我正在使用:

  • Selenium v​​er 3.0.1
  • Firefox ver 47 64bit
  • Windows 10
  • geckodriver ver 11

我的代码:

from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

binary=FirefoxBinary('C:\Program Files\Mozilla Firefox\firefox.exe')
wb=webdriver.Firefox(firefox_binary=binary)
wb.get("www.python.org")

错误讯息:

   wb=webdriver.Firefox(firefox_binary=binary)
  File "c:\Python34\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 145, in __init__
    keep_alive=True)
  File "c:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 92, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "c:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 179, in start_session
    response = self.execute(Command.NEW_SESSION, capabilities)
  File "c:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 236, in execute
    self.error_handler.check_response(response)
  File "c:\Python34\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 192, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Failed to start browser: entity not found

2 个答案:

答案 0 :(得分:4)

答案 1 :(得分:2)

发现问题可能是一个错误 在geckodriver.log中,我注意到firefox.exe的调用方式有些奇怪

  

1478478477543 geckodriver :: marionette INFO启动浏览器C:\ Program   文件(x86)\ Mozilla Firefoxirefox.exe

当我将firefox路径从firefox.exe更改为大写F Firefox.exe时。每个人都在工作

binary = FirefoxBinary('C:\Program Files (x86)\Mozilla Firefox\Firefox.exe')