问题描述
Selenium WebDriver(又名 Selenium 2)从哪里获得它在打开 FirefoxDriver 时使用的匿名配置文件?如果它使用 Firefox 的默认值,%appdata%/roaming/mozilla/firefox/profiles,那么如果我要禁用 firefox 插件,它也应该为 Selenium WebDriver 禁用,那为什么不呢?
Where does Selenium WebDriver (a.k.a Selenium 2) get the anonymous profile that it uses when it opens FirefoxDriver? If it used the default for Firefox, %appdata%/roaming/mozilla/firefox/profiles, then if I were to disable a firefox plugin, it should be disabled for Selenium WebDriver also, so why isn't it?
推荐答案
我会回答,支持@twall 的评论:在 Selenium 2 WebDriver 中启动 firefox 时,它会启动新的匿名配置文件.
I will answer it, supporting comment from @twall: When starting firefox in Selenium 2 WebDriver, it starts new, anonymous profile.
但是,如果你想改变它,你可以创建新的 Firefox 配置文件 并以某种方式命名它,你知道它是什么 - 例如硒
However, if you want to change it, you can create new Firefox profile and name it somehow, you know what it is - e.g. SELENIUM
然后在您的代码中执行以下操作:
Then in your code do this:
ProfilesIni profile = new ProfilesIni();
FirefoxProfile ffprofile = profile.getProfile("SELENIUM");
WebDriver driver = new FirefoxDriver(ffprofile);
这样,Firefox 将始终启动该配置文件.在配置文件中,您可以进行所有需要的设置
That way, Firefox will always start that profile. In the profile you do all the settings you need
这篇关于Selenium WebDriver 默认使用什么配置文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!