TestNG Tutorial

How to Generate Report in Selenium Webdriver using TestNG

Advance Selenium Reporting part 2

Welcome to Selenium tutorial, Today we will discuss how to generate report in selenium webdriver.

Automation without reporting of no use. Reporting plays very important role in Automation as well in Manual testing as well. Report help us to identify ROI and to prepare POC as well.

 

We can generate Advance reports as well like XSLT report which provide very good reporting.

I would highly recommend using Extent report which is a really very impressive report which is the advance version of XSLT report.

 

 

I have created a detailed video on TestNG which will help you to get started 

Generate Report in Selenium Webdriver

 Q1-Importance of Reporting in Selenium?

Ans-1- Reports helps you to identify the status of the test case (Pass/Fail/Skip).

2- Using reports we calculate time taken by  each test case that helps to calculate ROI(Return on Investment).

3- You can share automation reports with your team and clients as well to share the status of testing progress etc.

 

Q2- Does selenium support report generation?

Ans- No Selenium will only help you to automate your web application. If you want to generate reports then we can use Third party tools that we can integrate and can generate reports.

Here TestNG comes into the picture.

 

Q3- Do we need to write some script or any additional code for reports?
Ans- No we do not have to write any additional code for report generation. We need to refresh our project and we will get 1 additional folder (default suite) inside that folder we will get all the reports.

One good feature about TestNG for every test case it creates 3 different type of reports.

 

Generate Report in selenium webdriver

Step 1- Create a Simple java class and write some test cases (in my case I have written 3 test case)

 

generate report in selenium webdriver

 

Step 2- To run script simply right click and select TestNG Test.

 

generate report in selenium webdriver

 

Step 3- Now test case will start execution and you will get console notification about the status and wait until the program is getting finished.

Report type 1- Console output.

generate report in selenium webdriver

Since console output is not useful because you can’t share and send to others so we required some HTML reports as well

TestNG guys already gave a solution for this so for even single test case you will get HTML reports as well.

 

Report type 2- HTML report

We have to refresh your project and reports folder will come automatically.

 

Generate Reports Selenium using TestNG

 

 

After refreshing, you will get below folder ready 🙂

 

Generate Reports Selenium using TestNG

Let’s open each report and check the content

Note- Open Each report in Web Browser select each report then right click and open in browser

 

 

Generate report in selenium webdriver

First open Default test.html

generate report in selenium webdriver

Second open emailable-report.html

generate report in selenium webdriver

 

Third, open Index.html

generate report in selenium webdriver

 

 

If you really think this article will help others too then please share this with others too.

For More updates Learn Automation page

For any query join Selenium group- Selenium Group

author-avatar

About Mukesh Otwani

I am Mukesh Otwani working professional in a beautiful city Bangalore India. I completed by BE from RGPV university Bhopal. I have passion towards automation testing since couple of years I started with Selenium then I got chance to work with other tools like Maven, Ant, Git, GitHub, Jenkins, Sikuli, Selenium Builder etc.

38 thoughts on “How to Generate Report in Selenium Webdriver using TestNG

  1. Priya says:

    Hi Mukesh,

    I want to create test report in PDF along with screenshots of each test case pass/fail.
    I have the code to generate pdf report but not able to add the screenshot. How can I do this

    1. Hi Priya, please use pdfbox lib to create report and add screenshot as well.

  2. Anagha Girwalkar says:

    hii Mukesh
    i just want to know about how to perfotm key actions and mouse action..
    can you plz help me with this?

  3. Thanks able to implement it smoothly without any errors

  4. Ashok kumar G says:

    How to create a report for Selenium Parallel Test execution.
    I have two test in testng.xml file. Each test calls 50methods(@Test).
    One test runs in chrome browser and another one runs in firefox browser.

    Which one is the best report generation tool and how can i achieve it.

    1. In this case,You can continue with default testng report.

  5. Arun says:

    Hai Mukesh , How are you & could you send me the most important selenium interview questions and it’solution.

  6. ND says:

    https://vigoreport.io/

    This is awesome tool gor online reporting, from anywhere.

    1. Seems Nice let me try this.

  7. Noori Banu says:

    hello mukesh!!
    how to read excel (.xls and .xslx) and supply data using data provider?

  8. Shehshukumar says:

    Hi I am unable to genarete extent report could you please help me.

    1. What is the issue? Kindly share the logs/exception.

  9. shalsa says:

    hi Mukesh,
    why my test-output folder doesnt updated.
    And emailable-report.html always not updated… help

    1. Hi Shalsa,

      In eclipse it does not updated automatically but if you see the local drive then you will find updated reports.

  10. Sambeet says:

    Hi,

    Can you tell me how to take backup of the all the report files into a new folder each time I run a suite ?
    Files are –
    index.html
    emailable-report.html
    Default test.html

    1. Hi Sambeet,

      You can use below post to zip the data after test execution https://www.mkyong.com/java/how-to-compress-files-in-zip-format/

  11. Nitesh Jaiswal says:

    Great tutorial and its helping me to learn easily.!!

  12. siddhant raut says:

    Very Helpful and so much Interesting .

    Thanks Mukesh

    1. Hey Sid,

      Glad to know that you find this usefull.

  13. Mallikarjun says:

    Hi Mukesh,

    could you please help me how to configure xslt files in testng

    1. This post has clearly explained the same. Please try extent report as well.

  14. Ahmed says:

    Thanks Mukesh for such a great help. Mukhesh could you please help me out in one issue. I have successfully integrated Selenium HP ALM. I am able to do every thing now with ALM. But if I am attaching any file in ALM it is appearing as 0KB file. If you can give some of your precious time kindly contact or reply back.

    1. Hi Ahmed,

      Sorry dear I have never integrated Selenium with ALM so really not sure on this.

  15. Swamy says:

    Good doc for begineers

    1. Hi Swamy Thank you 🙂

  16. Sowjanya Viswanath says:

    Really very nice its clearing all my doughts what ever i have… Thanks Mukesh.

    1. Hi Sowjanya,

      Thank you.
      Please check other articles too and let me know if any help needed from my side 🙂

  17. Karthikeyan says:

    Excellent

  18. Senthilkumar says:

    Good work.. Its very useful to beginners for automation

    1. Thank you Senthi, keep visiting and please check other articles too 🙂

  19. Deepa says:

    keep up your great work…

    1. thanx Deepa keep visiting 🙂

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.