保存 Selenium Webdriver 生成的 firefox 配置文件

2023-12-30

我在 Firefox 中使用 Selenium WebDriver。每次selenium 都会在临时文件夹中为firefox 生成新的aniumus 配置文件,并在退出后将其删除。我需要这个个人资料。我怎么才能得到它? F.e.配置文件存储在

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

关闭 WebDriver 后

driver.quit();

profile 将被删除,但它已经被记录,我想在下一次迭代中使用它,通过用它初始化 WebDriver :

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

是否可以保存配置文件而不需要像在驱动程序工作时处理整个文件夹这样的肮脏黑客行为(我什至不确定它是否有效,因为在 Windows 中,文件夹在 Firefox 启动时被锁定)?也许 Selenium 中存在一些 API?


你为什么不改变方法呢?

  • 创建火狐浏览器配置文件 http://kb.mozillazine.org/Creating_a_new_Firefox_profile_on_Windows这将是干净的,并以某种方式命名它,你知道它是什么。例如SELENIUM
  • 初始化 Webdriver 时:

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

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

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

保存 Selenium Webdriver 生成的 firefox 配置文件 的相关文章

随机推荐