2015-11-06 63 views
3

我正在使用硒測試Web應用程序。在這裏,我正在用Javascript編寫硒測試。但是我找不到一種自動化SSL證書驗收的方法。如何編寫腳本以接受SSL證書

使用the profile class我試圖做這樣的事情:

有什麼我失蹤?

無功配置=新firefox.Profile() profile.setAcceptUntrustedCerts(真)

VAR的選擇=新firefox.Options()。setProfile(配置文件)

VAR firefoxDriver =新的Web driver.Builder () .forBrowser( '火狐') .usingServer( 'http://127.0.0.1:4444/WD /集線器') .setFirefoxOptions(選項) .build()

firefoxDriver.get(URL)

但這似乎並不奏效。有什麼方法可以編寫一個bash腳本(我可以在我的測試中調用)還是在JavaScript中有任何其他方式接受SSL證書?

+0

可能重複[如何處理證書使用硒?](http://stackoverflow.com/questions/24507078/how-to-deal-with-certificates-using-selenium) – JeffC

+0

你如何通過配置文件到webdriver?你試過'檔案嗎? assumeUntrustedCertIssuer(真)'? – danielepolencic

+0

@danielepolencic profile.assumeUntrustedCertIssuer(true)不起作用?還有其他建議嗎? – Dana

回答

0

你試過這個嗎? profile.setAcceptUntrustedCertificates(真);

+0

您好,感謝您的回覆。我正在嘗試以下,但它不起作用。有什麼我失蹤? 無功配置=新firefox.Profile() profile.setAcceptUntrustedCerts(真) VAR的選擇=新firefox.Options()。setProfile(配置文件) VAR firefoxDriver =新的網絡driver.Builder() .forBrowser( 'firefox') .usingServer('http://127.0.0.1:4444/wd/hub') .setFirefoxOptions(options) .build() firefoxDriver.get(url) – Dana