How To Handle SSL Certificate Error In IE Browser For Selenium WebDriver Test

Earlier we learnt how to handle SSL certificate error by creating custom profile In selenium WebDriver software test when you run It In Firefox browser as described In THIS POST. IE browser do not have any such feature to create and run software test In custom profile. So you need to do something different for IE browser to resolve certificate related error when you run WebDriver software automation test.
As you know, we can resolve error "Enable protected mode for all zones" as described In THIS POST and Set IE browser Zoom Level To 100% Error as described In previous post. Now let's see how to resolved SSL certificate error In IE browser for selenium WebDriver software automation test.

When you see SSL certificate error In IE browser, Your screen will looks like bellow.


There Is one option link with text "Continue to this website (not recommended)." If somehow we can click on this link then original software website page will be loaded and our test script can go further for execution. If you view link In HTML mode using F12 then you will realize that link has ID called "overridelink". We can click on that link using driver.navigate() method with Javascript as bellow.

//To click on "Continue to this website (not recommended)." link to load original website.
driver.navigate().to("javascript:document.getElementById('overridelink').click()");

This solution Is worked for me In many website's tests. Full example demonstration Is as bellow.

package Testing_Pack;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

public class SSLErrorInIE {

 public static void main(String[] args) {  
  
  // Set path of IEDriverServer.exe
  // Note : IEDriverServer.exe should be In D: drive.
  System.setProperty("webdriver.ie.driver", "D://IEDriverServer.exe");

  WebDriver driver = new InternetExplorerDriver();
  driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
  
  driver.get("URL of SSL error site");
  
  //To click on "Continue to this website (not recommended)." link to load original website.
  driver.navigate().to("javascript:document.getElementById('overridelink').click()");
 }
}

This way we can resolve SSL certificate error In IE browser. View THIS ARTICLE to know how to handle SSL cretificate error in google chrome browser.

No comments:

Post a Comment