Skip to main content
Experience faster, smarter testing with BrowserStack AI Agents. See what your workflow’s been missing. Explore now!
No Result Found
Get your setup working faster. Join our Discord for optimisation tips from elite testers. Join our DiscordJoin our Discord

Accept insecure certificates

Avoid invalid certificate warning while testing using self-signed or invalid certificates

Whenever you work with self-signed certificates or some server with a stale or 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 following capability.

Capability Description Expected values
acceptInsecureCerts Accept all SSL certificates A boolean. Default is False.
True if you want to accept all SSL certificates.

If you are using BrowserStack SDK, you can set the following capabilities in the configutation file:

browserstack.yml
Copy icon Copy

JavascriptExecutor for Safari browser and iOS devices

This section is only required if you are testing on Safari or iOS devices and navigating to a URL with invalid certificate in the middle of the test through navigation commands such as click action, Javascript navigation, etc. Under such scenario you have to use both the capability explained above and the Javascript executor shown below.

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 and on iOS devices:

driver.findElement(By.id(β€œsome-element”)).click();
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("browserstack_executor:  {\"action\": \"acceptSsl\"}");

Check our list of various JavaScript Executors that BrowserStack offers.

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

Test web and mobile, from manual to automation, on real devices in one unified platform.

Contact Us

Is this page helping you?

Yes
No

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!

Talk to an Expert
Download Copy Check Circle