Before going through this section, I would recommend you to check your IE browser settings for running the automation from the below article.
Once above setting is set on your IE browser, Open Eclipse and open the project which we have created previously.
You can also download the code directly from the GitHub as well.
For the running IE instance, you’ll need the IEDriver Server binaries similar to what we have for the Chrome Browser and Firefox Browser.
Below tutorial will guide you for downloading browser binaries
- Now once you downloaded the binaries and unzipped it, you’ll need to set those binaries in the system by
System.setProperty()command. For the Internet Explorer, property set by
webdriver.ie.driverand with value as the path of the IEDriverServer.exe. as below
// Setting the IE Driver binaries System.setProperty("webdriver.ie.driver", "C:\\Users\\admin\\Desktop\\IEDriverServer.exe");
- Now just like again Chrome browser, we’ll need an instance of the
driverfor working with automation. You might also notice we have created the driver instance with the
ChromeDriver()which will create the instance for the Chrome browser with the WebDriver, we’ll create an instance as
InternetExplorerDriver()for the running Internet Explorer.
// Creating instance of the InternetExplorerDriver WebDriver driver = new InternetExplorerDriver();
- Now follow the similar steps as below to open the browser and enter the test URL, and getting the page title from the page and finally closing the browser session.
// Opening the Browser with URL driver.get("http://www.step2qa.com"); // Get and print the page title of the loaded page System.out.println(driver.getTitle()); // Wait for the 5000ms (5 seconds) Thread.sleep(5000); // Quit the browser session and close the current running browser driver.quit();
You’ll see the IE Browser launching and open the URL, printing the Page Title in the console and finally closing the IE instance.
Congratulation!!! You’ve successfully opened the browser instance, now what we’ll do is the Selenium actions on the browser. we’ll look into that in next section.