一般启动firefox driver,使用如下代码
<code class="hljs fix has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;"><span class="hljs-attribute" style="box-sizing: border-box;">WebDriver driver </span>=<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;"> new FirefoxDriver();</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>
这样启动的firefox,会是一个全新的driver,不带任何的插件。一些高级的版本的firefox,启动时还会出现注册firefo的提示,这样对我们的测试造成了不少影响,怎样才能使用自己定义的firefox呢,根据下面的步骤即可完成。
1.打开cmd,进入到firefox安装目录
2.执行如下命令 firefox.exe -ProfileManager -no-remote
3.在弹出的profile窗口,点击create profile按钮,输入profile的名字,如selenium
4.点击 start firefox
5.在启动的firefox中安装自己需要的插件

使用如下代码即可调用刚才自定义的配置
<code class="hljs cs has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;">ProfilesIni allProfiles = <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">new</span> ProfilesIni();
FirefoxProfile profile = allProfiles.getProfile(<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"Selenium"</span>);
WebDriver driver = <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">new</span> FirefoxDriver(profile);</code>