Python:Selenium Firefox Webdriver失败并显示错误:'无法加载配置文件... WARN addons.xpi ..."

duh*_*ime 27 python firefox selenium xpi

我正在尝试运行以下Python代码以通过Selenium创建Firefox Webdriver窗口:

from selenium import webdriver
driver = webdriver.Firefox()
driver.get("http://www.google.com")
Run Code Online (Sandbox Code Playgroud)

虽然这段代码几周前工作正常,但它现在会产生以下预感信息:

 Traceback (most recent call last):
  File "test.py", line 2, in <module>
    driver = webdriver.Firefox()
  File "c:\python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 60, in __init__
    self.binary, timeout),
  File "c:\python27\lib\site-packages\selenium\webdriver\firefox\extension_connection.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\\douglas\\appdata\\local\\temp\\tmpuf4ipq Firefox output: *** LOG addons.xpi: startup\r\n*** WARN addons.xpi: Ignoring missing add-on in C:\\Program Files\\CheckPoint\\ZAForceField\\WOW64\\TrustChecker\r\n*** WARN addons.xpi: Ignoring missing add-on in C:\\ProgramData\\Norton\\{78CA3BF0-9C3B-40e1-B46D-38C877EF059A}\\NSM_2.9.5.20\\coFFFw\r\n*** LOG addons.xpi: Skipping unavailable install location app-system-local\r\n*** LOG addons.xpi: Skipping unavailable install location app-system-share\r\n*** LOG addons.xpi: checkForChanges\r\n*** LOG addons.xpi: No changes found\r\n*** Blocklist::_loadBlocklistFromFile: blocklist is disabled\r\n************************************************************\r\n* Call to xpconnect wrapped JSObject produced this error:  *\r\n[Exception... "\'[JavaScript Error: "this._defaultEngine is null" {file: "resource://gre/components/nsSearchService.js" line: 3527}]\' when calling method: [nsIBrowserSearchService::currentEngine]"  nsresult: "0x80570021 (NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS)"  location: "JS frame :: chrome://browser/content/search/search.xml :: get_currentEngine :: line 130"  data: yes]\r\n************************************************************\r\n************************************************************\r\n* Call to xpconnect wrapped JSObject produced this error:  *\r\n[Exception... "\'[JavaScript Error: "this._defaultEngine is null" {file: "resource://gre/components/nsSearchService.js" line: 3527}]\' when calling method: [nsIBrowserSearchService::currentEngine]"  nsresult: "0x80570021 (NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS)"  location: "JS frame :: chrome://browser/content/search/search.xml :: get_currentEngine :: line 130"  data: yes]\r\n************************************************************\r\n************************************************************\r\n* Call to xpconnect wrapped JSObject produced this error:  *\r\n[Exception... "\'[JavaScript Error: "this._defaultEngine is null" {file: "resource://gre/components/nsSearchService.js" line: 3527}]\' when calling method: [nsIBrowserSearchService::currentEngine]"  nsresult: "0x80570021 (NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS)"  location: "JS frame :: resource://app/components/nsBrowserGlue.js :: <TOP_LEVEL> :: line 354"  data: yes]\r\n************************************************************\r\n************************************************************\r\n* Call to xpconnect wrapped JSObject produced this error:  *\r\n[Exception... "\'[JavaScript Error: "this._defaultEngine is null" {file: "resource://gre/components/nsSearchService.js" line: 3527}]\' when calling method: [nsIBrowserSearchService::currentEngine]"  nsresult: "0x80570021 (NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS)"  location: "JS frame :: resource://app/components/nsBrowserGlue.js :: <TOP_LEVEL> :: line 354"  data: yes]\r\n************************************************************\r\n'
Run Code Online (Sandbox Code Playgroud)

有谁知道这意味着什么,或者我可以做些什么来弥补错误并让代码按预期运行?我通过Google搜索找到了相关的错误消息,但没有任何消息可以让我解决问题.

对于它的价值,我可以通过更改上面的第二行来打开Chrome Webdriver而不会出现问题driver = webdriver.Chrome().

我正在使用Python 2.7,Selenium 2.35.0(我刚刚在Windows 8机器上运行"pip install selenium --upgrade"和Firefox 26.0.非常感谢其他人可以提供的任何提示或建议.

Sil*_*Ray 29

Selenium 2.35与Firefox 26不兼容.正如发行说明所述,在Selenium 2.39中添加了FF 26支持.您需要更新到2.39.试试吧pip install -U selenium.

  • 我运行了`pip install -U selenium`并且它似乎升级了selenium,但我仍然收到相同的错误消息.其他任何建议都是最受欢迎的 (4认同)
  • webdriver.xpi位于site-packages中的Selenium包分发中.每次创建Firefox实例时都会将其复制到tmp目录,然后在启动时将其加载到浏览器中.使用pip更新selenium应该更新xpi文件(实际上是驱动Selenium在浏览器中的操作的Firefox插件),当你使用`webdriver.Firefox()`实例化时,它会被启动.Firefox配置文件不同,虽然相关,因为它们定义了要加载的插件,Selenium将Selenium插件添加到它使用的动态复制配置文件列表中. (2认同)