Hi,
I am not using ranorex recording to capture my images. I am using spy to capture the screenshot and then save it as a png file.
Now I am running my application I have to make sure this captured image matches with the application page.
How can I do it ? I have tried to use imaging.Contains method, but my image was not found.
Plese help
Thanks,
Image comparion without using repository
Re: Image comparion without using repository
Here is code i use:
I found, that Spy can add few pixels on the edge, so i use following construct to remove few pixels from the edge:
But i found, that it doesn't work in 100% cases. I found, that sometimes my code fails, but if i use Ranorex Validation - it will pass. Can someone explain why?
Code: Select all
Bitmap image = Imaging.Load ("ScreenShot.png");
Validate.ContainsImage (repo.FormOIS_WinStation_11_EyeSca.Element59648Info,
image.Clone ( new Rectangle (3,3,image.Width-6,image.Height-6),image.PixelFormat),
Imaging.FindOptions.Default,
"Validation: All figures are correctly drawn");
Code: Select all
image.Clone ( new Rectangle (3,3,image.Width-6,image.Height-6),image.PixelFormat)
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Image comparion without using repository
The only difference is that Ranorex uses its own Ranorex.Imaging.Crop method instead of the Bitmap.Clone method. You might try to replace the call to Clone with Imaging.Crop.slavikf wrote:But i found, that it doesn't work in 100% cases. I found, that sometimes my code fails, but if i use Ranorex Validation - it will pass. Can someone explain why?
Regards,
Alex
Ranorex Team
Re: Image comparion without using repository
Hi slavikf ,
Thanks for your reply, But I am not using repository. What can be used in place of "repo.FormOIS_WinStation_11_EyeSca.Element59648Info.."
Thanks,
Thanks for your reply, But I am not using repository. What can be used in place of "repo.FormOIS_WinStation_11_EyeSca.Element59648Info.."
Thanks,
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Image comparion without using repository
Any Ranorex element. See the method overloads in the Ranorex Validate class API:Saha wrote:What can be used in place of "repo.FormOIS_WinStation_11_EyeSca.Element59648Info.."
http://www.ranorex.com/Documentation/Ra ... lidate.htm
Regards,
Alex
Ranorex Team
Re: Image comparion without using repository
I can suggest following code:
Bitmap current = Imaging.CaptureImage (repo.FormOIS_WinStation_11_EyeSca.Element59648);
You can use some like that:
Bitmap current = Imaging.CaptureImage (Element);
And you can generate Element in Runtime. See here for details:
http://www.ranorex.com/Documentation/Ra ... eImage.htm
public static void imagesCompare (Bitmap expected, Bitmap actual, String success, String error) { if (Imaging.Compare (expected, actual)==1) Report.Success (success); else { Report.Failure (error); Report.LogData (ReportLevel.Error, "Expected", expected); Report.LogData (ReportLevel.Error, "Actual", actual); } } Bitmap current = Imaging.CaptureImage (repo.FormOIS_WinStation_11_EyeSca.Element59648); Bitmap image = Imaging.Load ("TC244.png"); imagesCompare (image, current, "TC244: correct image", "TC244: image is incorrect!");And instead of repo:
Bitmap current = Imaging.CaptureImage (repo.FormOIS_WinStation_11_EyeSca.Element59648);
You can use some like that:
Bitmap current = Imaging.CaptureImage (Element);
And you can generate Element in Runtime. See here for details:
http://www.ranorex.com/Documentation/Ra ... eImage.htm