When we are using Selenium or any other automation tool, we are performing operations on the web application. But our purpose of automation is not just to exercise the application under Test. We, as an automation tester are supposed to test the application, find bugs and report it to the development team or higher management. Here the reporting gets importance for Software Testing process

How to customize PDF Report

PDF reporting is quite handy but still, sometimes we need some less data in reports or want to display reports in some other format like pdf along with comments, excel, etc.

We can customize PDF report by:

Using Itextpdf Interface

Itextpdf Interface:

We use this interface when we need to customize real time report. In other words, if we are executing the bunch of test cases in a TetNG suite and we want to get the report of each test case, then after each test case we need to implement Itextpdf Interface interface.

Here are the steps we will follow

  • Create a class say DiagDirect and implement ITextPdfReport in it.
  • Implement methods of ITextpdf Listener

Create test method and add DiagDirect class as a listener in Test Method class.

API for PDF report along with comments we have to add below jars file in the project workspace in pom.xml

                                                com.itextpdf

                                                kernel

                                                7.0.2

                               

                               

                                                com.itextpdf

                                                io

                                                7.0.2

                               

                               

                                                com.itextpdf

                                                layout

                                                7.0.0

                               

                               

                                                com.itextpdf

                                                forms

                                                7.0.2

                               

                               

                                                com.itextpdf

                                                pdfa

                                                7.0.2

                               

                               

                                                com.itextpdf

                                                sign

                                                7.0.2

                               

                               

                                                com.itextpdf

                                                barcodes

                                                7.0.2

                               

                               

                                                com.itextpdf

                                                font-asian

                                                7.0.2

                               

                               

                                                com.itextpdf

                                                hyph

                                                7.0.2

                               

                               

                                                com.itextpdf

                                                itextpdf

                                                5.0.6

                               

                               

                                                com.aspose

                                                aspose-cells

                                                20.3

                               

               

               

                               

                                                AsposeJavaAPI

                                                Aspose Java API

                                                http://repository.aspose.com/repo/

                               

               

Take Screenshot code :

 Selenium webdriver can automatically take screenshots during the execution. But if users need to capture a screenshot on their own, they need to use the Take Screenshot method which notifies the WebDrive to take the screenshot and store it in Selenium.

Itext Pdf class.java

create a PDF document and add a paragraph to it using the iText library. It creates a PDF document with the name addingParagraph.pdf, adds a paragraph to it, and saves it in the path

Test Class.java

For generating PDF report , while execution we are capturing the  screen shots .In run-time we had adding the screen shots in pdf report along with comments in every image .

PDF Reports along with comments sample:

HRMS Home page

Leave a Reply

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