Selenium, Selenium grid, Testing

How to deal with Internet Explorer issues to make it work via Selenium.

To err is human, well said.

I have been traversing over web what all new things I can explore and share knowledge about, but I can never deny the fact that there is a lot which I can share and talk about. Today I will share how Selenium faces problem  while connecting with Internet Explorer. Lets get started then.

How to use Internet Explorer?

Selenium provided support to Firefox, by default. This is something which the Selenium-creators have done to make our life easier while working with FireFox. Now, how about browsers other than default. Of-course, they understand that Web-UI testing can not be said as completed if it is not tested well on multiple browsers.

For testing your application on Internet Explorer via Selenium, you need to add the internetExplorer.exe into your project. And use this for the invocation of the browser,like this:


public void initDriver(){
try{
if(Property.IsRemoteExecution.equalsIgnoreCase("true")){
String remoteURL;
DesiredCapabilities capabilities = new DesiredCapabilities();
if(Property.RemoteURL.toLowerCase().contains("saucelabs")){
//set all saucelab capabilities here.
}
remoteURL = Property.RemoteURL + "/wd/hub";

URL uri = new URL(remoteURL);
if(browserName.equalsIgnoreCase("firefox")){
FirefoxProfile remoteProfile = new FirefoxProfile();
remoteProfile.setPreference("webdriver_assume_untrusted_issuer", false);
remoteProfile.setAcceptUntrustedCertificates(true);
remoteProfile.setEnableNativeEvents(false);
capabilities.setBrowserName("firefox");
capabilities.setCapability("firefox_profile", remoteProfile.toString().toString());
driver = new RemoteWebDriver(uri, capabilities);
}
else if(browserName.equalsIgnoreCase("internetexplorer")){
capabilities.setBrowserName("internet explorer");
capabilities.setCapability("ignoreProtectedModeSettings", true);
driver = new RemoteWebDriver(uri,capabilities);
}

}
else{
if(browserName.equalsIgnoreCase("firefox")){
FirefoxProfile ffprofile = new FirefoxProfile();
ffprofile.setPreference(
"webdriver_assume_untrusted_issuer", "false");
driver = new FirefoxDriver(ffprofile);
}
else if(browserName.equalsIgnoreCase("internetexplorer")){
DesiredCapabilities iecapabilities = DesiredCapabilities
.internetExplorer();
iecapabilities.setCapability("ignoreProtectedModeSettings",
"true");
iecapabilities
.setCapability(
InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
"true");
driver = new InternetExplorerDriver(iecapabilities);
}

driver.manage().window().maximize();
}
catch (Exception e) {
System.out.println(e.getMessage());
}
}

How can Selenium Webdriver makes it comfortable with Internet Explorer?

Selenium uses the added executable for driving all the browser invocations and here-forth it takes all the details from the selenium-standalone.jar which should also be placed in your project build path.

In this flow, what happens is Selenium interacts with IE driver, which further makes all mimicry at the browser level.

What is the issue? How to get it resolved?

The issue is no where, but there is some changes which you need to make sure if you want to execute your scripts on IE. For that you need to set your browser security mode to the protected mode, like this:

InterNetExplorerProtectedMode

 

This should be done for all four areas:

  1. Internet Local
  2. Internet.
  3. Trusted sites.
  4. Restricted sites.

Also, if you want to work with Selenium grid then there are some other issues which you need to tackle.

  1. You can not 2 instances of IE at one time.
  2. You can not apply same command to IE browser at one time. For example, if there is click command executing somewhere then, you have to wait for the executor to finish this step. Then only you can proceed working.

 

Where is the issue?

The issue is Internet Explorer requires some additional security set-up before the actual browser invocation. So that’s you as a user need to do while working with this browser. And that’s all.

Advertisements

5 thoughts on “How to deal with Internet Explorer issues to make it work via Selenium.”

  1. Hi, It’s simple to map the “IEDriverServer” folder path in system – Environment varialbe , instead of using system capabilties. It works fine for me. Then , use
    internetexplorer driver=new internetexplorer ()
    driver.manage().window().maximize();
    driver.get(“specify the url”)

    Like

  2. It is appropriate time to make some plans for the future and it’s time to be happy.
    I’ve read this post and if I could I desire to suggest you few innteresting
    things or tips. Perhaps you can write next articles referring to this article.
    I wish to read more things about it!

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s