Selenium WebDriver默认使用什么配置文件?

Mic*_*ler 17 firefox selenium selenium-webdriver

Selenium WebDriver(又名Selenium 2)在哪里获得它在打开FirefoxDriver时使用的匿名配置文件?如果它使用Firefox的默认值,%appdata%/ roaming/mozilla/firefox/profiles,那么如果我要禁用firefox插件,它也应该禁用Selenium WebDriver,那么为什么不呢?

Pav*_*cek 21

我将回答它,支持来自@twall的评论:当在Selenium 2 WebDriver中启动firefox时,它会启动新的匿名配置文件.

但是,如果您想要更改它,您可以创建新的Firefox配置文件并以某种方式命名,您知道它是什么 - 例如SELENIUM

然后在你的代码中这样做:

 ProfilesIni profile = new ProfilesIni();
 FirefoxProfile ffprofile = profile.getProfile("SELENIUM");
 WebDriver driver = new FirefoxDriver(ffprofile);
Run Code Online (Sandbox Code Playgroud)

这样,Firefox将始终启动该配置文件.在配置文件中,您可以执行所需的所有设置


And*_*dis 5

您可以为每个Selenium grid 2节点分配一个特定的firefox配置文件:

java -jar selenium-server-standalone-2.37.0.jar -Dwebdriver.firefox.profile = my-profile -role node -hub http://example-server.org:4444/grid/register

请注意,webdriver.firefox.profile的值必须是firefox配置文件名称,而不是位置或文件夹名称