如何在Selenium WebDriver(Selenium 2)中运行Firebug? [英] How do I run Firebug within Selenium WebDriver (Selenium 2)?

查看:110
本文介绍了如何在Selenium WebDriver(Selenium 2)中运行Firebug?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行Selenium 2时在Firefox中激活Firebug的最佳方法是什么?

What's the best way to activate Firebug in Firefox when running Selenium 2?

编辑:好的,我知道最佳可以解释,但是配置文件 - 基于解决方案真的曾经是硒1.0的痛苦。因此,除非证明更糟,否则任何替代方案都会被认为更好;)

Ok, I realize "best" is open to interpretation, but the profile-based solution really used to be a pain with selenium 1.0. So any alternative is considered better until proved worse ;)

推荐答案

您可以在代码中创建配置文件并动态添加所需的附加组件。假设您将Firebug XPI作为firebug.xpi保存到C:\ FF_Profile文件夹中(转到 Firebug下载页面,右键单击添加到Firefox并保存为C:\ FF_Profile\firebug.xpi)。

You can create your profile in code and dynamically add required add-ons. Let's assume that you saved Firebug XPI into the C:\FF_Profile folder as firebug.xpi (go to Firebug download page, right-click on the "Add To Firefox" and save as C:\FF_Profile\firebug.xpi).

代码:

   final String firebugPath = "C:\\FF_Profile\\firebug.xpi";
   FirefoxProfile profile = new FirefoxProfile();       
   profile.addExtension(new File(firebugPath));
   // Add more if needed
   WebDriver driver = new FirefoxDriver(profile);

这在 WebDriver常见问题解答

这篇关于如何在Selenium WebDriver(Selenium 2)中运行Firebug?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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