您所看到的错误说明了一切:
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的 的ReleaseNotes为 它明确提到了以下情况:
支持Firefox和Chrome无头桌面不再启动Windows资源管理器。创建无头桌面后,desktop_utils.exe学会了不运行explorer.exe。因此,无法使用 *
更新:按您的评论Are there any alternatives to open IE and run it in background viaselenium with mouse/keyboard inputs直Answer是 。
Github线程中的@JimEvans 明确提到:
他还补充说:
解决方法我正在尝试运行一个简单的无头Web浏览器;
from selenium import webdriverfrom selenium.webdriver.common.keys import Keysdriver = 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 DesiredCapabilitiescaps = DesiredCapabilities.INTERNETEXPLORER.copy()caps[’ie.ensureCleanSession’]= Truedriver = 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.exeStarted InternetExplorerDriver server (32-bit)3.8.0.0