保存由Selenuim Web Driver生成的Firefox配置文件 [英] Save firefox profile generated by Selenuim Web Driver

查看:67
本文介绍了保存由Selenuim Web Driver生成的Firefox配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Selenium WebDriver与firefox一起使用.硒每次在temp文件夹中为firefox生成新的anoniumus配置文件,并在退出后将其删除.我需要这个个人资料.我怎么才能得到它? F.e.个人资料存储在

I use Selenium WebDriver with firefox. Every time selenium generates new anoniumus profile for firefox in temp folder and after exit, removes it. I need this profile. How can I get it? F.e. profile stored in

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

通过关闭WebDriver后

After shutting down WebDriver with

driver.quit();

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

profile will be removed, but it is already logged and I want to use it in next iteration, by initing WebDriver with it:

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

是否可以保存配置文件而不会在驱动程序正常工作时处理整个文件夹(我不确定它是否可行,因为在Windows中,Firefox启动时文件夹被锁定了)就不会对整个文件夹造成恶意攻击?也许Selenium中存在一些API吗?

Is it possible to save profile without dirty hacks like coping whole folder while driver works (I'm not sure even it works, because in windows, folder is locked while firefox launched)? Maybe exists some API in Selenium for it?

推荐答案

您为什么不更改方法?

  • 创建Firefox配置文件,该文件将是干净的并以某种方式命名,您以某种方式知道它是什么.例如SELENIUM
  • 初始化Webdriver时:

  • Create firefox profile which will be clean and name it somehow you know what it is. e.g. SELENIUM
  • When initializing the Webdriver:

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

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

That way, you assure that this profile will be used anytime you do the tests...

这篇关于保存由Selenuim Web Driver生成的Firefox配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆