Handling untrusted SSL certificates in different browsers using Selenium?

0 votes
Jun 3, 2019 in Selenium by Ishita
2,706 views

2 answers to this question.

+1 vote
Best answer

Hi Ishita, you can handle untrusted SSL certificates in different browsers by using these code snippets:

  1. In Chrome Browser:

    •  // Create object of DesiredCapabilities class
      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);
  2. In Internet Explorer:

    • // 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);
  3. In Safari:

    • // Create object of DesiredCapabilities class
      
      DesiredCapabilities cap=DesiredCapabilities.safari();
      
      // Set ACCEPT_SSL_CERTS  variable to true
      cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
      
      // Set the driver path
      System.setProperty("webdriver.safari.driver","Safari driver path");
      
      // Open browser with capability
      WebDriver driver=new SafariDriver(cap);
answered Jun 3, 2019 by Abha
• 27,930 points

selected Jul 8, 2019 by Abha

Hi, help me, Already implement untrusted SSL certificates for  Chrome Browser, but continues failed. 

Someone, Who can guide me for the solution?

Thanks,

Hey @catalina, Have you tried Abha's solution for chrome browser? What is the error you are facing?
0 votes

Hey Ishita, you can also handle SSL certificate for Firefox by using follow lines of code:

FirefoxProfile profile=new FirefoxProfile();

profile.setAcceptUntrustedCertificates(true);

WebDriver driver=new FirefoxDriver(profile);

driver.get("www.123movies.sc");
answered Jul 8, 2019 by Anvi
• 14,090 points
We dont have FirefoxDriver(FirefoxProfile) constructor

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer

Handling pop up in Chrome using Selenium WebDriver

AutoIt Window Information Tool do not recognize ...READ MORE

answered Jun 11, 2018 in Selenium by Meci Matt
• 9,460 points
1,312 views
0 votes
1 answer

How can I refresh a browser window in different ways using Selenium Webdriver?

Hello Piyush, you can refresh a browser ...READ MORE

answered May 28, 2019 in Selenium by Anvi
• 14,090 points
1,025 views
+1 vote
1 answer

In selenium Can we interact with browsers directly without using browsers web drivers like codedui

As per my understanding of your query, ...READ MORE

answered Aug 20 in Selenium by Sirajul
• 57,880 points
67 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,510 points
3,512 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31 in Selenium by Sri
• 2,970 points
4,514 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,890 points
2,585 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 2 in Selenium by Sri
• 2,970 points
2,841 views
0 votes
1 answer
0 votes
2 answers

How can we take screenshots of tests in Selenium 2 using C#

Hey, try using following code command to ...READ MORE

answered Aug 22, 2019 in Selenium by Abha
• 27,930 points
321 views