How to Handle SSL Untrusted Connection in Selenium WebDriver ?

In this article, i will talk about how to handle SSL Untrusted connection in selenium webdriver.
Suggested Article to read: What is Firefox profile, Need of Firefox profile?

Handling SSL Untrusted Connection in Selenium WebDriver

Some applications have issues related to SSL certification error. We again do that manually by accepting & confirming the certificate. But again, what if this encounter when we automate application using selenium Webdriver?
Using profiles in Firefox we can handle accept the SSL untrusted connection certificate. Profiles are basically set of user preferences stored in a file.
Let’s consider the Firefox browser to create a new profile and set the following:
Handle Untrusted certificate (SSL Certificate error) in Firefox
FirefoxProfile profile = new FirefoxProfile();

profile.setAcceptUntrustedCertificates(true); 

profile.setAssumeUntrustedCertificateIssuer(false);

WebDriver driver = new FirefoxDriver(profile);

Handle Untrusted certificate (SSL Certificate error) in Chrome
To Handle SSL certification error in chrome, we need to Create object of DesiredCapabilities class. Basically, the DesiredCapabilities help to set properties for the WebDriver. The DesiredCapabilities class tells the Webdriver which environment we are going to use for test execution.
DesiredCapabilities cap=DesiredCapabilities.chrome();

// Set ACCEPT_SSL_CERTS  variable to true

cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);

// Set the driver path

System.setProperty("webdriver.chrome.driver","Chrome driver path");

// Open browser with capability

WebDriver driver=new ChromeDriver(cap);

Handle Untrusted certificate (SSL Certificate error) in IE

// Create object of DesiredCapabilities class

DesiredCapabilities cap=DesiredCapabilities.internetExplorer();

// Set ACCEPT_SSL_CERTS  variable to true

cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);

// Set the driver path

System.setProperty("webdriver.ie.driver","IE driver path");

// Open browser with capability

WebDriver driver=newInternetExplorerDriver(cap);

Hope this helps ….

Leave Comment

Your email address will not be published. Required fields are marked *

Looking for learning Framework Development from Scratch? Lookout for Detailed Framework Development videos on YouTube here -

https://www.youtube.com/automationtalks

Get the Framework code at Github Repo: https://github.com/prakashnarkhede?tab=repositories