firebug / netexport

Firebug extension - export data from the Net panel
http://www.softwareishard.com/blog/netexport/
Other
35 stars 17 forks source link

Set a constant name for the HAR file #9

Closed beanqueen closed 9 years ago

beanqueen commented 10 years ago

it would be nice to be able to set the name of the exported file.

if would be even nicer if i were able to issue a command like this:

save_now(under_this_name)

if maybe i wanted to save the requests between two clicks on the same page

thank you!

yuisong commented 9 years ago

I wonder whether there is an option to set the file name of the exported har file or not now?

janodvarko commented 9 years ago

Yes it is now possible to provide a custom name.

1) There is a new pref: extensions.firebug.netexport.defaultFileName You can set it to a string that is used as a format string for generating the name An example: myname-%Y-%m-%d-endofthename

Read more about the format: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleFormat

2) You can pass name into NetExport.triggerExport() API

NetExport.triggerExport({ fileName: "myFileName" })

NetExport is currently bundled in Firebug.next, this new feature available in alpha 10 https://github.com/firebug/firebug.next/releases/tag/firebug-3.0.0-alpha.10

Honza

yuisong commented 9 years ago

Here is the screenshot of my about:config. There isn't a pref named extensions.firebug.netexport.defaultFileName.

What's more, it did not show up in https://github.com/firebug/netexport/blob/master/defaults/preferences/prefs.js, either.

Can you have a look at this?

Many thanks!

Yui 2015-04-22 9 18 30

yuisong commented 9 years ago

Now I use Selenium + FirefoxWebdriver(FF for mac 37.0.2 ) + Firebug 3. I wrote a Har file generator in Java and take the use of the code on your blog as the following. However, the new pref: extensions.firebug.netexport.defaultFileName dosen't work. Is there some thing wrong? Or is it necessary for me to use a format as you mention above?

Many thx!

Yui

Here is the Java code:

   String url ="www.google.com";    
    // Set default Firefox preferences
    profile.setPreference("app.update.enabled", false);

    String domain = "extensions.firebug.";

    // Set default Firebug preferences
    profile.setPreference(domain + "currentVersion", "3.0.0");
    profile.setPreference(domain + "allPagesActivation", "on");
    profile.setPreference(domain + "defaultPanelName", "net");
    profile.setPreference(domain + "net.enableSites", true);

    // Set default NetExport preferences
    profile.setPreference(domain + "netexport.alwaysEnableAutoExport", true);
    profile.setPreference(domain + "netexport.showPreview", false);
    profile.setPreference(domain + "netexport.defaultLogDir", "~/project/har");
    profile.setPreference(domain + "netexport.defaultFileName", url);// Set the name of the har log file

  //Set up the browser
    WebDriver driver = new FirefoxDriver(profile);
    driver.get(url);
janodvarko commented 9 years ago

Here is the screenshot of my about:config. There isn't a pref named extensions.firebug.netexport.defaultFileName.

There is for me, make sure you have Firebug 3 alpha 11 installed (the latest) http://getfirebug.com/releases/firebug/3.0/ (look in this directory)

What's more, it did not show up in https://github.com/firebug/netexport/blob/master/defaults/preferences/prefs.js, either.

You don't need the NetExport at this point.

Honza