Handling untrusted SSL certificates in different browsers using Selenium?

0 votes
Jun 3 in Selenium by Ishita
144 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 by Abha
• 22,870 points

selected Jul 8 by Abha
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 by Anvi
• 12,840 points

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,420 points
634 views
0 votes
1 answer
0 votes
1 answer

How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,090 points
1,962 views
0 votes
1 answer

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,090 points
549 views
0 votes
1 answer
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,130 points
882 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
546 views
0 votes
1 answer
0 votes
2 answers