How to handle SSL certificate error using Selenium WebDriver?

SeleniumAutomation TestingTesting Tools

We can handle SSL certificate error using Selenium webdriver while we try to launch a web page based on HTTP. SSL certificate errors are encountered in multiple browsers like Chrome, Safari, and Firefox and so on.

SSL certificate error comes up if the site we are making an attempt to access has an outdated, invalid or an untrusted certificate. SSL or Secure Sockets Layer is a protocol followed to create a connection between the client (browser) and the server.

To handle the SSL certificate error we have to use the DesiredCapabilities class and then accept the SSL error by setting the ACCEPT_SSL_CERTS to true and applying this capability to the browser


DesiredCapabilities c=DesiredCapabilities.internetExplorer();
c.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);


import org.openqa.selenium.WebDriver;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
public class SSLError{
   public static void main(String[] args) {
      //DesiredCapabilities object
      DesiredCapabilities c=DesiredCapabilities.internetExplorer();
      //set SSL certificate to true
      c.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
      System.setProperty("", "C:\\Users\\ghs6kor\\Desktop\\Java\\IEDriverServer.exe");
      //configure capability to browser
      WebDriver driver = new InternetExplorerDriver(c);
      //implicit wait
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
      //URL launch
      driver.get("application url to be entered");
Published on 06-Apr-2021 15:21:35