0

Windowsマシンでセレンサーバー2.28を使用しています。ハブとノードをセットアップしました。私は.netを使ってテストケースを書いています。次のコードを使用して、ユーザー エージェントを (iPhone に) 変更したカスタム FireFox (17.0.1) プロファイルを使用しています。

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

プリファレンスは正しく設定されています。何か不足していますか?

4

2 に答える 2

2

私は現在、非常に似たようなことをしようとしています(Windows認証を使用するようにFirefoxを設定しています)。

これを機能させるための私の(やや限定された)実験では、を使用するprofileとローカルドライバーインスタンスで機能しますが、SeleniumServerと通信する場合は機能しません。ここでprofile.ToBase64String()ヒントとして使用することで、プロファイルをSeleniumServerに渡すことができます。

于 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 に答える