We have an application and testing this locally shows an invalid SSL certificate warning. Normally I would just add an exception and get on with it. However is there anyway for protractor to ignore this?
I've seen some capabilities in selenium where SSL can be ignored but can't seem to find any in protractor.
EdgeOptions ssl = new EdgeOptions(); -- Object of EdgeOptions is created. ssl. setAcceptInsecureCerts(true); -- Insecure certificates are accepted by using Boolean true as an argument. WebDriver driver = new EdgeDriver(ssl); -- The options now pass to the WebDriver instance to start with the desired settings.
setProperty("webdriver. ie. driver","IEDriverServer.exe"); WebDriver driver = new InternetExplorerDriver(capabilities); The above code will help to handle SSL certificate error in IE.
New Selenium IDE A SSL is the standardized protocol used to create a connection between the browser and server. The information exchanged via a SSL certificate is encrypted and it verifies if the information is sent to the correct server. It authenticates a website and provides protection from hacking.
To serve an Angular app locally with SSL we have to use the options --ssl , --ssl-key and --ssl-cert together with ng serve . Hence, after generating the local certificate authority and ssl certificate we have to set the sslKey and sslCert environment variables to the path of the certificate and key files.
This works for me, (in conf file):
capabilities: {
browserName : 'firefox',
marionette : true,
acceptInsecureCerts : true
}
Hope that helps.
capabilities: {
browserName: 'chrome',
chromeOptions: {
// for ci test
args: ['--headless', 'no-sandbox', "--disable-browser-side-navigation",
"--allow-insecure-localhost"
/// for https sites: ignore ssl on https://localhost...
/// further args please see https://peter.sh/experiments/chromium-command-line-switches/
]
}
}
maybe you want to take some screenshots to test where the error occurs
import fs from 'fs';
function writeScreenShot(data, filename) {
const stream = fs.createWriteStream(filename);
stream.write(new Buffer(data, 'base64'));
stream.end();
}
export function takeScreenshot(browser, path){
browser.takeScreenshot().then((png) => {
writeScreenShot(png, path);
});
}
But for the long run, I would suggest migrating to cypress (https://www.cypress.io/), because it have many other features out of the box: video, screenshot, etc. And believe me, it is worth it ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With