How do you use a firefox plugin within a selenium webdriver program written in java?(如何在用 java 编写的 selenium webdriver 程序中使用 firefox 插件?)
问题描述
我试图运行一个 selenium 脚本,该脚本单击我工具栏中的一个 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 插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在用 java 编写的 selenium webdriver 程序中使用 firefox 插件?
基础教程推荐
- 大摇大摆的枚举 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 多个组件的复杂布局 2022-01-01
- 从 python 访问 JVM 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- Java Swing计时器未清除 2022-01-01
