How to do image based validation without ranorex recording?

Ask general questions here.
AutomationTester
Posts: 30
Joined: Mon Jan 21, 2013 1:31 pm

How to do image based validation without ranorex recording?

Post by AutomationTester » Mon Jan 21, 2013 1:41 pm

Hai,
How to do image based validation without ranorex recording module? My application is based on WPF. After placing an image from folder to application, I have to validate the image, whether it is same as in folder or not.
please help..

thanks and regards
Amir aka AutomationTester

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

Re: How to do image based validation without ranorex recording?

Post by Support Team » Mon Jan 21, 2013 6:00 pm

Hello,

You could use dynamic image validation in User Code as shown in the attached example.
Please take a look at the method 'CheckContainsExternal'.

Please let me know if you need further information.

Regards,
Markus (T)
You do not have the required permissions to view the files attached to this post.

AutomationTester
Posts: 30
Joined: Mon Jan 21, 2013 1:31 pm

Re: How to do image based validation without ranorex recording?

Post by AutomationTester » Tue Jan 22, 2013 5:49 am

Hai Markus,

You are showing me the demo using recording module. I saw the code for image comparison in your file. It's not working when I use it in normal cs file. Can you please write the code in cs file and send me?

Thanks and regards,
Amir aka AutomationTester

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

Re: How to do image based validation without ranorex recording?

Post by Support Team » Tue Jan 22, 2013 4:51 pm

Hello,

I assume that you are using Visual Studio. Is that correct?
Please find attached a short example how you could use image validation in Visual Studio.

You could use the method 'Ranorex.Imaging.Compare(Bitmap image, Bitmap feature, Double similarity)' in your test. Please take a look at this 'code example' in our User Guide.

Regards,
Markus (T)
You do not have the required permissions to view the files attached to this post.

AutomationTester
Posts: 30
Joined: Mon Jan 21, 2013 1:31 pm

Re: How to do image based validation without ranorex recording?

Post by AutomationTester » Wed Jan 23, 2013 8:44 am

Hai Markus,

I'm using Ranorex and I want to compare images using code and not by recording. I used your suggested code in my module. In my report, Both images are same but ranorex throws an error of "Module execution was aborted because a validation step has failed. Trying to find image at path: 'C:\Users\****\Desktop\Images\MonalbumPhoto_JPG_Smiley.jpg' ".

The path is correct. I'm attaching screen shot of report and code . Please help with this problem.

Code: Select all

string picturepath = "C:\\Users\\****\\Desktop\\Images\\MonalbumPhoto_JPG_Smiley.jpg";
         Image currentPicture = Image.FromFile(picturepath);
        	        	
        Imaging.FindOptions imgFindOptions = new Imaging.FindOptions(0.1);
        Validate.Options valOptions = new Validate.Options();
        
        // runtime validation by using the repository object
        Validate.ContainsImage(workarearepo.Tabpagelist.NewlyAddedImage.ImgCanvasInfo, (System.Drawing.Bitmap) currentPicture, imgFindOptions, "Trying to find image at path: '" +picturepath+"'");
If you want anything more. let me know.
Regards,

Amir aka AutomationTester

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

Re: How to do image based validation without ranorex recording?

Post by Support Team » Wed Jan 23, 2013 4:48 pm

Hello,

Could you please try to add a timeout to your options as shown below?
int timeOut = 5000;
imgFindOptions.Timeout = timeOut;
Could you please post a 'Ranorex Snapshot' of your application in order to analyze this issue?
Please take a look at section 'Creating Ranorex Snapshot Files' in our User Guide.

Regards,
Markus (T)

AutomationTester
Posts: 30
Joined: Mon Jan 21, 2013 1:31 pm

Re: How to do image based validation without ranorex recording?

Post by AutomationTester » Thu Jan 24, 2013 7:37 am

Dear Markus,

Due to software credentials, I can't send u the Ranorex snapshot. I have attached a snap of png.
Hope this helps.
Pic snap.png
Thanks and regards,

Amir aka AutomationTester
You do not have the required permissions to view the files attached to this post.

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

Re: How to do image based validation without ranorex recording?

Post by Support Team » Thu Jan 24, 2013 5:51 pm

Hello,

Is the resolution of your images the same?

Could you please send us your report to [email protected]?
A Ranorex Snapshot would really help a lot to analyze this issue.

Regards,
Markus (T)