你如何在用java编写的selenium webdriver程序中使用firefox插件?

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

实际上你不能点击元素,因为它不是一个网页元素。 但是,您可以为firefox创建配置文件,并在该配置文件中包含由webdriver应用程序启动的插件。 这将允许您访问Firebug或其他插件。 我不确定插件本身之间的交互,因为我不使用它,但你设置配置文件和使用插件api扩展配置文件的方式是这样的:

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

您可以使用名为“Autoit”的自动化工具自动执行上述方案。 我们只需要编写一个小脚本,在此工具的帮助下点击相应的坐标。 您可以参考: http : //www.autoitscript.com/site/autoit/