Handling Security Certificates in Chrome and IE browser using WebDriver

Previous tutorial we have seen how to handle SSL Certificates in Firefox driver, now here we will see how to handle the same in chrome driver and IE browser.

As we know SSL is mainly used to keep sensitive information encrypted when sending across the Internet, which is important because, the information that we send on the internet is passed by connecting with multiple systems to the destination server. You can know more info on this here .Different SSL certificate Errors

This is how the error looks like :

handle SSL certificates with selenium

Let us now see the example :

package com.example;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class SSLExample_Chrome {

	private WebDriver driver;

	public void setUp() {
		DesiredCapabilities capability = DesiredCapabilities.chrome();
		// To Accept SSL certificate
		capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
		// setting system property for Chrome browser
		System.setProperty("webdriver.chrome.driver", "E:/chromedriver.exe");
		// create Google Chrome instance and maximize it
		driver = new ChromeDriver(capability);

	public void openApplication() {
		System.out.println("Navigating application");
		WebElement headingEle = driver.findElement(By.cssSelector(".story h3"));
		// Validate heading after accepting untrusted connection
		String expectedHeading = "Are you new to CAcert?";
		Assert.assertEquals(headingEle.getText(), expectedHeading);

	public void tearDown() {
		if (driver != null)

Unlike handling SSL certificates in firefox and chrome browser are different when it comes to IE. In IE browser, we may have to handle it using javascript like like below :

System.setProperty("webdriver.ie.driver", "D:/IEDriverServer.exe");
driver = new InternetExplorerDriver();

Happy selenium.

Hope this tutorial helps you.

Selenium Tutorials: 


Hi, There are so much good and informative articles on http://www.seleniumeasy.com that I have keep coming again and again.
And I just want to thank you....guys....

Add new comment

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.