如何使用Selenium 2 Webdriver打开指定的配置文件Firefox?

当我使用默认配置文件启动没有问题。 但是,当我开始使用自定义配置文件时,firefox会启动但仍会“阻止”。 该过程保持活动消耗31MB的RAM,但永远不会启动。 只有在我杀死这个过程后才开始,然后开始并与selenium一起正常工作。

我使用Windows 7,Firefox 25.0.1和selenium-server-standalone-2.38.0.jar¿可能是版本兼容性问题?

这是打开配置文件的代码:

FirefoxProfile profile = new FirefoxProfile(new File("C:/Users/UserTest/AppData/Roaming/Mozilla/Firefox/Profiles/tydtn9km.testprofile")); WebDriver driver = new FirefoxDriver(profile); 

编辑:这是我的实际代码

 package org.openqa.selenium.example; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.firefox.FirefoxProfile; import org.openqa.selenium.firefox.internal.ProfilesIni; public class Main { public static void main(String[] args) { ProfilesIni profile = new ProfilesIni(); FirefoxProfile ffprofile = profile.getProfile("Other"); WebDriver driver = new FirefoxDriver(ffprofile); driver.get("http://google.com"); } } 

编辑2:已解决问题是因为我的Firefox配置文件位于另一个分区,而Firefox位于另一个分区中。

我一直在使用它:

首先,创建一个Firefox配置文件,并以某种方式命名它。 例如SELENIUM

然后初始化您的个人资料:

 ProfilesIni profile = new ProfilesIni(); FirefoxProfile ffprofile = profile.getProfile("SELENIUM"); WebDriver driver = new FirefoxDriver(ffprofile);