Report bitmap

Class library usage, coding and language questions.
atom
Posts: 357
Joined: Sun Dec 07, 2008 11:14 pm
Location: Dublin, Ireland

Report bitmap

Post by atom » Tue Jul 28, 2009 1:53 pm

Hiya

In our test framework we have a class that produces performace test results as a graph
The graph is help in memory as a Bitmap object but can also be saved to an external file
Id like the bitmap to be part of the ranorex log file
Can this be done?

Thanks

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Report bitmap

Post by Support Team » Tue Jul 28, 2009 2:24 pm

Hi atom,
yes it can be done. Use the Report.LogData() method and assign the bitmap to the 'object data' parameter.

e.g.
Bitmap bmp = new Bitmap(...);
Report.LogData(ReportLevel.Info,"Info",bmp);
Regards,
Christian
Support Team

atom
Posts: 357
Joined: Sun Dec 07, 2008 11:14 pm
Location: Dublin, Ireland

Re: Report bitmap

Post by atom » Wed Jul 29, 2009 3:44 pm

nice one!
So what types does LogData recognise?
I was kind of suspicious that it might try to convert the object to a string and then log the string

Thanks

atom
Posts: 357
Joined: Sun Dec 07, 2008 11:14 pm
Location: Dublin, Ireland

Re: Report bitmap

Post by atom » Wed Jul 29, 2009 3:45 pm

BTW for other automation people... check out ZedGraph
Its a free graphing library, pretty useful for reporting results as Bar / Pie / Line graphs

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Report bitmap

Post by Support Team » Wed Jul 29, 2009 3:51 pm

Report.LogData currently only recognizes Bitmap objects, so for all other types it will just put the type name into the report.

Regards,
Alex
Ranorex Support Team

chrisgeorge
Posts: 49
Joined: Thu Aug 20, 2009 11:28 am

Re: Report bitmap

Post by chrisgeorge » Tue Sep 15, 2009 1:52 pm

Has anyone actually managed to get a bitmap to display in a report?

We're generating image diff's and using LogData I tried displaying one of these diff Bitmap's in a report but it just displays nothing. Viewing the generated html (using Firefox plugin WebDeveloper) shows that the RanorexReport.xsl does not seem to be handling the image part of the xml.

I'm using 2.1.4.
Chris George
Test Engineer

Red Gate Software Ltd
Cambridge

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Report bitmap

Post by Support Team » Tue Sep 15, 2009 2:12 pm

Yepp, I have using the following code :-)
Report.LogData(ReportLevel.Info, "SomeCategory", Imaging.CaptureImage(Host.Local));
// or ...
Report.LogData(ReportLevel.Info, "SomeCategory", Host.Local.CaptureCompressedImage().Image);
Just be sure that the type of the data you log is System.Drawing.Bitmap! That should work with all Ranorex 2.X versions.

Regards,
Alex
Ranorex Support Team

chrisgeorge
Posts: 49
Joined: Thu Aug 20, 2009 11:28 am

Re: Report bitmap

Post by chrisgeorge » Tue Sep 15, 2009 2:22 pm

Hmm... I've used ReportLevel.Failure, does that matter? and yes I'm using a System.Drawing.Bitmap.

It is outputting the images (as jpg's) to disk, and it references them in the xml, but when viewing the xml in either the ranorex log viewer, or a web browser, it does not display them.


Chris
Chris George
Test Engineer

Red Gate Software Ltd
Cambridge

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Report bitmap

Post by Support Team » Tue Sep 15, 2009 3:18 pm

You are right, the RanorexReport.xsl does not handle images right if the ReportLevel is different from Info. We'll correct that for the next version. Meanwhile, I attached the fixed RanorexReport.xsl to this post (contained in package RanorexReport.zip).

Regards,
Alex
Ranorex Support Team
You do not have the required permissions to view the files attached to this post.

chrisgeorge
Posts: 49
Joined: Thu Aug 20, 2009 11:28 am

Re: Report bitmap

Post by chrisgeorge » Tue Sep 15, 2009 4:46 pm

Cool! Yes that works. Is the xsl generated on the fly by Ranorex? or is it stored somewhere that I can overwrite with the one you sent?
Chris George
Test Engineer

Red Gate Software Ltd
Cambridge

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Report bitmap

Post by Support Team » Tue Sep 15, 2009 5:22 pm

No, sorry, it is generated on the fly, so you can't just replace anywhere in the install directory. But you can replace it right after you call the Report.Setup method using your own file, i.e. the XSL will be generated by the Report.Setup method. So if you overwrite it afterwards with the fixed XSL, the fixed XSL should be used.

In the next Ranorex version (2.2.0) we add the functionality to configure a custom XSL file that is then referenced by the report files.

Regards,
Alex
Ranorex Support Team

chrisgeorge
Posts: 49
Joined: Thu Aug 20, 2009 11:28 am

Re: Report bitmap

Post by chrisgeorge » Wed Sep 16, 2009 9:09 am

Ok, I've worked around it by using acombination of nunit asserts to mark the failure, then recording the failure in the log with ReportLevel.Info. It will do for now!

Thanks for your help!
Chris George
Test Engineer

Red Gate Software Ltd
Cambridge