How to drive Firebug from Selenium WebDriver

那年仲夏 提交于 2019-11-30 20:04:39

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

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

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.

To run Firebug within Selenium WebDriver using Java:

Actions action = new Actions(driver);
action.sendKeys(Keys.F12).build().perform();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!