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/'
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.