1

I am aware that IE does not support headless. But there's a workaround of using virtual desktops on Windows to get it done. This is what https://github.com/kybu/headless-selenium-for-win is doing, but I seem to be running into an issue here.

My IEDriverServer.exe is added to $PATH$, and headless_ie_selenium.exe is also in the same directory as the IEDriverServer.exe

I'm trying to use it like this:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

browser = webdriver.Ie('C:\IEDriverServer_Win32_3.150.1\headless_ie_selenium.exe')

browser.get('www.someurl.com')

I'm pasting the traceback below

Traceback (most recent call last):
  File "C:\Users\hjind\Desktop\pythonRCM\headless_ie.py", line 16, in <module>
    browser = webdriver.Ie('C:\IEDriverServer_Win32_3.150.1\headless_ie_selenium.exe')
  File "C:\Users\hjind\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium-3.141.0-py3.9.egg\selenium\webdriver\ie\webdriver.py", line 93, in __init__
    RemoteWebDriver.__init__(
  File "C:\Users\hjind\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium-3.141.0-py3.9.egg\selenium\webdriver\remote\webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "C:\Users\hjind\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium-3.141.0-py3.9.egg\selenium\webdriver\remote\webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Users\hjind\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium-3.141.0-py3.9.egg\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\hjind\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium-3.141.0-py3.9.egg\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: Unexpected error launching Internet Explorer. IELaunchURL() returned HRESULT 80070012 ('There are no more files.') for URL 'http://localhost:57762/'
Harshit Jindal
  • 621
  • 8
  • 26
  • does this solution help https://stackoverflow.com/questions/51165929/unexpected-error-launching-internet-explorer-ielaunchurl-returned-hresult-800 – C. Peck Apr 29 '21 at 18:31
  • You need to [configure these things](https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver#required-configuration) before you use IE Driver. Please check them one by one and do what the doc says. Besides, you should use double backslash in your path like this `browser = webdriver.Ie('C:\\IEDriverServer_Win32_3.150.1\\headless_ie_selenium.exe')` and the url should use protocol like this `browser.get('https://www.someurl.com')`. – Yu Zhou Apr 30 '21 at 05:36
  • @C.Peck Let me try to set "introduce_flakiness_by_ignoring_security_domains". This seems to be an issue with the API for calling IE, and Microsoft has not provided why this happens. – Harshit Jindal Apr 30 '21 at 07:38

1 Answers1

1

The only thing that worked for me was to programatically minimise the IE window on launch, and switch to another virtual desktop while the job runs.

Setting introduce_flakiness_by_ignoring_security_domains helped bypass the "Protected Mode" and "Zoom Level" errors.

Harshit Jindal
  • 621
  • 8
  • 26