【发布时间】:2013-01-07 21:28:08
【问题描述】:
我在 Windows 机器上使用 selenium server 2.28。我已经设置了集线器和节点。我正在使用 .net 编写我的测试用例。我正在使用以下代码来使用自定义 FireFox (17.0.1) 配置文件,并将用户代理更改为 iPhone。
FirefoxProfileManager profileManager = new FirefoxProfileManager();
FirefoxProfile profile = profileManager.GetProfile(FireFox_Profile_Name);
profile.SetPreference("general.useragent.override", _sUserAgent);
DesiredCapabilities capability = DesiredCapabilities.Firefox();
capability.SetCapability(FirefoxDriver.ProfileCapabilityName, profile);
我正在像这样实例化一个RemoteWebDriver 实例:
driver = new RemoteWebDriver(new Uri("hub_uri"), capability);
当我在节点机器上的 firefox 实例中检查 about:config 时,我根本看不到 general.useragent.override 首选项。如果我使用:
driver = new FirefoxDriver(profile);
首选项设置正确。我错过了什么吗?
【问题讨论】:
-
您是否也尝试从 webdriver 实例化的浏览器中查看 whatsmyuseragent.com 上的 useragent 值?只是为了确保..?
-
A.J,我刚刚检查了,用户代理没有改变。
标签: c# firefox selenium preference