0

我在 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);

当我about:config在节点机器上检查 firefox 实例时,我根本看不到 general.useragent.override 首选项。如果我使用:

driver = new FirefoxDriver(profile); 

首选项设置正确。我错过了什么吗?

4

2 回答 2

2

我目前正在尝试做一些非常相似的事情(将 Firefox 设置为使用 Windows 身份验证)。

在我的(有些有限的)实验中,使用 justprofile将与本地驱动程序实例一起工作,但在与 Selenium Server 交谈时却不行。我可以使用这里profile.ToBase64String()提示的方式将配置文件传递给 Selenium Server 。

于 2013-01-11T20:11:28.553 回答
0

以下是如何使用 Python 在 Grid 2 中传递用户代理。如果您不想要代理,只需将其删除。

    myProxy = IP:PORT
    proxy = Proxy({
        'proxyType': ProxyType.MANUAL,
        'httpProxy': myProxy,
        'ftpProxy': myProxy,
        'sslProxy': myProxy,
        'noProxy': '' # set this value as desired
        })

    desired_capabilities = webdriver.DesiredCapabilities.FIREFOX.copy()   
    browser_profile = webdriver.FirefoxProfile()          
    browser_profile.set_preference("general.useragent.override", 'USERAGENT' )           
    desired_capabilities["firefox_profile"] = browser_profile.update_preferences() 
    driver = webdriver.Remote(   command_executor='http://IPADDRESS:4444/wd/hub',desired_capabilities=desired_capabilities, browser_profile=browser_profile, proxy = proxy) 

希望有帮助

于 2014-05-24T22:54:57.953 回答