How can I download Microsoft WebDriver/Edge Driver to use with Selenium?

SeleniumAutomation TestingTesting Tools

We can download Microsoft/Edge Driver to use with Selenium. The Microsoft Edge driver allows communication of the tests developed in Selenium with the Edge browser.

To download the msedgedriver.exe file, we have to first navigate to the following link − https://developer.microsoft.com/en-us/microsoftedge/tools/webdriver/#downloads

Then move to the Downloads section, and click on the link based on the local operating system and browser version we have.

Once the download is completed, a zip file gets saved. It needs to be extracted and stored in a location. After extracting it, the executable file - msedgedriver.exe file is to be kept at a desired location.

We have to configure the path of the msedgedriver.exe file using the System.setProperty method along with creating an object of the EdgeDriver class.

Syntax

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

Example

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
public class EdgeBrwserLaunch{
   public static void main(String[] args) {
      //configure path of msedgedriver.exe path
      System.setProperty("webdriver.edge.driver",
         "C:\\Users\\ghs6kor\\Desktop\\Java\\msedgedriver.exe");
      //object of EdgeDriver
      WebDriver driver = new EdgeDriver();
      //URL launch
      driver.get("https://www.yahoo.com/");
      //get browser name
      Capabilities c = ((RemoteWebDriver) driver).getCapabilities();
      System.out.println("Browser: " + c.getBrowserName());
      driver.quit();
   }
}

Output

raja
Published on 06-Apr-2021 11:19:07
Advertisements