2017-06-16 52 views
0

我是Selenium Webdriver的新手。我正試圖在Firefox中測試我的應用程序登錄頁面。每次這樣做時,我都會收到不安全的密碼警告(此連接不安全,此處輸入的登錄信息可能會受到影響)。如何在Firefox中使用Selenium Webdriver禁用Java中的不安全密碼警告

輸入密碼時即將到來。如何禁用使用Java的selenium Webdriver?

目前我使用此代碼:

System.setProperty("webdriver.gecko.driver", driverPathFF); 
DesiredCapabilities capabilities = new DesiredCapabilities(); 
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); 
capabilities.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true); 
driver = new FirefoxDriver(capabilities); 

但它並沒有幫助。我嘗試了其他在相關谷歌搜索中找到的方式,但沒有運氣。

請檢查鏈接以供參考。 Sceenshot

+0

請確保使用最新的Firefox。 – Monika

+0

我正在使用FF 53.0.3 – Payel

+0

@Payel國際海事組織你搞亂了2點這裏'不安全的密碼警告'和'連接不安全'。您可以考慮使用您的確切手動步驟和網址更新我們嗎?謝謝 – DebanjanB

回答

0

嘗試創建Firefox配置文件,如下面的一個,

profile = new FirefoxProfile() 
profile.accept_untrusted_certs = True 
DesiredCapabilities dc = DesiredCapabilities.firefox(); 
dc.setCapability(FirefoxDriver.PROFILE, profile); 
WebDriver driver = new FireFoxDriver(dc); 
+0

謝謝你...但它不起作用......每當輸入密碼時都會發出警告。 – Payel

1

您可以嘗試使用Selenium的Firefox設置首選項。 例如,

var firefoxOptions = new FirefoxOptions(); 
firefoxOptions.SetPreference("security.insecure_password.ui.enabled", false); 
firefoxOptions.SetPreference("security.insecure_field_warning.contextual.enabled", false); 

它表示可以手動打開的Firefox,打字大約被改變的值:配置和尋找相同的選項。 它幫助我的測試避免了不安全的登錄消息。

0

這樣做的一個JavaScript的方式:

const {Builder} = require('selenium-webdriver'); 
const firefox = require('selenium-webdriver/firefox'); 

    var profile = new firefox.Profile(); 
    profile.setPreference("security.insecure_password.ui.enabled", false); 
    profile.setPreference("security.insecure_field_warning.contextual.enabled", false); 

    var options = new firefox.Options().setProfile(profile); 
    var browserUnderTest = new webdriver.Builder() 
    .forBrowser('firefox') 
    .setFirefoxOptions(options) 
    .build(); 
0

如果是正確的,我覺得有一種方法來實現,使用硒: 東西這種性質的;

var firefox = new FirefoxOptions(); 
firefox.SetPreference("security.insecure_password.ui.enabled", false); 

雖然不太確定!但只要一試!

相關問題