我正在使用Selenium Webdriver for Automation。最近我需要打开一个网页,安装一个插件(在后端),然后点击一个按钮。该按钮检测到已安装的插件,并让我继续。
我可以在正常的firefox窗口中看到这一点。但不知何故,WebDriver发起的火狐不允许这样做。插件在网页中被实例化,按钮被启用。
我可以安装插件并在Add Ons页面中看到它,但按钮没有启用。
有没有办法强制webdriver重新加载所有插件,或者由于webdriver阻止插件实例化而存在任何安全问题?
提前感谢
发布于 2013-01-31 13:12:02
如果您想使用Add-on's,意味着您必须为Firefox创建一个配置文件,并在web驱动程序应用程序启动配置文件中包含附加组件。这将允许您通过附加组件访问“`Web元素”。我不确定它会有什么反应。我还没试过呢。但这是将插件用于启动的浏览器的方式。
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 tartup screen
WebDriver driver = new FirefoxDriver(firefoxProfile);引用自- http://code.google.com/p/selenium/wiki/FirefoxDriver
https://stackoverflow.com/questions/14604682
复制相似问题