如何在用java编写的selenium webdriver程序中使用Firefox插件? [英] How do you use a firefox plugin within a selenium webdriver program written in java?

查看:250
本文介绍了如何在用java编写的selenium webdriver程序中使用Firefox插件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图运行一个硒脚本,点击我的工具栏中的一个Firefox插件。是否有可能做到这一点?

I was trying to run a selenium script that clicks on one of my firefox plugins in my toolbar. Is it possible to do this?

推荐答案

事实上,你不能在元件上按一下,因为它不是一个网页元素。不过,您可以为Firefox创建一个配置文件,并在该配置文件中包含由webdriver应用程序启动的插件。这将允许您访问Firebug或其他插件。我不确定插件之间的相互作用,因为我不使用这个,但是设置配置文件和扩展插件api的配置文件的方式如下所示:

Actually you can't click on the element since it's not a web page element. However you can create a profile for firefox and include addons in that profile that is launched by the webdriver applications. This will allow you to have access to Firebug or other addons. I'm not sure of the interaction between the addons myself since I don't use this but the way you set a profile and extend the profile with the addon api is like so:

File file = new File("firebug-1.8.1.xpi");
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.addExtension(file);
firefoxProfile.setPreference("extensions.firebug.currentVersion", "1.8.1"); // Avoid startup screen
WebDriver driver = new FirefoxDriver(firefoxProfile);

引用 - http://code.google.com/p/selenium/wiki/FirefoxDriver

这篇关于如何在用java编写的selenium webdriver程序中使用Firefox插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆