how to show screen shot within testng report in jenkins

4,736 views
Skip to first unread message

himadri das

unread,
Aug 22, 2013, 6:43:12 AM8/22/13
to seleniu...@googlegroups.com
Hi,

I am new to this forum. I have problem to show screenshot within testng report in jenkins. I have used following code to show screenshot in tesng report and it's showing screen shot there but I am not able see the same from jenkins:

Reporter.log("<td><a href='"+Image_name+".png'><img src='"+Image_name+".png' height='100' width='100' /></a></td>");



Please help me to solve the problem.



Regards,
Himadri

Mark Collin

unread,
Aug 22, 2013, 6:53:02 AM8/22/13
to seleniu...@googlegroups.com
This is not a selenium question.
> --
> You received this message because you are subscribed to the Google
> Groups "Selenium Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to selenium-user...@googlegroups.com.
> To post to this group, send email to seleniu...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/selenium-users/f63fc723-a7d0-4ae2-bc23-575822325e17%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

UmaMahesh

unread,
Aug 22, 2013, 8:07:03 AM8/22/13
to seleniu...@googlegroups.com
Reporter.log(String.format("SCREENSHOT: <a href='%s'><img border='0', src='%s' width='80' height ='60'/></a>", screenShotName, screenShotName)

try this and let me know.

Regards,
Uma Mahesh


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/f63fc723-a7d0-4ae2-bc23-575822325e17%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
mahesh.......

himadri das

unread,
Aug 29, 2013, 5:34:27 AM8/29/13
to seleniu...@googlegroups.com
Hi Mahesh,

I have tried with this. it is not also working. What I observed is screen shot is getting  saved in surefire-reports folder but jenkins is searching the screen shot from this path:http://localhost:8080/job/Verio_Framework/7/testngreports/retailsite.users/retailsite.users.Signup/signuptest/image.jpg

even I have fixed the screen shot path but jenkins is not able to fetch it from there. Please help.


Regards,
Himadri

David Lai

unread,
Aug 29, 2013, 11:30:11 AM8/29/13
to seleniu...@googlegroups.com
In Jenkins, the report you see is processed by the Jenkins plugin.  

If you want to see the screen shot and the report you're generating, you'll have to instead of using a reporting plugin, have Jenkins export the report and the images as an artifact so you can open the real files.

David Lai

unread,
Aug 29, 2013, 11:31:28 AM8/29/13
to seleniu...@googlegroups.com
Also another way is to convert the images to a dataURI schema, that can be embedded directly into the HTML.

himadri das

unread,
Sep 6, 2013, 4:16:12 AM9/6/13
to seleniu...@googlegroups.com
Can you please tell me how to use it?

David Lai

unread,
Sep 6, 2013, 7:52:56 PM9/6/13
to seleniu...@googlegroups.com
Selenium has a method for getting a screenshot as a base64 encoded string.  Then you just prepend the dataURI prefix to it to make it a png data URI.

## Python
base64_str = driver.get_screenshot_as_base64()
data_uri = "data:image-png;base64," + base64_str

Shawn McCarthy

unread,
Nov 26, 2013, 2:05:11 PM11/26/13
to seleniu...@googlegroups.com
Thanks David ! This helped me a lot ! I had one issue with your solution. When I clicked the image in the testNG report (in Chrome), it would download the image. In Firefox it worked. I switched the data_uri prefix from "data:image-png;base64," to "data:image/png;base64," and it worked correctly in Firefox and Chrome.

Ashok kumar

unread,
Nov 27, 2013, 11:02:49 PM11/27/13
to seleniu...@googlegroups.com
Hi,

Apart from the reports generated by TestNG, you can use a TestNG Listener plugin that can generate more detailed reports that includes screenshots and much more information about the test execution.

you can refer http://automationtestingutilities.blogspot.in/ for download the project.


Regards
Ashok

Nils Gajsek

unread,
Jan 22, 2014, 5:45:50 AM1/22/14
to seleniu...@googlegroups.com
Hi Guys,

check out this Lib selenium gallery plugin

It generate a HTML Gallery Report by fetching the screenshot directory using PHP. The eample shows you a solution with Phing .. but its also possible to make it run with Ant or command line ... 

Cheers
Reply all
Reply to author
Forward
0 new messages