- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to handle SSL certificate error using Selenium WebDriver?
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
Syntax
DesiredCapabilities c=DesiredCapabilities.internetExplorer(); c.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
Example
import org.openqa.selenium.WebDriver; import org.openqa.selenium.Capabilities; import org.openqa.selenium.ie.InternetExplorerDriver; 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("webdriver.ie.driver", "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"); } }
- Related Articles
- How does Selenium Webdriver handle SSL certificate in Firefox?
- How does Selenium Webdriver handle SSL certificate in Chrome?
- How does Selenium Webdriver handle the SSL certificate in Safari?
- How does Selenium Webdriver handle the SSL certificate in Edge?
- How to handle frame in Selenium WebDriver using java?
- How to handle windows file upload using Selenium WebDriver?
- How to handle authentication popup with Selenium WebDriver using Java?
- How to take care of SSL certificate issues in chrome browser in Selenium?
- How can I handle multiple keyboard keys using Selenium Webdriver?
- How can we handle authentication popup in Selenium WebDriver using Java?
- How to handle frames in Selenium Webdriver in Python?
- Handle Firefox Not Responding While Using Selenium WebDriver With Python?
- How can I verify Error Message on a webpage using Selenium Webdriver?
- What is the best way to handle a Javascript popup using Selenium Webdriver?
- How to get website SSL certificate validity dates with PowerShell?

Advertisements