保存Selenuim Web Driver生成的firefox配置文件

我使用Selenium WebDriver和firefox。 每次selenium在temp文件夹中为firefox生成新的anoniumus配置文件,并在退出后删除它。 我需要这个档案。 我怎么才能得到它? 存储的Fe配置文件

C:\Documents and Settings\Developer\Local Settings\Temp\anonymous5583304190515426768webdriver-profile 

关闭WebDriver后

 driver.quit(); 

配置文件将被删除,但它已被记录,我希望在下一次迭代中使用它,方法是使用它启动WebDriver:

 FirefoxDriver driver = new FirefoxDriver(new FirefoxProfile(profileFolder)); 

是否有可能保存配置文件没有肮脏的黑客攻击,如驱动程序工作时应对整个文件夹(我不确定它是否工作,因为在Windows中,文件夹被锁定而firefox启动)? 可能在Selenium中存在一些API吗?

你为什么不改变做法?

  • 创建一个干净的firefox配置文件 ,并以某种方式命名它你知道它是什么。 例如SELENIUM
  • 初始化Webdriver时:

      ProfilesIni allProfiles = new ProfilesIni(); FirefoxProfile desiredProfile = allProfiles.getProfile("SELENIUM"); WebDriver driver = new FirefoxDriver(desiredProfile); 

这样,您可以确保在您进行测试时随时使用此配置文件…