如何从Selenium WebDriver驱动Firebug [英] How to drive Firebug from Selenium WebDriver

查看:102
本文介绍了如何从Selenium WebDriver驱动Firebug的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在通过WebDriver运行测试时捕获Firebug的Net面板输出.我正在考虑使用NetExport将信息转储到har文件中.当使用"driver.get()"显示特定页面时,如何激活Firebug进行导出?

I would like to capture the Net panel output from Firebug while running a test through WebDriver. I was thinking of doing this using NetExport to dump the info to a har file. How can I activate Firebug to do the export while a particular page is displayed using "driver.get()"?

推荐答案

除Firebug和NetExport外,您还需要Firestarter扩展.这是我在Ruby中的操作方式:

You need the Firestarter extension in addition to Firebug and NetExport. Here's how I do it in Ruby:

profile = Selenium::WebDriver::Firefox::Profile.new

profile.add_extension "path/to/firebug.xpi"
profile.add_extension "path/to/fireStarter.xpi"
profile.add_extension "path/to/netExport.xpi")

profile['extensions.firebug.currentVersion']    = "1.7.0a3" # avoid 'first run' tab
profile["extensions.firebug.previousPlacement"] = 1
profile["extensions.firebug.onByDefault"]       = true
profile["extensions.firebug.defaultPanelName"]  = "net"
profile["extensions.firebug.net.enableSites"]   = true

profile["extensions.firebug.netexport.defaultLogDir"]          = output_dir
profile["extensions.firebug.netexport.alwaysEnableAutoExport"] = true

driver = Selenium::WebDriver.for :firefox, :profile => profile

等效的API在Java中可用.确保扩展名彼此兼容(以及您的Firefox版本).

Equivalent APIs are avilable in Java. Make sure the extensions are compatible with each other (and your Firefox version).

如果您使用的是Ruby(或者只是想从命令行快速启动HAR查看器),请查看我的 HAR gem ,这是以后处理数据的简便方法.

If you're using Ruby (or just want to quickly launch a HAR viewer from the command line), check out my HAR gem for an easy way to work with the data later.

这篇关于如何从Selenium WebDriver驱动Firebug的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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