Selenium - IE 不是 运行 无头

Selenium - IE not running headless

使用 python 和 selenium,我有一个 IE 的功能 运行 无头,但由于某种原因它不起作用。它适用于 Chrome,但不适用于 IE。我可以发誓它以前有效。有什么想法吗?

from selenium import webdriver
from selenium.webdriver.ie.options import Options as IEOptions

def openie():
    setglobalvariables()
    window_size = '1920,1080'
    ie_options = IEOptions()
    ie_options.add_argument('--headless')
    ie_options.add_argument('--window-size=%s' % window_size)
    ie_options.add_argument('--no-sandbox')
    driver = webdriver.Ie(input_path + 'IEDriverServer.exe', options=ie_options)

    url = settingsfile('url').strip()
    statusmessage(url)
    driver.get(url)
    driver.maximize_window()
    driver.implicitly_wait(3)

    return driver

据我所知,IE不支持Headless Browsing。

您可以参考此线程进行验证,并了解它如何工作的解决方法:

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.

https://github.com/SeleniumHQ/selenium/issues/4551#issuecomment-324319508

https://community.lambdatest.com/t/how-can-i-run-my-selenium-tests-in-headless-ie/5447


编辑:

第二个帖子是 LambdaTest community 的,由我回答。