10d. Advanced WebDriver – JUnit Report Customization Contd.

Hiya champs! If you had not let your imagination run wild with the previous post, I will help u do just that today.

We will be,

  • Adding or deleting a column
  • Changing the styles
  • Adding a logo to the header section
  • Modifying static text

Add or delete a column

This is really a piece of cake. Add or delete <th> and <td> tags to achieve this task. Let us see a scenario by adding a column named ‘Executed By’ in ‘All Tests’ table.

<!-- method header -->
<xsl:template name="testcase.test.header">
    <xsl:param name="show.class" select="''"/>
    <tr valign="top">
    <xsl:if test="boolean($show.class)">
        <th width="60%">Type</th>
        <th nowrap="nowrap">Time(s)</th>
        <th>Executed By</th>

Under this template, <xsl:template match="testcase" mode="print.test">

along with the existing columns add a value for the newly created ‘Executed By’ column as well.

            <xsl:call-template name="display-time">
                <xsl:with-param name="value" select="@time"/>


Before adding column


After adding a column

Changing the styles

Thinking hard how to change the styles in the generated report? There is no need to strain your brain on that! Because just like any other webpage, we have a CSS stylesheet taking care of the styles for this report as well. Just search for the template with the name, ‘stylesheet.css’ in the “junit-frames.xsl” file.

<!-- this is the stylesheet css to use for nearly everything -->
<xsl:template name="stylesheet.css">

Styles for the body, tables, headings, stack trace, error, failure, paragraphs, properties, everything is specified in this very template. Just go ahead and throw your hat in the ring! Experiment with each line of CSS and see the changes rendered. And yeah, you can add in your own CSS as well!

Let us just look at one small example for starters. The table details and failure styles are given as below,

table.details tr th{
    font-weight: bold;
.Failure {
    font-weight:bold; color:purple;

Let us change these as following,

  1. All table headings alignment to center
  2. The background color of the table header rows to ‘greenyellow’ (#ADFF2F)
  3. Failure text color to maroon
table.details tr th{
    font-weight: bold;
.Failure {
    font-weight:bold; color:maroon;


Before changing styles


After changing the styles

I know, it doesn’t look very appealing to the eye but we proved what we wanted to. So, there you go!

Adding a Logo to the header section

Most of us like our logos on the report that is generated. Who doesn’t like personalizing and a bit of marketing ? If you know a bit of HTML, it’s pretty simple. To the template named, “pageHeader”, add an image tag and specify the path in the src attribute. I have placed my logo image in the ‘junit’ folder of the project where the index.html file is generated.

<xsl:template name="pageHeader">
   <!-- <h1><xsl:value-of select="$TITLE"/></h1>  -->
   <h1>Custom JUnit Report</h1>
    <table width="100%">
        <td align="left"></td>
        <td align="right"><img width="50" height="50" alt="Selenium" src="myLogo.jpg"/> Designed by ninjas!</td>
    <hr size="1"/>


Adding a Logo

Modifying static text

This is the icing on the cake (Oh! You already know it by now). To modify any static text that is displayed in the report, you have to just change it in the “junit-frames.xsl” file. Yes, you read that right. It is that simple!

Let’s say, in the summary table of the report instead of ‘tests’, I want it to be ‘Number of Tests’. Just change the text in the body section where the h2 tag says ‘Summary’,

<table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
        <tr valign="top">
            <th>Number of Tests</th>
            <th>Success rate</th>


Modifying static text

Time to self-reflect on what we learned so far.

See you again in another post. Happy customizing!

Lakshmi Chandana is a Software professional + passion-fueled blogger + novel-reader + artist + tutor to make your day a little brighter than it was before! She is thrilled you are here! She is on a mission to make sure learning sticks but with the fun part kept intact. She uses certain tricks called BrainBells (inspired from barbells and dumbbells used for workout) to achieve this and she says, “this is not the hardest job! As once minions said, it for sure is working in a bubble wrap factory. Imagine the self-control needed!” So, dive in to explore the fun-filled World of Learning!!

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top Search