Take a screenshot and use it to compare

Ask general questions here.
dkmpbrt
Posts: 6
Joined: Thu Jan 25, 2018 9:00 am

Take a screenshot and use it to compare

Post by dkmpbrt » Thu Feb 22, 2018 4:28 pm

Hey All,

First, let me give a general idea of what i'm doing. At this moment i'm automating a google map-like map. I can draw a polygon on it and save it. After it is saved, it will show an image of the map with the polygon on it.

Now I want to take a screenshot of that image and use it in a later recording to compare it.

How can one do that?

Thanks,
Bart

User avatar
RobinHood42
Posts: 238
Joined: Fri Jan 09, 2015 3:24 pm

Re: Take a screenshot and use it to compare

Post by RobinHood42 » Fri Feb 23, 2018 2:06 pm

Hi dkmpbrt,

Please check out the following links/discussions:
Hope this helps.

Cheers,
Robin

dkmpbrt
Posts: 6
Joined: Thu Jan 25, 2018 9:00 am

Re: Take a screenshot and use it to compare

Post by dkmpbrt » Fri Feb 23, 2018 7:10 pm

Hey Robin,

Thanks for your answer, this already helps, but i'm just not sure on how to save an image of a repository item at run time. Probably this will be in C# but I don't think the Ranorex.Screenshot() will be of any use because it is purely used as reporting, no?

Thx,
Bart

User avatar
RobinHood42
Posts: 238
Joined: Fri Jan 09, 2015 3:24 pm

Re: Take a screenshot and use it to compare

Post by RobinHood42 » Mon Feb 26, 2018 10:32 am

Hey Bart,

You could use the following code to create a screenshot during runtime.

Sample: Creates s screenshot of a button element and logs it to the Ranorex report
public void Report_Screenshot_Button1(RepoItemInfo buttonInfo)
        {
        	var bla = Ranorex.Imaging.CaptureImageAuto(buttonInfo.FindAdapter<Button>());
        	Report.LogData(ReportLevel.Info, "User", bla);
        }
Cheers,
Robin