【问题标题】:Headless_ie_driver Unexpected error launching Internet Explorer. IELaunchURL() returned HRESULT 80070012 ('There are no more files.')Headless_ie_driver 启动 Internet Explorer 时出现意外错误。 IELaunchURL() 返回 HRESULT 80070012('没有更多文件。')
【发布时间】:2018-01-19 18:27:21
【问题描述】:

我正在尝试运行一个简单的无头网络浏览器;

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Ie("headless_ie_selenium.exe")
driver.get("www.google.com")
print(driver.title)

我得到:

selenium.common.exceptions.SessionNotCreatedException: Message: Unexpected error launching Internet Explorer. IELaunchURL() returned HRESULT 80070012 ('There are no more files.') for URL 'http://localhost:65393/'

我尝试过但没有用的方法:

1:

from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
caps = DesiredCapabilities.INTERNETEXPLORER.copy()
caps['ie.ensureCleanSession']= True
driver = webdriver.Ie("headless_ie_selenium.exe",capabilities=caps)

2:所有 Internet 选项安全设置都处于同一级别,并且都已选中启用保护模式;

3:搜索了一个要删除的C:\Program文件夹,但是什么也没有。

注意事项:相同的代码在普通的 webdriver (IEDriverServer.exe) 上运行良好,当我手动打开 headless_ie_selenium.exe 时它会启动:

Selenium driver found at: path..\IEDriverServer.exe
Started InternetExplorerDriver server (32-bit)
3.8.0.0

【问题讨论】:

    标签: python selenium selenium-webdriver headless headless-browser


    【解决方案1】:

    您看到的错误说明了一切:

    selenium.common.exceptions.SessionNotCreatedException: Message: Unexpected error launching Internet Explorer. IELaunchURL() returned HRESULT 80070012 ('There are no more files.') for URL 'http://localhost:65393/'
    

    如果您访问Release Pageheadless-selenium-for-winRelease Notesheadless-selenium-for-win v1.4,它清楚地提到了以下内容:

    • 支持 Firefox 和 Chrome
    • Windows 资源管理器不再在无头桌面中启动。
    • desktop_utils.exe 学会在创建无头桌面后不运行 explorer.exe。

    因此 Internet Explorer 无法使用 headless_ie_selenium.exe 进行初始化。


    更新:

    根据您的评论Are there any alternatives to open IE and run it in background via selenium with mouse/keyboard inputsAnswer

    @JimEvans 在 Github 线程 Headless IE with selenium not working on Windows server 中明确提到:

    The IE driver does not support execution without an active, logged-in desktop session running. You'll need to take this up with the author of the solution you're using to achieve "headless" (scare quotes intentional) execution of IE.

    他还补充道:

    Mouse and keyboard simulation won't work without an active session. It's a browser limitation, not a driver limitation.

    【讨论】:

    • 嗯,有没有其他方法可以打开 IE 并通过 selenium 使用鼠标/键盘输入在后台运行它?
    猜你喜欢
    • 1970-01-01
    • 2018-12-12
    • 1970-01-01
    • 1970-01-01
    • 2020-04-16
    • 1970-01-01
    • 2018-05-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多