Handling untrusted SSL certificates in different browsers using Selenium?

0 votes
Jun 3 in Selenium by Ishita
82 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
• 15,320 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
• 9,830 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,400 points
527 views
0 votes
1 answer
0 votes
1 answer

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

We can take screenshots using below function ...READ MORE

answered Mar 23, 2018 in Selenium by nsv999
• 5,050 points
129 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,050 points
245 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
616 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
234 views
0 votes
1 answer
0 votes
1 answer

What are locators in Selenium and what are the different types of it?

Hi Divya, in Selenium Locators define an ...READ MORE

answered May 7 in Selenium by Abha
• 15,320 points
51 views