Selenium 2 Firefox配置文件更改位置 [英] Selenium 2 Firefox Profile Change Location

查看:260
本文介绍了Selenium 2 Firefox配置文件更改位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很多星期以来,我一直在环顾四周,并且没有发现任何有关更改Firefox配置文件保存位置的信息.

For many weeks now, I have been looking around and I have not seen anything regards to changing the location the Firefox Profile saves to.

我正在使用特定的Firefox配置文件,但是,当测试运行时,会话是在/tmp/中创建的.我希望会话在其他位置启动并将其使用的文件保存在/var/tmp/等位置.有什么办法吗?

I am using a specific Firefox profile, however, when the tests run the session is created in /tmp/. I would like the session to start up in a different location and save the files it uses in a location like: /var/tmp/. Is there any way to do this?

注意:这不是我从哪里获得RemoteWebDriver来使用特定Firefox配置文件的问题.

Note: This is not a question as to where I get the RemoteWebDriver to use a specific Firefox profile.

我正在使用Selenium 2.28和Firefox 15.0.1

I am using Selenium 2.28 and Firefox 15.0.1

推荐答案

查看

TemporaryFilesystem 使用:中的位置,通常指向系统的临时目录. Santoshsarma的解决方案将因为此行而起作用(但它也会移动您的OS临时目录).

The TemporaryFilesystem takes it's location from "java.io.tmpdir":, which usually points to system's temp directory. Santoshsarma's solution will work because of this line (but it will also move your OS temp directory).

private static File sysTemp = new File(System.getProperty("java.io.tmpdir"));

我们可以做的更多!查看 公共 方法

We can do more! Look at the public method setTemporaryDirectory!

您可以在实例化FirefoxDriver之前调用此方法,并且它应该在您指定的位置创建它的配置文件副本.

You can invoke this method just before instantiating your FirefoxDriver and it should create it's profile copy at the location you specified.

这篇关于Selenium 2 Firefox配置文件更改位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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