Launch of Edge and Internet Explorer browser in Selenium 3

Hello Folks,

We have seen:

  1. How to launch Firefox browser.
  2. How to launch chrome browser.

In this post we will learn:

  1. How to launch Edge browser(Windows 10 onward)
  2. How to launch Internet Explorer browser

What is Edge browser:

Microsoft Edge is a web browser developed by Microsoft and included in Windows 10, Windows 10 Mobile and Xbox One, replacing Internet Explorer as the default web browser on all device classes.  It has designed to be a lightweight web browser.

Note: You will find Internet Explorer as well in Windows 10. Just it has been removed as default browser of Microsoft. #InterviewQuestion

Launch of Edge browser through Selenium 3:

##StartOfConcept##

  1. We are aware that Selenium provides driver class for each browser and when we create an object of browser driver class, It will launch the browser. For Edge browser, we have EdgeDriver class.
  2. We need to set system property for defining path of edge driver executable file as we have done for Firefox and chrome browsers.
  3. Here, getting executable file of edge browser is little tricky. You will not get .exe file directly.
  4. First you need to download Microsoft webdriver as per your OS build number. You can download it easily from here. You will get a file with name “MicrosoftWebDriver.msi”.
  5. You need to setup Microsoft WebDriver by double clicking on above file similar to other software installation. By default it will be installed in below path: C:\Program Files (x86)\Microsoft Web Driver\ .
  6. Go to above path. You will find “MicrosoftWebDriver.exe” inside “Microsoft Web Driver” folder. For convenience, you will copy this .exe file and will put in our exefiles folder.
  7. Now set the system property using setProperty method of System class and create an object of EdgeDriver class to open a browser.

##EndOfConcept##

#JavaCode


import org.openqa.selenium.edge.EdgeDriver;
public class LaunchEdgeBrowser {
public static void main(String[] args) {
//setting path of edgeodriver
System.setProperty("webdriver.edge.driver", "./exefiles/MicrosoftWebDriver.exe");
// Launching edge browser
EdgeDriver EDriver= new EdgeDriver();
// Opening a URL
EDriver.get("https://www.google.com");
// Closing the browser
EDriver.quit();
}
}

Launch of Internet Explorer in Selenium:

##StartOfConcept##

  1. To launch Internet Explorer, we have InternetExplorerDriver class. Creating an object of this class will result in launch of IE browser.
  2.  You need to set path of IE executable file like we did for other browsers. You can download exe file  from here. You need to download as per your processor. IEDriver

##EndOfConcept##

#JavaCode


import org.openqa.selenium.ie.InternetExplorerDriver;
public class LaunchIEBrowser {
public static void main(String[] args) {
//setting path of IEodriver
System.setProperty("webdriver.ie.driver", "./exefiles/IEDriverServer.exe.exe");
// Launching edge browser
InternetExplorerDriver driver = new InternetExplorerDriver();
// Opening a URL
driver.get("https://www.google.com");
// Closing the browser
driver.quit();
}
}

That’s all for this post. Comments, suggestion are welcomed.
#HappyLearning

Author: Amod Mahajan