The Selenium Files: Missing Log Message in Selenium IDE

Every now and then I noticed that the first log message did not show up in the log pane of the Selenium IDE. Thanks to my File Logging plugin for Selenium IDE, it was never a problem. The File Logging plugin would capture the log message to a file even if it was not shown in the log pane. I never bothered to investigate missing log message bug further or try to identify steps to reproduce it. This weekend while I was working on the next version of the File Logging plugin, I came across the following piece of code in editor.js in Selenium IDE code.

if (!this.isHidden()) {
    var newEntry = this.view.contentDocument.createElement('li');
    newEntry.className = entry.level;
    newEntry.appendChild(this.view.contentDocument.createTextNode(entry.line()));
    this.getLogElement().appendChild(newEntry);
    newEntry.scrollIntoView();
} else {
    this.panel.switchView(this);
}

Hmmm. That explains the problem and the circumstances under which the missing log message bug occurs. Basically, if the log pane is hidden, i.e. another pane like the reference pane is visible, the log pane is shown, but the log message is not shown. Hence, if the log pane is not visible, the log message goes missing.

The Fix

Now that I have found the cause of the problem, the fix is trivial. If the log pane is hidden, show it first and then show the log message.

if (!this.isHidden()) {
    // Samit: Fix: Fix the occasional missing log message bug
    this.panel.switchView(this);
}
var newEntry = this.view.contentDocument.createElement('li');
newEntry.className = entry.level;
newEntry.appendChild(this.view.contentDocument.createTextNode(entry.line()));
this.getLogElement().appendChild(newEntry);
newEntry.scrollIntoView();

No more missing log message. Time to submit a patch.

Case solved! 🙂

Advertisements
This entry was posted in The Selenium Files and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s