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:

JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("browserstack_executor:  {\"action\": \"acceptSsl\"}");
  driver.executeScript("browserstack_executor: {\"action\": \"acceptSsl\"}").then(function()});
((IJavaScriptExecutor)driver).ExecuteScript("browserstack_executor: {\"action\": \"acceptSsl\"}");
$web_driver->executeScript('browserstack_executor: {"action": "acceptSsl"}');
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->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