Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to automatically accept SSL certs in chrome?

Its been a while I'm trying to figure out a way to automatically accept SSL certs. But unfortunately no luck. So, here is the case, I'm working on selenium tests. And, every time when I run the test on chrome, a small pop-up appears asking to select a certificate.

I tried this in python: How to deal with certificates using Selenium?

I also tried (in javascript): var options = new chrome.Options();
options.addArguments("--ignore-certificate-errors")

But it doesn't seems to work!

In firefox, there is an option to automatically selects certs. Is there any way in selenium or in chrome settings which automatically selects the certs? Will ENTER/RETURN keys in selenium work?

EDITED: Below is my code. Is this the right way to use?

var launch = function(){
var options = new chrome.Options();
options.addArguments("--test-type"); 
/* Also tried options.addArguments(“--ignore-certificate-errors")
*/
var driver = new webdriver.Builder()
.usingServer('http://127.0.0.1:4444/wd/hub')
.setChromeOptions(options)
.build();
driver.get(url)
}

P.S Here, I'm using JavaScript.

like image 418
Dana Avatar asked Nov 16 '15 20:11

Dana


2 Answers

ACCEPT_SSL_CERTS is one of the browser's desired capability that tells the browser to accept / deny ssl certificates by default.

below is a sample code for accepting SSL certificates in chrome:

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);
like image 109
Navpreet Singh Avatar answered Sep 20 '22 12:09

Navpreet Singh


It is major problem with Chrome versions above v.80. I am currently using version 84.0.4147.105 which won't accept or ignore SSL certificate. The one thing to do is to downgrade Chrome version below v.80, especially for those of you who are building test cases in local Host applications.

like image 36
kilo_bravo_delta Avatar answered Sep 18 '22 12:09

kilo_bravo_delta