2017-05-30 20 views
0

的Firefox版本如何更改Firefox的配置偏好字段JAVA像“security.insecure_field_warning.contextual.enabled”

53.0(32位)

3.4.0

ProfilesIni profile = new ProfilesIni(); 
    FirefoxProfile firefoxProfile = profile.getProfile("Selenium"); 

    firefoxProfile.setPreference("security.insecure_field_warning.contextual.enabled", false); 

的问题是第三行什么都不做。 如果我在about:config中将security.insecure_field_warning.contextual.enabled设置为false,则此更改不会保存在配置文件中。

如何将其设置为falsecodejava

我看到类似的话题,但它在Python

显然security.insecure_field_warning.contextual.enabledabout:configFirefox

+0

您可以考虑通过简单的方式将'security.insecure_field_warning.contextual.enabled'设置为'false'来更新我们正在尝试做什么?谢谢 – DebanjanB

+0

@DebanjanB这是一个来自Firefox的设置,目前约在:config ,我想禁用它 – yami

+0

我的问题是具体的,你为什么要'禁用'它?什么是禁用它的实现?我如何测试我的代码是否真的禁用?谢谢 – DebanjanB

回答

1

这里设定的是回答你的问题:

工作虽然与硒3.4.0与geckodriver v.0.16.1 & Mozilla Firefox浏览器53.x到从现有的Firefox配置文件开始,security.insecure_field_warning.contextual.enabled设置为false您需要指定("security.insecure_field_warning.contextual.enabled", false)setPreference并且接下来您需要将Firefox配置文件通过欲望dCapabilities类。

这里是工作的代码块,设置"security.insecure_field_warning.contextual.enabled"false在Firefox浏览器:

System.setProperty("webdriver.gecko.driver", "C:\\your_directory\\geckodriver.exe"); 
    ProfilesIni profile = new ProfilesIni(); 
    FirefoxProfile testprofile = profile.getProfile("debanjan"); 
    testprofile.setPreference("security.insecure_field_warning.contextual.enabled", false); 
    DesiredCapabilities dc = DesiredCapabilities.firefox(); 
    dc.setCapability(FirefoxDriver.PROFILE, testprofile); 
    dc.setCapability("marionette", true); 
    WebDriver driver = new FirefoxDriver(dc); 
    driver.manage().window().maximize(); 

让我知道如果这个回答你的问题。

+0

我尝试了很多次,它的工作。但现在更少的代码**似乎也可以工作 - 这很奇怪。谢谢 – yami

+0

@yami很高兴它适合你。如果您需要帮助,请告诉我。谢谢 – DebanjanB