2012-02-26 55 views
0

我尝试使用Firefox模板来指定prefs.js文件中的一些参数。 我用两种场景问题与配置文件模板硒服务器

  1. 测试与webdriver的 代码:

    FirefoxProfile配置=新FirefoxProfile(新文件( “/ home/user中/ selenium.default”)); driver = new FirefoxDriver(profile);

    结果:按预期工作

    与remoteWebDriver

    步骤

  2. 测试:

    1. 启动硒服务器

      java -jar selenium-server-standalo-2.19.0.jar -trustAllSSLCertificates -firefoxProfileTemplate /home/user/selenium.default/ -Dwebdriver.firefox.bin=/home/user/Apps/firefox/firefox 
      
    2. 代码在客户端

      DesiredCapabilities cap = DesiredCapabilities.firefox(); 
      driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), cap); 
      

    结果:浏览器启动,但不执行pref.js中指定的设置。所以,不要从指定目录加载配置文件。

是否有人在selenium服务器中使用profileTemplate成功?

回答

0

我知道你必须写下完整的profilePath for Firefox,如: -firefoxProfileTemplate "C:\ffprofile"

  • 也许还有一个原因:

尝试:

DesiredCapabilities cap = DesiredCapabilities.firefox(); 
FirefoxProfile profile = new FirefoxProfile("path_to_profile"); 
cap.SetCapability("firefox_profile", profile.ToBase64String());