Accessing Snapshot Screenshot

Class library usage, coding and language questions.
ALauden
Posts: 3
Joined: Mon Mar 06, 2017 9:40 pm

Accessing Snapshot Screenshot

Post by ALauden » Tue Mar 07, 2017 6:01 am

Hello,

I am having trouble trying to access the screenshot that is saved as part of a Ranorex Snapshot.

Whenever I try to access the ScreenShot property of an ElementSnapshot object the ScreenShot property is null.
The snapshot displays the screenshot when opened using the Spy utility and the screenshot element is present in the Snapshot xml.
This happens no matter what Snapshot I load whether I use CreateFromFile or Capture an element.

I have attached a sample Snapshot that I have taken of the Windows Calculator app.

I am running Ranorex 6.2.1 on Windows XP and Windows 7.

Any help would be appreciated.
Attachments
CalcSnapshot.rxsnp
(29.28 KiB) Downloaded 37 times

McTurtle
Posts: 191
Joined: Thu Feb 23, 2017 10:37 am
Location: Benedikt, Slovenia

Re: Accessing Snapshot Screenshot

Post by McTurtle » Tue Mar 07, 2017 3:13 pm

Hello ALauden,

Welcome to the Ranorex forum.

Could you explain a bit more in detail the actual use case? You are probably trying to do some validation. Maybe there exists a simpler way than to access screenshots from a snapshot.

Regards,
McTurtle

ALauden
Posts: 3
Joined: Mon Mar 06, 2017 9:40 pm

Re: Accessing Snapshot Screenshot

Post by ALauden » Tue Mar 07, 2017 4:03 pm

Hello McTurtle,

I am using the snapshot to compare gui elements to some baseline snapshot to spot changes between versions.

This all works well but it would be nice to include a screenshot of the snapshot on the report so that reviewers can quickly and easily view the differences.

It seemed like that would be possible using a line like this:

Code: Select all

Report.LogData(ReportLevel.Info, "Screenshot", "Screenshot from snapshot:", snapshot.ScreenShot.Image);
But no matter how I create the snapshot object the ScreenShot property is null.

McTurtle
Posts: 191
Joined: Thu Feb 23, 2017 10:37 am
Location: Benedikt, Slovenia

Re: Accessing Snapshot Screenshot

Post by McTurtle » Fri Mar 10, 2017 8:02 am

Hello ALauden,

I am sorry it took so long, I was a bit swamped.

Below is an example for putting a screenshot of the whole application from the snapshot into the report.
ElementSnapshot snapshot = ElementSnapshot.CreateFromFile("...path to snapshot...");

var screenshot_1_compressed=snapshot.Element.CaptureCompressedImage();

Bitmap screenshot_2_uncompressed=screenshot_1_compressed.Image;
        	 	
Report.LogData(ReportLevel.Info,"Info",screenshot_2_uncompressed);
It seems, your recipe was missing just "Element.CaptureCompressedImage()".

Please let me know if this was helpful.

Regards,
McTurtle

ALauden
Posts: 3
Joined: Mon Mar 06, 2017 9:40 pm

Re: Accessing Snapshot Screenshot

Post by ALauden » Fri Mar 10, 2017 4:32 pm

Hello McTurtle,

Looks like that did it.

Thanks,
Alauden