Headless_ie_driver Неожиданная ошибка при запуске Internet Explorer. IELaunchURL() вернул HRESULT 80070012 ("Больше нет файлов")

Я пытаюсь запустить простой безголовый веб-браузер;

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 Options находятся на одном уровне, и все они отметили Enabled Protected Mode;

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

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 Page из headless-selenium-for-win Release Notes за headless-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 inputs прямой Answer нет

@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.

Другие вопросы по тегам