Launch SELENIUM IE (Internet Explorer) / Edge Browser:
1. Launch IE (Internet Explorer) Browser:
- WebDrivers for different browsers like: FirefoxDriver() for Firefox browser, ChromeDriver() for Google Chrome, SafariDriver() for Safari Browser, InternetExplorerDriver for Internet Explorer etc.
- Webdriver is an Interface and InternetExplorerDriver() is a class which has implemented Webdriver Interface.
- WebDriver is an interface which contains all the unimplemented common methods, which can be used for any browser e.g. getTitle(), getCurrentUrl(), get(), findElement() etc.
Download IEDriverServer.exe:
- The Internet Explorer driver needs the installation of “webdriver.ie.driver” property with the location of IEDriverServer.exe.
- IEDriverServer.exe could be downloaded here.
- Choose IEdriver server based on your work environment because there are two separate zip files for both 32 and 64 bit IE.
- 32-bit driver has been recommended, which is less than errors compared to the 64-bit driver to launch IE (Internet Explorer).
Launching IE Explorer Browser:
1 2 3 4 5 | // Setting the webdriver.ie.driver property to its location System.setProperty("webdriver.ie.driver", "Path_IEDriverServer.exe"); //Creating a driver object referencing WebDriver interface WebDriver driver = new InternetExplorerDriver(); |
Example Launching IE Explorer Browser:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | // Importing Packages import org.openqa.selenium.WebDriver; import org.openqa.selenium.ie.InternetExplorerDriver; public class InternetExplorerDriver{ public static void main(String[] args) { // Set IEDriverServer path System.setProperty("webdriver.ie.driver","D:\\IEDriverServer.exe"); // Creating a driver object referencing WebDriver interface WebDriver driver=new InternetExplorerDriver(); driver.get("https://www.stqatools.com"); System.out.println("Title is :-"+driver.getTitle()); // Close IE Browser driver.close(); } } |
Output:
1 | Title is :- Software Testing Quality Automation Tutorials |
Points while working with IE browser in Selenium:
- The IE browser is slower than other browsers.
- Your browser zooming level must be set to 100% otherwise, you will get an exception.
- You must also check your security settings in IE when you turn on the IE browser in the Selenium, all your areas should be enabled or disabled.
- If not then you will get an exception and your test case will fail.
2. Launch Edge Browser:
- Make sure you have Windows 10 on your machine and download the specified Microsoft WebDriver server version for your build.
- You can download the latest version of Download Microsoft Edge Driver Go to this Link.
Example of Launch Edge Browser:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | import org.openqa.selenium.WebDriver; import org.openqa.selenium.edge.EdgeDriver; public class While_Java { public static void main(String[] args) { // Set the driver path System.setProperty("webdriver.edge.driver", "C://MicrosoftWebDriver.exe"); // Start Edge Session WebDriver driver = new EdgeDriver(); driver.get("https://stqatools.com"); driver.quit(); } } |