selenium启动firefox时加载扩展

    有些时候,我们测试需要用到插件或者已经导入的证书(比如金融和安全加密行业),而selenium启动firefox时会打开一个新的,不含有任何插件和个人证书的firefox(等同于全新安装后第一次打开的那个firefox)这种情况下,我们就要用firefoxprofile了。

    我们需要先新建一个profile或者直接使用默认,最快捷的方法就是把默认的profile拷贝一份出来。

关于firefox的profile,官网有介绍,点击这里查看

    使用特定Profile启动,使用FirefoxDriver(FirefoxProfile profile)的构造方法。

1 FirefoxProfile profiles = new FirefoxProfile(newFile("C:\FirefoxProfile\Auto"));  
2 WebDriver webDriver = new FirefoxDriver(profiles);  

    这样启动firefox后就会加载插件或证书了。

原文地址:https://www.cnblogs.com/liu-ke/p/4208514.html