Sunday, 27 October 2013

How to launch internet explorer browser using selenium webdriver in Java?

You can download the IE driver from the link - IEDriverServer supports 32 bit as well as 64 bit Internet Explorer.

Setting the driver parameters

Ensure that Server path is included in System PATH variable or set the property as shown below.

System.setProperty("", "F:\\selenium\\java\\iedriver.exe");

Other properties that we can set are given below.

Browser Settings

Ensure that Protected mode settings for all zones should be same and for IE10 and above, enhanced protected mode must be disabled and the browser zoom level must be set to 100%.

For IE 11 only, You will need to edit below registry keys.

For 32-bit Windows, the key is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE. For 64-bit Windows, the key is HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE.

Please note that the FEATURE_BFCACHE subkey is optional and and should be created if not present. Inside this key, you need to create a DWORD value with name = iexplore.exe and value = 0.

To clean IE Session

Ensure that you pass below capability - ie.ensureCleanSession with true value.

Example code to launch IE

You can use below example/code to start the new IE session in Java using selenium web driver.

package seleniumtest;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.Actions;

public  class MainTest {
       public static void main(String[] args) {
                 WebDriver driver =null;
                 System.setProperty("", "F:\\selenium\\java\\iedriver.exe");
                 driver = new InternetExplorerDriver();
                 driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS);
                 driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
                           Actions builder = new Actions(driver);

                           WebElement e = driver.findElement(By.cssSelector("#sk"));
                           //build the action chain.
                           Action doubleclick = builder.doubleClick(e).build();

                           //perform the double click action

              }catch(Exception e){
Please note that we need to set the system property
We have to give the path of IEdriver.exe
Once you have created driver object, you can use its methods to automated the browser tasks.
You can find more updated information here - instructions on IE configuration.

You may also like to read below topics.
  1. Press key in Selenium Webdriver in Java
  2. Read Table Data in Selenium Webdriver in Java
  3. Take the screenshot in Selenium Webdriver in Java
  4. Execute JavaScript in Selenium Webdriver in Java
  5. Handle multiple browser windows in Selenium Webdriver in Java
  6. Double-Click on the Element in Selenium Webdriver in Java
  7. Exceptions in Selenium Webdriver in Java
  8. Synchronization in Selenium Webdriver in Java

What do you think on above selenium topic. Please provide your inputs and comments. Thanks

No comments:

Post a Comment

Buy Best Selenium Books