Friday 19 October 2018

How to attach screenshot image / link to Test NG report?

How to attach screenshot image / link to Test NG report?

First of all, let us know that Reporter.log() can be used to write additional text to Test NG HTML log file.

For eg: Reporter.log("msg");


To attach screenshot link to Test NG Report, simply we can define <a tag inside Reporter log
like this:

Reporter.log("<a href='" + new File(filePath+".png").getAbsolutePath() + "'>screenshot</a>");

Here, filePath is the exact path of file image to be attached.

This would be the sample output:


Note: It attached image hyperlink and when clicked on it, it would show the image. 


To attach directly image to Test NG report, we can define tag <img with src= file path as below: 

String path = "<img src=\"file://" + filePath2 + "\" alt=\"\"/>";
Reporter.log(path);

Here, filePath2 is the exact path of file image to be attached. 

This would be the sample output: 


Note: It attached image directly to Test NG report. 



if you have any questions about this do write in comment below. 

Hope this blog has been useful to you. If yes do follow my blogs by entering your email by 
clicking on "Follow" (blue) button. 

You can as well explore my 

Youtube Channel: https://www.youtube.com/user/srinivaskinik

And 

facebook page: https://www.facebook.com/srinivaskinikalmady/

Thank you.





No comments:

Post a Comment

How to schedule RFT (Rational Functional Tester) scripts to run using Jenkins / schedule

How to schedule RFT (Rational Functional Tester) scripts to run using Jenkins / schedule 1. Create a batch file with following content ...