Protractor - invalid SSL certificate

為{幸葍}努か 提交于 2019-12-23 10:09:34

问题


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.


回答1:


This works for me, (in conf file):

capabilities: {
    browserName : 'firefox',
    marionette : true,
    acceptInsecureCerts : true
}

Hope that helps.




回答2:


try

webdriver-manager update --ignore_ssl

or configure protractor.conf.js for firefox

var makeFirefoxProfile = function(preferenceMap) {
    var profile = new FirefoxProfile();
    for (var key in preferenceMap) {
        profile.setPreference(key, preferenceMap[key]);
    }
    return q.resolve({
        browserName: 'firefox',
        marionette: true,
        firefox_profile: profile
    });
};

exports.config = {
    seleniumAddress: 'http://localhost:4444/wd/hub',
    framework: 'jasmine2',
    getMultiCapabilities: function() {
        return q.all([
            makeFirefoxProfile(
                {
                    'browser.acceptSslCerts': true
                }
            )
        ]);
    },
}



回答3:


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);
    });
}


来源:https://stackoverflow.com/questions/47770336/protractor-invalid-ssl-certificate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!