How to launch Edge browser with Selenium Webdriver?


We can launch Edge browser with Selenium webdriver by using the Microsoft webdriver. We should also ensure that we are having the machine with the Windows 10 operating system.

Navigate to the below link to download the Microsoft Edge driver executable file − https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/

Once the page is launched, scroll down to the Downloads section, then choose and click the link which is compatible with our local Edge browser version.

A zip file gets created, once the download is completed successfully. We have to then unzip the file and save it in a desired location. Then, set the path of the msedgedriver.exe file. This is done by utilizing the System.setProperty method.

Finally we have to create an instance of the EdgeDriver class.

Syntax

System.setProperty("webdriver.edge.driver",
"C:\Users\ghs6kor\Desktop\Java\msedgedriver.exe");
WebDriver d = new EdgeDriver();

Example

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;
public class EdgeBrwser{
   public static void main(String[] args) {
      //set path of msedgedriver.exe path
      System.setProperty("webdriver.edge.driver",
         "C:\Users\ghs6kor\Desktop\Java\msedgedriver.exe");
      //instance of EdgeDriver
      WebDriver driver = new EdgeDriver();
      //URL launch
      driver.get("https://www.tutorialspoint.com/index.htm");
   }
}

Output

Updated on: 07-Apr-2021

7K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements