Reputation: 111
I need to run Protractor tests using PhantomJS for a site using https. It's a development environment, the certs are self-signed and are not recognized by PhantomJS. I'm starting PhantomJS with the --ignore-ssl-errors flag, which supposed to make it accept invalid certs, but this isn't working. In CLI:
phantomjs --webdriver=localhost:4444 --web-security=false --ignore-ssl-errors=true --ssl-protocol=any
In spite of these settings, the acceptSslCerts property of the webdriver is still set to false. From the logs:
Session.negotiatedCapabilities - {"browserName":"phantomjs","version":"2.1.1","driverName":"ghostdriver","driverVersion":"1.2.0","platform":"mac-unknown-64bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"databaseEnabled":false,"locationContextEnabled":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,"acceptSslCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"}}
In a relevant GhostDriver repo issue (https://github.com/detro/ghostdriver/pull/388) the following code is listed:
const capabilities = webdriver.Capabilities.phantomjs();
capabilities.set(webdriver.Capability.ACCEPT_SSL_CERTS, true);
capabilities.set(webdriver.Capability.SECURE_SSL, false);
capabilities.set('phantomjs.cli.args', ['--web-security=no', '--ssl-protocol=any', '--ignore-ssl-errors=yes']);
const driver = new webdriver.Builder().withCapabilities(webdriver.Capabilities.chrome(), capabilities).build();
I tried setting this in protractor.conf.js:
capabilities: {
browserName: 'phantomjs',
'webdriver.Capability.ACCEPT_SSL_CERTS': true,
'webdriver.Capability.SECURE_SSL': false
}
but this has no effect.
Has anyone figured out how to run PhatomJS in https mode?
Upvotes: 0
Views: 1936
Reputation: 61
I'm currently facing the same problem. Tried all alternatives you told and nothing seems to work.
Only thing that actually worked (not viable to my project, but maybe for yours) was to instantiate the webdriver passing the service_args like below:
Python:
webdriver.PhantomJS(executable_path='/home/rodrigo/bin/phantomjs-2.1.1-linux-x86_64/bin/phantomjs',
desired_capabilities=dict(DesiredCapabilities.PHANTOMJS),
service_args=['--web-security=no', '--ssl-protocol=any', '--ignore-ssl-errors=yes'])
Hope it helps you more than helped me.
Upvotes: 2