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

7 thoughts on “Launch of Edge and Internet Explorer browser in Selenium 3”

  1. Exception in thread “main” org.openqa.selenium.SessionNotCreatedException: Unknown error (WARNING: The server did not provide any stacktrace information)
    Command duration or timeout: 0 milliseconds
    Build info: version: ‘unknown’, revision: ‘5234b32’, time: ‘2017-03-10 09:00:17 -0800’
    System info: host: ‘RCHENNUB-LAP1’, ip: ‘10.177.245.185’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_112’
    Driver info: driver.version: EdgeDriver

    1. when i run script o nedge browser getting above exception. edge browser is launched but url is not opening and immeditely program exits.can you give me the solution thanks in advance

  2. Yours each and every post is very helpful..n easy to understand..thankss
    Can you pleas share how to handle webelement if it is dynamic..

  3. The way you are explaining is really cool and awesome.
    If possible can you please provide the interview questions for each concept that you are explaining so that it would really helpful.

Leave a Reply

Your email address will not be published. Required fields are marked *