How to drive Firebug from Selenium WebDriver

后端 未结 2 632
野趣味
野趣味 2021-01-05 06:02

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

相关标签:
2条回答
  • 2021-01-05 06:13

    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.

    0 讨论(0)
  • 2021-01-05 06:18

    To run Firebug within Selenium WebDriver using Java:

    Actions action = new Actions(driver);
    action.sendKeys(Keys.F12).build().perform();
    
    0 讨论(0)
提交回复
热议问题