【问题标题】:How to disable Insecure Password Warning in Firefox using Selenium Webdriver with Java如何使用 Selenium Webdriver 和 Java 在 Firefox 中禁用不安全密码警告
【发布时间】:2017-06-16 06:51:12
【问题描述】:

我是 Selenium Webdriver 的新手。我正在尝试在 Firefox 中测试我的应用程序登录页面。每次这样做时,我都会收到不安全的密码警告(此连接不安全。此处输入的登录名可能会被盗用)。

这是在输入密码时出现的。如何使用 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

【问题讨论】:

  • 请确保您使用的是最新的 Firefox。
  • 我使用的是 FF 53.0.3
  • @Payel IMO 你在这里搞砸了 2 分 insecure password warningconnection is not secure。您可以考虑用您的确切手动步骤和 URL 更新我们吗?谢谢
  • 谢谢。大概吧。实际上我只搜索了不安全的密码警告并尝试了所有可能的解决方案,但没有任何效果。因此我在这里....我要做的是自动化登录页面(上面附上的屏幕截图)。输入密码后,我收到上述警告,隐藏登录按钮。所以我的测试用例失败了,而不是点击登录按钮,而是点击了解更多警告。我想在 selenium 中找到一些方法,这样这个密码警告就不会出现在 FF 窗口中。我的脚本在 chrome 和 IE 中运行正常。

标签: java selenium firefox webdriver


【解决方案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 手动更改的值,输入 about:config 并找到相同的选项。 它帮助我的测试避免了不安全的登录消息。

【讨论】:

    【解决方案2】:

    尝试创建如下所示的 Firefox 配置文件,

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

    【讨论】:

    • 谢谢...但它没有用...仍然会在输入密码时发出警告。
    【解决方案3】:

    执行此操作的 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();
    

    【讨论】:

      【解决方案4】:

      如果我是对的,我认为有一种方法可以使用 selenium 来实现: 这种性质的东西;

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

      虽然不太确定!但请试一试!

      【讨论】:

        【解决方案5】:

        在 Java 中这对我有用

        FirefoxProfile fp = new FirefoxProfile();
        fp.setPreference("security.insecure_field_warning.contextual.enabled", false);
        

        【讨论】:

          猜你喜欢
          • 2018-01-21
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2012-07-25
          • 2013-04-04
          • 1970-01-01
          • 2013-05-28
          相关资源
          最近更新 更多