How to drive Firebug from Selenium WebDriver

老子叫甜甜 提交于 2019-11-30 04:24:39

问题


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()"?


回答1:


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.




回答2:


To run Firebug within Selenium WebDriver using Java:

Actions action = new Actions(driver);
action.sendKeys(Keys.F12).build().perform();


来源:https://stackoverflow.com/questions/4965167/how-to-drive-firebug-from-selenium-webdriver

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