Page 1 of 1

Accessing Snapshot Screenshot

Posted: Tue Mar 07, 2017 6:01 am
by ALauden
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.

Re: Accessing Snapshot Screenshot

Posted: Tue Mar 07, 2017 3:13 pm
by McTurtle
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

Re: Accessing Snapshot Screenshot

Posted: Tue Mar 07, 2017 4:03 pm
by ALauden
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.

Re: Accessing Snapshot Screenshot

Posted: Fri Mar 10, 2017 8:02 am
by McTurtle
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

Re: Accessing Snapshot Screenshot

Posted: Fri Mar 10, 2017 4:32 pm
by ALauden
Hello McTurtle,

Looks like that did it.

Thanks,
Alauden