gpt4 book ai didi

python - Headless_ie_driver 启动 Internet Explorer 时出现意外错误。 IELaunchURL() 返回 HRESULT 80070012 ('There are no more files.' )

转载 作者:太空宇宙 更新时间:2023-11-03 14:14:00 24 4
gpt4 key购买 nike

我正在尝试运行一个简单的 headless (headless)网络浏览器;

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文件夹,但没有找到任何内容。

注释:相同的代码可以在普通的网络驱动程序 (IEDriverServer.exe) 中正常工作,当我手动打开 headless_ie_selenium.exe 时,它会启动:

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

最佳答案

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

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 Page headless-selenium-for-win Release Notes对于 headless-selenium-for-win v1.4 它清楚地提到了以下内容:

  • 支持 Firefox 和 Chrome
  • Windows 资源管理器不再在 headless (headless)桌面中启动。
  • desktop_utils.exe 学会在创建 headless (headless)桌面后不运行 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

Github 线程中的 @JimEvans 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.

关于python - Headless_ie_driver 启动 Internet Explorer 时出现意外错误。 IELaunchURL() 返回 HRESULT 80070012 ('There are no more files.' ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48322719/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com