Enabling logging in Selenium IDE

One of the things I never really figured out while I was maintaining Selenium IDE was to get all the log messages (and there are a lot!) to appear in the Firefox log. Or more accurately I suppose, I never bothered to figure it out. But thankfully Dave Hunt did figure it out.

If you are developing a plugin getting the messages to appear is only half the story. You of course have to get them into the log in the first place. This is made slightly more complicated by the fact there are two different logging implementations in Selenium IDE. (here and here).

What I have done in a customer plugin I’m developing is take the first implementation and extracted it to its own file. With that file included in your project somewhere, here is how you use it.

var loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader);
loader.loadSubScript("chrome://your_plugin/content/js/log.js", this);
function Foo() {
    this.logger = new Log("Foo");
Foo.prototype.do_something = function() {
  // do somethng
  this.logger.log(this.logger.DEBUG, 'a message!');

It is on my ‘to do’ list to back port this extraction into the main Selenium IDE project, but its down the list a bit.

Post a Comment

Your email is never published nor shared. Required fields are marked *