Firefox Webdriver + 在执行过程中安装插件 [英] Firefox Webdriver + installing plugin during the execution

查看:30
本文介绍了Firefox Webdriver + 在执行过程中安装插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Selenium Webdriver 进行自动化.最近我需要打开一个网页,安装一个插件(在后端)并单击一个按钮.该按钮检测到已安装的插件并让我继续.

I am using Selenium Webdriver for Automation. Lately I have a need where I open a webpage, install a plugin(in the backend) and click a button. The button detects the installed plugin and lets me continue.

我可以在正常的 Firefox 窗口中看到它的工作.但不知何故,WebDriver 启动的 Firefox 不允许这样做.插件在网页中实例化,按钮被启用.

I can see this working in the normal firefox window. But somehow the WebDriver initiated firefox does not allow the same. The plugin is instantiated in the webpage and the button gets enabled.

我可以安装插件并在附加组件"页面中看到它,但按钮未启用.

I could install the plugin and see it in Add Ons page but the button is not getting enabled.

有没有办法强制 webdriver 重新加载所有插件,或者是否存在任何安全问题,因为哪个 webdriver 阻止插件被实例化?

Is there a way I can force the webdriver to reload all the plugins or is there any security issue due to which webdriver is preventing the plug in from being instantiated?

提前致谢

推荐答案

如果您想使用 Add-on's 意味着您必须为 Firefox 创建一个配置文件并在该配置文件中包含附加组件由 Web 驱动程序应用程序启动.这将允许您通过附加组件访问Web 元素".我不确定它会如何反应.我还没试过.但这是在启动的浏览器中使用插件的方式.

If you want to use Add-on's mean you have to create a profile for Firefox and include add on's in that profile that is launched by the web driver applications. This will allow you to have access to the `Web Element' through add-on's. I am not sure how it will react. I didn't tried not yet. But this the way to use plug-in to the launched browser.

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/Firefox 驱动程序

这篇关于Firefox Webdriver + 在执行过程中安装插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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