collect extended info about failures

I had certain difficulties analyzing failures after execution of Selenium's test, especially when tests were executed in a 'continuous integration' mode overnight:

  • I could not see values that variables had at the moment of failure. It is especially critical if value assigned to variable generated in test or requested from the web service.
  • I could not see a page content at the moment of the failure. So I had no way to quickly figure out what happened - previous navigation failed, control was not present, server error happened etc.

It especially hurt in cases of irreproducible failures.

I thought about using some tool to record video of test run (yuck, bulky AVIs, hard to locate point of the failure) or of a way somehow take a 'regular' jpg screenshot. Both did not look like a good idea because in case of multi window mode it will show only top part of the page.
So I decided to proceed with simply grabbing html of the AUT.

Attached extension is a first (rather quick and probably rough) attempt to solve the problems described above.
'Screenshot' is somewhat not too nice looking because it is simply html of the page, missing css etc. So far it works for me especially considering that I did not have much time to improve it.

How to use

Just include attached code into your user-extensions.js. It was tested with Selenium Core 0.8.0.
Run your tests as you usually do.

Sample output

Type: 

User-Extension

2 Comments

Dec 18, 2007


Dec 18, 2007

Jerry Qian says:
A cool extension. It's really useful for me. Some of my suggestions: 1. Move ex...
A cool extension. It's really useful for me.
Some of my suggestions: 1. Move extension source from user-extension.js to selenium-testrunner.js. Then, selenium-ide user will not receive js error alert.
2. Error page source capture code: selenium.page().getDocument().body.innerHTML only captured body html. It may cause CSS and JS missing, which are usually included in html head. Modify it to: '<html>'+ selenium.page().getDocument().getElementsByTagName("html")[0].innerHTML + '</html>' Then, we capture the whole html. CSS/JS effect are better in popup window now.

Thank you Andrey

Thank you Andrey
This is a very useful extension.
Thank you Jerry I updated the extension with your recommendation and it picks up the css and scripts.
I use the store Global extension and included the global vars in a seperate table under the locals here is the addition just under the same for localvars.

var global_txt_vars = "";
for( var i in globalStoredVars ) {
global_txt_vars += "<tr><td><b><font color='purple'>"
+ i
+ "</font></b></td><td><b><font color='blue'>"
+ globalStoredVars[i]
+ "</font></b></td></tr>"
}
if( !global_txt_vars ) {
global_txt_vars = "No Local variables were set at this point."
}
else {
global_txt_vars = '<table cellpadding="1" cellspacing="1" border="1">'
+ '<tr><th>Global Variable</th><th>Value</th></tr>\r\n'
+ global_txt_vars
+ '</table>'
}
txt_vars = '<html><body>' + txt_vars + global_txt_vars + '</body></html>'

Now to include this in my reports.