如何在firefox中使用selenium调用一个插件



我可以使用selenium从firefox/chrome调用插件吗?我的要求是,我必须点击并打开一个插件从firefox和做一些行动。假设我必须在firefox中调用脚本覆盖插件

您可以在Firefox中执行以下操作:

FirefoxProfile profile = new FirefoxProfile();
profile.addExtension(new File(ClassLoader.getSystemResource("path/to/.xpi").getFile()));
WebDriver driver = new FirefoxDriver(profile);

我敢打赌,为Chrome设置一些东西会非常相似。注意以上是针对Selenium 2的。

编辑RC指令:

您需要像这样运行服务器(在配置文件管理器中创建配置文件之后):

java -jar selenium-server.jar -firefoxProfileTemplate “<Selenium Profile Directory>”

最新更新