How to Open Microsoft Edge Browser using Selenium in Java?
- Launch Edge browser.
- Maximize the browser.
- Open URL: https://www.geeksforgeeks.org/
For invoking the chrome browser, we need the Eclipse IDE, Selenium Grid(version 4), and Edge Driver.
Note: To open Chrome Browser Using Selenium please refer to this article How to Open Chrome Browser Using Selenium in Java?
- Eclipse IDE: Before downloading also make sure that your device has Java JDK. If you don’t have, install Java refer to this: How to Download and Install Java for 64 bit machine?. And install Eclipse IDE by referring to this article Eclipse IDE for Java Developers
- Selenium: Download the Selenium latest stable version here
- Web Driver: Download the Microsoft Edge Webdriver according to your version here
Step By Step Implementation
Open the Eclipse IDE and create a new Java project. Right-click on the “src” folder and create a new Class File from New > Class. Give the Class name and click on the “Finish” button.
Add Selenium JAR file into the Java Project. Right-click on Class name and Select “Build Path” and select > configure build path
Then select Libraries > Classpath > and Click “Add External JAR”, now add the Selenium Jar and click “Apply and Finish”
Studying the code
The above script is for opening Microsoft Edge Browser and navigating to geeksforgeeks website. So let’s see how it works:
- Set a system property “webdriver.edge.driver” to the path of your EdgeDriver.exe file and instantiate an EdgeDriver class:
System.setProperty(“webdriver.edge.driver” ,”edgedriver location”);
- Maximize the window: driver.manage().window().maximize();
- To open the URL: driver.get(“URL link”)