How to Run Edge Driver in Selenium Using Eclipse?
Last Updated :
22 Sep, 2023
Selenium is a well-known software used for software testing purposes. Selenium consists of 3 parts. One is Selenium IDE, one is Selenium Webdriver & the last one is Selenium Grid. Among these Selenium Webdriver is the most important one. Using webdriver online website testing can be done. There are 3 main webdrivers present.
For the Chrome browser, ChromeDriver is present. For the Firefox browser, Gecko Driver is applicable. And for Microsoft Edge, there will be MSEdgeDriver present. In this article, the process of running EdgeWebdriver is implemented. This simple Java program can be run.
Pre-Requisite required is as follows:
- For running EdgeDriver, Java jdk version must be installed in machine previously.
- Latest version of Edge should be installed.
- It is preferable to install Eclipse IDE in machine, so that running this code will be easier.
- Most important pre-requisite is latest EdgeDriver should be downloaded in machine.
Approach:
Here, using EdgeDriver, the home page of Google is going to open. For, that some methods need to be imported.
Step 1: The Google home page link is to be stored in a string.
Step 2: Then in a program, the property of the browser is to be set. setproperty() method is going to be used here.
Step 3: In the setProperty() method, the first argument is to be the web driver that is to be used. Here, using EdgeDriver specifically that argument has to be passed. And in the second argument, the location of the EdgeDriver.exe is to be passed.
Note: In this case, EdgeDriver.exe is stored in Eclipse, so may be the location seems different. But also, a complete File Explorer path can also be passed.
Step 4: Then a new object called driver should be implemented which is a type of WebDriver. Here, in this case, it will be EdgeDriver.
Step 5: Then using that driver object, the get() method will be used. This get() method of webDrivers helps to open some URLs provided. Here the home page of Google is going to be opened. So, only the string where the URL has been stored will be passed. Executing this method will open a new Edge window.
Step 6: Then the sleep() method is going to be implemented. This delays the programs for some time. So that the output can be visible easily.
Step 7: At last, the opened Edge window has to be closed. For that reason, the quit() method is going to be implemented.
Implementation:
Java
// Java Program to Illustrate Run for Edge Driver
// In Selenium Using Eclipse
// Importing All Necessary Items
import java.io.*;
import java.lang.Thread;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;
// Class
public class EdgeHomePage {
// Main driver method
public static void main(String[] args)
{
// Try block as we will be using sleep() method
try {
// String Where Home Page URL Is Stored
String baseUrl = "https://www.google.com/";
// Implementation of SetProperty Method
System.setProperty(
"webdriver.edge.driver",
"test/resources/msedgedriver.exe");
// Creating new Object driver Of Webdriver
WebDriver driver = new EdgeDriver();
// Calling Home Page by
// using Get() Method
driver.get(baseUrl);
// Making output delayed
// by 2 seconds
Thread.sleep(2000);
// Closing The Opened Window
// using quit() method
driver.quit();
}
// Catch block to handle exceptions
catch (Exception e) {
// Display exceptions on the console
System.out.println(e);
}
}
}
Output:
If the above code is run, then a new Edge Window will be opened. This open window will be controlled by EdgeDriver.exe.
Similar Reads
How to Run Gecko Driver in Selenium Using Java? Selenium is a well-known software used for software testing purposes. It consists of three parts: Selenium IDE, Selenium WebDriver, and Selenium Grid. Selenium WebDriver is the most important. Using WebDriver, online website testing can be done. There are three main WebDriver implementations:ChromeD
5 min read
How to Run Internet Explorer Driver in Selenium Using Java? Selenium is a well-known software used for software testing purposes. Selenium consists of three parts. One is Selenium IDE, one is Selenium Webdriver & the last one is Selenium Grid. Among these Selenium Webdriver is the most important one. Using Webdriver online website testing can be done. Th
6 min read
How to Run Opera Driver in Selenium Using Java? Selenium is a well-known software used for software testing purposes. Selenium consists of three parts. One is Selenium IDE, one is Selenium Webdriver & the last one is Selenium Grid. Among these Selenium Webdriver is the most important one. Using Webdriver online website testing can be done. Th
3 min read
How to Run Safari Driver in Selenium Using Java? Selenium is a well-known software used for software testing purposes. Selenium consists of three parts: Selenium IDE, Selenium Webdriver, and Selenium Grid. Among these, Selenium Webdriver is the most important one. Using Webdriver, online website testing can be done. There are three main Webdrivers
4 min read
How to disable images in chrome using Selenium java? Disabling images in Chrome during automated testing can enhance performance and speed up your Selenium tests. This is particularly useful when dealing with large web pages or when you want to focus on specific elements without the distraction of images. In this guide, we'll walk you through how to d
2 min read
How to Install Firefox Driver for Selenium? GeckoDriver is essential for using Selenium WebDriver with the Firefox browser. It acts as a bridge between Selenium and Firefox, allowing for seamless browser automation. Installing GeckoDriver ensures that your automated tests run smoothly and efficiently on Firefox, leveraging the latest browser
4 min read