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)
Step 2- To run script simply right click and select TestNG Test.
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.
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.
After refreshing, you will get below folder ready 🙂
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
Second open emailable-report.html
Third, open Index.html
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
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
Mukesh Otwani says
Hi Priya, please use pdfbox lib to create report and add screenshot as well.
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?
Mukesh Otwani says
Hi Anagha,
Please refer these links
1. http://learn-automation.com/selenium-advance-activity/
2. Official Document : https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/interactions/Actions.html
Gaurav Khurana says
Thanks able to implement it smoothly without any errors
Mukesh Otwani says
Great…!!!
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.
Mukesh Otwani says
In this case,You can continue with default testng report.
Arun says
Hai Mukesh , How are you & could you send me the most important selenium interview questions and it’solution.
Mukesh Otwani says
Here you go
http://learn-automation.com/selenium-interview-questions-and-answers/
ND says
https://vigoreport.io/
This is awesome tool gor online reporting, from anywhere.
Mukesh Otwani says
Seems Nice let me try this.
Noori Banu says
hello mukesh!!
how to read excel (.xls and .xslx) and supply data using data provider?
Mukesh Otwani says
HI Noori,
I have done the same thing in below post http://learn-automation.com/data-driven-framework-in-selenium-webdriver/
Shehshukumar says
Hi I am unable to genarete extent report could you please help me.
Mukesh Otwani says
What is the issue? Kindly share the logs/exception.
shalsa says
hi Mukesh,
why my test-output folder doesnt updated.
And emailable-report.html always not updated… help
Mukesh Otwani says
Hi Shalsa,
In eclipse it does not updated automatically but if you see the local drive then you will find updated reports.
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
Mukesh Otwani says
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/
Nitesh Jaiswal says
Great tutorial and its helping me to learn easily.!!
Mukesh Otwani says
Good to hear Nitesh. Check advance report too http://learn-automation.com/advance-selenium-reporting-with-screenshots-2/
siddhant raut says
Very Helpful and so much Interesting .
Thanks Mukesh
Mukesh Otwani says
Hey Sid,
Glad to know that you find this usefull.
Mallikarjun says
Hi Mukesh,
could you please help me how to configure xslt files in testng
Mukesh Otwani says
This post has clearly explained the same. Please try extent report as well.
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.
Mukesh Otwani says
Hi Ahmed,
Sorry dear I have never integrated Selenium with ALM so really not sure on this.
Swamy says
Good doc for begineers
Mukesh Otwani says
Hi Swamy Thank you 🙂
Sowjanya Viswanath says
Really very nice its clearing all my doughts what ever i have… Thanks Mukesh.
Mukesh Otwani says
Hi Sowjanya,
Thank you.
Please check other articles too and let me know if any help needed from my side 🙂
Karthikeyan says
Excellent
Mukesh Otwani says
Thanks Karthikeyan
Senthilkumar says
Good work.. Its very useful to beginners for automation
Mukesh Otwani says
Thank you Senthi, keep visiting and please check other articles too 🙂
Deepa says
keep up your great work…
Mukesh Otwani says
thanx Deepa keep visiting 🙂