Accept Insecure Certificates

Whenever you work with self-signed certificates or some server with a stale/untrusted certificate, most modern browsers display a security warning or invalid certificate errors.

To avoid these warnings and errors while running your automated tests on BrowserStack, use the acceptSslCerts capability.

Capability Description Expected values
acceptSslCerts Accept all SSL certificates A boolean. Default is False.
True if you want to accept all SSL certificates.
Warning: While testing on the Safari browser or on iOS devices, if you want to navigate to a page in the middle of the test which has an invalid certificate, you have to also use the acceptSsl JavascriptExecutor (shown below) along with acceptSslCerts capability, to execute the test in a hassle-free manner.

JavascriptExecutor to accept insecure certificates

While executing Automate Test on Safari browser or iOS devices that take you to the stale/untrusted certificate webpage through navigation commands such as click action, Javascript navigation, etc. this acceptSsl JavascriptExecutor will be required along with acceptSslCerts capability to execute the test.

Note: This JavascriptExecutor code must be executed after the stale/untrusted certificate webpage is loaded.

Following is the code snippet to use JavascriptExecutor to accept insecure certificates on Safari browser or iOS devices:

driver.findElement(By.id(some-element)).click();
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("browserstack_executor:  {\"action\": \"acceptSsl\"}");
driver.findElement(webdriver.By.id('some-element')).click().then(function(){
  driver.executeScript("browserstack_executor: {\"action\": \"acceptSsl\"}").then(function()});
});
driver.FindElement(By.id("some-element")).Click();
((IJavaScriptExecutor)driver).ExecuteScript("browserstack_executor: {\"action\": \"acceptSsl\"}");
$web_driver->findElement(WebDriverBy::id("some-element"))->click();
$web_driver->executeScript('browserstack_executor: {"action": "acceptSsl"}');
driver.find_element_by_id("some-element").click()
driver.execute_script('browserstack_executor: {"action": "acceptSsl"}')
caps["javascriptEnabled"]=true #Set `javascriptEnabled` capability to `true`
driver.find_element(:id, "some-element").click()
driver.execute_script('browserstack_executor: {"action": "acceptSsl"}')
$driver->find_element_by_id("some-element")->click('LEFT');
$driver->execute_script('browserstack_executor: {"action": "acceptSsl"}');

We're sorry to hear that. Please share your feedback so we can do better






Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback