`

Webdriver使用自定义Firefox Profile运行测试

阅读更多

一般我们使用如下代码启动Firefox:

WebDriver driver = new FirefoxDriver()

 这样Selenium Server启动的Firefox将是一个全新的,不安装任何Add-On的Firefox.

 

如果有需要,我们可以使用我们自己指定的,带有特定配置的Firefox.步骤如下

  1. 运行CMD,打开Firefox的 Profile manager
  2. 点击"Create Profile...",完成步骤,包括输入Profile名字
  3. 点击"Start Firefox"
  4. 在新启动的Firefox中安装自己所需要的Add-On或者做其他配置


 

最后,在代码中使用如下方式启动FirefoxDriver:

ProfilesIni allProfiles = new ProfilesIni();
// "Selenium" is the new profile just created
FirefoxProfile profile = allProfiles.getProfile("Selenium");
WebDriver driver = new FirefoxDriver(profile);

 

我在Selenium profile中安装了Firebug,然后使用脚本启动这个Profile,就能看到安装的Firebug了.

另外我们可以看到Manager里面有个default,这个就是我们自己平时使用的Firefox Profile,也是可以在代码中使用的.

 

本文出自"lijingshou"博客,转载请务必保留此出处http://lijingshou.iteye.com/blog/2085276

  • 大小: 24.8 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics