点击进入转发地址:

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

Java代码 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或者做其他配置

【转发】Webdriver使用自定义Firefox Profile运行测试
 

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

Java代码 
  1. ProfilesIni allProfiles = new ProfilesIni();  
  2. // "Selenium" is the new profile just created  
  3. FirefoxProfile profile = allProfiles.getProfile("Selenium");  
  4. WebDriver driver = new FirefoxDriver(profile);  

 

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

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

相关文章:

  • 2021-12-15
  • 2021-10-23
  • 2022-12-23
  • 2021-07-16
  • 2021-12-13
  • 2022-12-23
  • 2022-12-23
  • 2021-11-12
猜你喜欢
  • 2022-12-23
  • 2021-08-27
  • 2021-09-26
  • 2022-01-24
  • 2022-12-23
  • 2021-06-05
  • 2022-12-23
相关资源
相似解决方案