问题描述
我使用selenium webdriver for firefox的C#项目。在我用NuGet包管理器安装最新的webdriver(2.40)之后,发生这个错误:
I'm using selenium webdriver for firefox on C# project. After I installed the latest webdriver (2.40) with NuGet Package manager this error occurred:
我的代码:
FirefoxProfile profile = new FirefoxProfile();
profile.SetPreference("browser.download.manager.showWhenStarting", false);
webdriver = new FirefoxDriver(profile);
第二行出现错误。
你知道如何解决这个问题吗?
The error is raised on the second line.Do you have any idea how this can be solved?
推荐答案
.NET绑定最近更新,其他语言绑定的行为,使用预设的配置文件设置列表,如果期望 FirefoxDriver
正常工作,其中一些不可更改。您尝试设置的偏好设置是这些冻结设置之一。它应该已经具有您尝试设置它的值。如果没有,驱动程序中可能会有一个错误。
The .NET bindings were recently updated to match the behavior of other language bindings, using a preset list of profile settings, some of which are not changeable if one expects the FirefoxDriver
to work properly. The preference you're attempting to set is one of those "frozen" settings. It should already have the value you're attempting to set it to. If it doesn't, there may be a bug in the driver.
您可以验证设置是否已经是您想要的,但查看异常详细信息:
You can verify that the setting is already what you desire, but looking at the exception details:
示例:
profile.SetPreference("network.http.phishy-userpass-length", 255);
会抛出错误:
意味着冻结值已经是正确的, SetPreference()
。
Meaning the frozen value would already be correct, and that SetPreference()
can be removed.
这篇关于browser.download.manager.showWhenStarting可能不会被覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!