Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/45.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用SeleniumWebDriver和Java禁用Firefox中的不安全密码警告_Java_Selenium_Firefox_Webdriver - Fatal编程技术网

如何使用SeleniumWebDriver和Java禁用Firefox中的不安全密码警告

如何使用SeleniumWebDriver和Java禁用Firefox中的不安全密码警告,java,selenium,firefox,webdriver,Java,Selenium,Firefox,Webdriver,我是SeleniumWebDriver的新手。我试图在Firefox中测试我的应用程序登录页面。每次这样做时,我都会收到不安全的密码警告(此连接不安全。在此输入的登录可能会受到影响) 当输入密码时,这将出现。如何在使用Java的SeleniumWebDriver中禁用该功能 目前我正在使用此代码: System.setProperty("webdriver.gecko.driver", driverPathFF); DesiredCapabilities capabilities = new

我是SeleniumWebDriver的新手。我试图在Firefox中测试我的应用程序登录页面。每次这样做时,我都会收到不安全的密码警告(此连接不安全。在此输入的登录可能会受到影响)

当输入密码时,这将出现。如何在使用Java的SeleniumWebDriver中禁用该功能

目前我正在使用此代码:

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);
但这没有帮助。我也尝试了在相关的谷歌搜索中找到的其他方法,但没有成功

请检查链接以供参考。

尝试创建如下firefox配置文件:

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

您可以尝试使用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并查找相同选项来手动更改的值。
它帮助我的测试避免了不安全的登录消息。

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

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

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

不过我不太确定!但只要试一下

在Java中,这对我很有用

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

请确保您使用的是最新的Firefox。我使用的是FF 53.0。3@Payel在我看来,您在这里弄乱了两点
不安全密码警告
连接不安全
。你能考虑用你的手动步骤和URL更新我们吗?谢谢你。我想是的。实际上,我只搜索了不安全的密码警告,并尝试了所有可能的解决方案,但没有任何效果。因此,我在这里…我正在尝试做的是自动登录页面(屏幕截图附在上面)。输入密码后,我得到了上面的警告,隐藏了登录按钮。所以我的测试用例失败了,它不是点击登录按钮,而是点击了解更多警告。我想在selenium中找到一些方法,这样这个密码警告就不会出现在FF窗口中。我的脚本在chrome和IE中正常运行。谢谢你们…但它并没有工作…尽管如此,只要输入密码,就会发出警告。