Mozilla Firefox, Google Chrome, and Internet Explorer are the 3 leading browsers any QA engineer would choose for Web automation testing. Today, we’ll demonstrate the Internet Explorer driver for website test automation. We’ll also create a simple Selenium regression testing suite and run a small test case for the demo.
Why Use Internet Explorer Driver with Selenium
If you’ve read our previous post on using Chrome for website test automation, it’ll be easy for you to run through this post. Next, for your note, IE is already in the Selenium browser support list. It provides an InternetExploreDriver module which is an executable server. It is the implementation of the Webdriver interface that enables the execution of the Selenium regression testing suite.
Types of IE Driver
Similar to the Chrome driver, the InternetExplorerDriver module talks to the Webdriver client using the WIRE protocol. But you need to add activation instructions to get it working. So first of all, let’s see how to download the IntrenetExplorerDriver. We’ve given two green links below so that you can easily download them. It comes in two flavors: a 32-bit version and a 64-bit version. So download the version depending on the type of system you are using.
1. 32-bit IE Driver |
2. 64-bit IE Driver |
Use Internet Explorer Driver with Selenium
As we’ve specified above, you need to follow a few activation steps to use the Internet Explorer driver. So here are the two cents that you’ll spend to run your test code.
System.setProperty("webdriver.ie.driver", driverPath+"IEDriverServer.exe"); driver = new InternetExplorerDriver();
Since we’ve already covered the creation of Selenium testing projects in many of our previous posts, you can still refer to the link given below. In this ongoing Selenium tutorial, we’ll keep our focus only on creating a simple Selenium regression testing suite.
Must Read: 6 easy steps for creating a Webdriver project in Eclipse
Also, before we move on, probably it’s a good idea to outline the use case we’ll cover in the code snippet.
- Activate the Internet Explorer driver module.
- Create an IE Webdriver instance.
- Launch the Internet Explorer browser.
- Navigate to Google’s homepage.
- Validates the title text of the page.
Now, let’s check out the sample source code.
Sample Code Snippet
package com.selenium.regression; import org.openqa.selenium.WebDriver; import org.openqa.selenium.ie.InternetExplorerDriver; import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; public class IEBrowserTest { static String driverPath = "path of IEDriverServer on local system"; public WebDriver driver; @BeforeClass public void setUp() { System.out.println("*******************"); System.out.println("launching IE browser"); System.setProperty("webdriver.ie.driver", driverPath+"IEDriverServer.exe"); driver = new InternetExplorerDriver(); driver.manage().window().maximize(); } @Test public void testGooglePageTitleInIEBrowser() { driver.navigate().to("http://www.google.com"); String strPageTitle = driver.getTitle(); System.out.println("Page title: - "+strPageTitle); Assert.assertTrue(strPageTitle.equalsIgnoreCase("Google"), "Page title doesn't match"); } @AfterClass public void tearDown() { if(driver!=null) { System.out.println("Closing IE browser"); driver.quit(); } } }
Quick Wrap-up
Hopefully, the blog post was able to help. If you face any runtime issues, write to us for a solution.
If you want more such posts like – “How to use Internet Explorer Driver with Selenium“, please visit here more often.
Lastly, our site needs your support to remain free. Share this post on social media (Facebook/Twitter) if you gained some knowledge from this tutorial.
Enjoy testing,
TechBeamers.