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

Java 如何使用Selenium 2 Webdriver打开指定的Firefox配置文件?,java,selenium,Java,Selenium,当我使用默认配置文件时,启动没有问题。但当我开始使用自定义配置文件时,firefox会启动,但会保持“阻塞”。进程保持活动状态,消耗31MB的RAM,但从未启动。只有在我终止了该过程后才开始,然后启动并与selenium配合使用 我使用的是Windows 7、Firefox 25.0.1和selenium-server-standalone-2.38.0.jar?版本的兼容性可能有问题 以下是打开配置文件的代码: FirefoxProfile profile = new FirefoxProfi

当我使用默认配置文件时,启动没有问题。但当我开始使用自定义配置文件时,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);

我就是这么做的+1这比我的代码好,但不能解决我的问题。我仍然有同样的问题。同样在Fedora 19中,但在Fedora中,首先打开匿名配置文件,然后在正确的配置文件工作正常后几秒钟。在这种情况下,您的代码(高概率)或Fedora(低概率)一定有问题。我认为问题不在于我的代码。我用代码更新了问题