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. |
acceptSsl
JavascriptExecutor (shown below) along with acceptSslCerts
capability, to execute the test in a hassle-free manner.
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.
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"}');
Contact our Support team for immediate help while we work on improving our docs.