I want to run my scripts in Edge browser in headless mode.But I am not able to find any proper solution for it. Can anyone suggest on this
Asked
Active
Viewed 1.7k times
2

ankita garge
- 21
- 1
- 1
- 2
-
What research have you done to not be able to find any help on this? Google is your friend my friend. Try entering "edge selenium" – Hoppo Jun 09 '20 at 15:43
3 Answers
1
Here, I assume that you are trying to automate the MS Edge Chromium browser and you want to run selenium tests on the MS Edge browser in headless mode.
You can refer to the steps below.
Download the Java/C# binding of Selenium 4.00-alpha05 from here.
Download the matching version of Microsoft Edge Driver from this page.
Example C# code.
using OpenQA.Selenium.Edge;
using System.Threading;
namespace ecwebdriver
{
public class edgewebdriver
{
static void Main(string[] args)
{
EdgeOptions edgeOptions = new EdgeOptions();
edgeOptions.UseChromium = true;
edgeOptions.BinaryLocation = @"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe";
edgeOptions.AddArgument("headless");
edgeOptions.AddArgument("disable-gpu");
var msedgedriverDir = @"E:\webdriver";
var driver = new EdgeDriver(msedgedriverDir, edgeOptions);
driver.Navigate().GoToUrl("<website url>");
Thread.Sleep(3000);
driver.Close();
}
}
}
JAVA Example code:
package selenium_test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.*;
public class new_java_class
{
public static void main(String[] args)
{
System.setProperty("webdriver.edge.driver","D:\\edgedriver_win64_83.0.478.45\\msedgedriver.exe");
EdgeOptions op=new EdgeOptions();
op.addArguments("headless");
WebDriver browser = new EdgeDriver(op);
browser.get("https://microsoft.com");
}
}
Note: Change the paths and modify the values in above code as per your own requirements.
You can download the Selenium 4.00-alpha05 on any path. you need to add it in your JAVA project by add External Jars option.

Deepak-MSFT
- 10,379
- 1
- 12
- 19
-
Can I get t in Java as I am using Java in my framework.And using this code I am getting errors. Also, on which path I download this Java/C# binding of Selenium 4.00-alpha05 – ankita garge Jun 10 '20 at 12:39
-
Please refer to the updated answer. I have added the JAVA code sample. – Deepak-MSFT Jun 10 '20 at 13:03
-
I am not able to set values to edgeoptions. it says UseChromium ,BinaryLocation etc are not member of edgeoptions. any idea? i have done the import correctly as Imports OpenQA.Selenium.Edge – anandhu Aug 14 '20 at 12:50
-
Does chromium Edge support headless execution if launched in IE Capability Mode? – anandhu Aug 24 '20 at 14:16
-
Running the Edge chromium-browser in IE mode will put the whole browser in an IE mode. Headless execution is not supported by the IE browser. so it will also not work when you try to automate the Edge chromium-browser in an IE mode. – Deepak-MSFT Aug 25 '20 at 06:21
-
This didn't work, the browser window is still getting opened. And addArguments() method is not present in *org.openqa.selenium.edge.EdgeOptions* but its in *com.microsoft.edge.seleniumtools.EdgeOptions* – Rashid Nov 08 '21 at 06:59
-
0
For python 3 this will enable headless browsing in edge:
from selenium import webdriver
from selenium.webdriver.edge.options import Options
opt = Options()
opt.add_argument("--headless")
driver = webdriver.Edge(options=opt)

Mike B
- 11
- 3
0
Using Python, that would be:
# Imports
from selenium import webdriver
# Instantiate a EdgeOption object
edge_options = webdriver.EdgeOptions()
# Set headless mode
edge_options.headless = True
# Start driver, passing edge_options
driver = webdriver.Edge(options=edge_options)
# Get page
page = driver.get(r"https://www.google.com")
This should work. Good luck!

the_hermit
- 1
- 2