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
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
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.