How to run Microsoft Edge headless with Selenium Python? How to run Microsoft Edge headless with Selenium Python? selenium selenium

How to run Microsoft Edge headless with Selenium Python?


  options = EdgeOptions()  options.use_chromium = True  options.add_argument("headless")  options.add_argument("disable-gpu")

Try above code , you have to enable chromium to enable headless

https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/?tabs=python

This works only for new edge chromium not for edge legacy versions . In legacy versions headless is not supported

Full code

from msedge.selenium_tools import EdgeOptionsfrom msedge.selenium_tools import Edge# make Edge headlessedge_options = EdgeOptions()edge_options.use_chromium = True  # if we miss this line, we can't make Edge headless# A little different from Chrome cause we don't need two lines before 'headless' and 'disable-gpu'edge_options.add_argument('headless')edge_options.add_argument('disable-gpu')driver = Edge(executable_path='youredgedriverpath', options=edge_options)


webdriver.Edge does not accept any options so i switched it to the following:It worked for me.

        # imports        from selenium import webdriver        from msedge.selenium_tools import EdgeOptions        # options        options = EdgeOptions()        options.use_chromium = True        options.add_argument("--headless")        options.add_argument("disable-gpu")        browser = webdriver.Chrome(            executable_path="resources/msedgedriver.exe", options=options)        browser.get(gen_token)

The version of Microsoft Edge that I am using is :

Microsoft EdgeVersion 89.0.774.57 (Official build) (64-bit)

This worked for me.


for Edge browser

options = EdgeOptions()

options.use_chromium = True

options.add_argument('--allow-running-insecure-content')

options.add_argument("--ignore-certificate-errors")

self.wd = webdriver.Chrome(executable_path=EdgeChromiumDriverManager().install(), options=options)

self.wd.maximize_window()

For Edge headless

options = EdgeOptions()

options.use_chromium = True

options.add_argument("--headless")

options.add_argument("disable-gpu")

options.add_argument('--allow-running-insecure-content')

options.add_argument('--ignore-certificate-errors')

self.wd = webdriver.Chrome(executable_path=EdgeChromiumDriverManager().install(), options=options)

self.wd.maximize_window()