2017-03-17 68 views
0

我需要使用PhantomJS爲使用https的站點運行量角器測試。這是一個開發環境,證書是自簽名的,PhantomJS不承認。我用--ignore-ssl-errors標誌啓動PhantomJS,它應該使它接受無效的證書,但這不起作用。在CLI:通過HTTPS的PhantomJS

phantomjs --webdriver=localhost:4444 --web-security=false --ignore-ssl-errors=true --ssl-protocol=any

儘管這些設置,webdriver的的acceptSslCerts屬性仍設置爲false。從日誌:

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"}}

在相關GhostDriver回購問題(https://github.com/detro/ghostdriver/pull/388)下面的代碼所示:

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

我試着在protractor.conf.js設置此:

capabilities: { browserName: 'phantomjs', 'webdriver.Capability.ACCEPT_SSL_CERTS': true, 'webdriver.Capability.SECURE_SSL': false }

但這沒有效果。

有沒有人想過如何在https模式下運行PhatomJS?

回答

2

我目前面臨同樣的問題。試過了你所說的所有替代品,似乎沒有任何工作。

只有實際工作(不可行到我的項目,但也許對你的)事情是實例化的webdriver經過service_args象下面這樣:

的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']) 

希望它可以幫助你更多比幫助我。