Testing Evidence with Selenium IDE

Recently I ran into a fan. My fan! I still can’t contain my surprise! I never expected that I would have fans. (OK, just one so far :-))

He asked me if there was a way to save the test case in a way that shows which commands have passed and which commands have failed. I asked him why on earth would he want to do such a thing and not use the -htmlsuite option of the Selenium remote control. To cut a lengthy discussion short, there is a real use case for this. There are companies that require testers to keep track of the test results for process or legal purposes. Some of the smart ones have started using Selenium IDE to reduce their effort. While these testers are not programmers, Selenium IDE helps them to save tons of time and effort. There are times when they cannot use the -htmlsuite and would benefit from test results exported from the Selenium IDE itself.

While my File Logger plug-in really helps to provide a log file with all the details of executed commands. Screen shots are another option, but quickly become a pain when your test case exceeds the screen size. A HTML version of the test case showing which tests have passed and which have failed would be a great help to easily digest the results. Being the pragmatic type, I told him that the answer to his question was simple and it was easily possible in Selenium IDE — if you know the right internals. It is as simple as copy the HTML format, throw a splash of colours with a style sheet and mix in the results.

Here is a step by step guide to do it.

1. Create a new format based on the built-in HTML formatter:-

Open the Options dialog and Formats tab then click on HTML and finally click the Source button. From the source dialog, copy all the source text and click the Cancel button to close the source dialog. Back in the Options dialog, click the Add button to add a new format and paste the source to replace the shown source. Before clicking the Save button, give the name of the format as Evidence.

2. Add a set of styles for providing colours:-

You will need to close the Options dialog by clicking the OK button and open it again to see the Evidence format. Click on the Evidence format, in the formats tab. Now in the Template for new test html file textbox just before the </head> tag, insert the following:-

.failed {color: red; background-color: #ffcccc;}
.passed {color: black; background-color: #ccffcc;}
.done {color: black; background-color: #eeffee;}

3. Add the results to the command:-

Next, in the Template for command entries in the test html file textbox, replace the <tr> with the following:-

<tr class="${command.result}">

And click on the OK button to save the changes.

From now on, after you have run a test case, you can simply export it (File menu – Export Test Case As menu item) using the Evidence formatter we just created. This will save a test case that will show nicely coloured rows when you open it in a browser similar to the way you see it in the Selenium IDE. Just don’t forget to give the extension as .htm.

I would also like to point out the genius of the people who designed the Selenium IDE. I think that providing this kind of flexibility is an application is sheer genius. Great work guys!

I think the above process is really simple and works reasonably well for single test cases. If all this is sounds too complicated or you are efficient (or lazy :-P), worry not! I will soon release a Test Results plug-in for Selenium IDE that will do all this and also allow you to export the test results for an entire suite in a single file without having to do any changes mentioned above.

And if you are my fan, don’t forget to let me know :-)

This entry was posted in Selenium Tips and tagged , , , , , , , , , . Bookmark the permalink.

11 Responses to Testing Evidence with Selenium IDE

  1. br says:

    I have some problems to get the style info working from ‘Template for new test html file’.
    SeleniumIDE doesn’t take the changes to the exported output file.
    The class entry to ‘Template for command entries in the test html file’ works fine.

    Any idea?

    • Samit Badle says:

      Hi Bruno,

      That is indeed strange. I followed the exact same procedure and took the screen shots. As you can from the screen shots it worked. I will try to help you out and get it working. Can you send me the content of your text field ‘Template for new test html file’? Please use http://gist.github.com/ and paste the link in your comment.


  2. br says:

    if the testcase format is HTML the export doesn’t change the header and footer, so the style info is not updated in the export file.

    look at function format(testCase, name) {

    if (testCase.header == null || testCase.footer == null) {

    On comment out the if/else statement you will get the new header, but this is not a good solution.

  3. br says:

    Hi Samit,
    i create a new formatter as you decriped above.
    I think the problem is, if you use html as default in IDE your testcases has the default html header and the evidence formatter don’t change the existing header.

    On comment out the if/else statement you will get the new header from evidence.
    “if (testCase.header == null || testCase.footer == null) { ”

    Cheers Br

    • Samit Badle says:

      Hi Bruno,

      You are right. It only works in case you have not saved the test case. For saved test cases, the header already exists and is not replaced. I will update the post to include your solution.

      Thanks & cheers,

  4. br says:

    Hi Samit,
    maybe it is interesting to add a evidance column to the output.


    The verified values may also be interesting, but I don’t know how to get them.
    Or you can display comments in the evidence report.
    Your evidence formater is a wonderful idea and instruction for personal formated reports.

    Thanks Bruno

    • Samit Badle says:

      Hi Bruno,

      All these are indeed nice ideas, I will add them to the backlog for the Test Results plugin. Showing the verified values won’t be simple, maybe I can figure a way to accomplish it. I am glad you have found it useful. This is exactly the reason I post such things.


  5. Pingback: Test Results v1.0 for Selenium IDE Now Available | Really Simple Thoughts of a Perpetual Learner

  6. Iury says:

    Hi Dude,

    Congratulations!! This article is awesome.

    I am having problem to export my tests as HTML, so I would like to know it is possible to export the name of test and the result as the test script.




    Test Passed
    open /
    type id=lst-ib vw polo
    verifyTextPresent POLO

Leave a Reply

Your email address will not be published. Required fields are marked *