Image validation through saved screenshot

Ask general questions here.
sanoyag
Posts: 7
Joined: Fri May 12, 2017 9:40 am

Image validation through saved screenshot

Post by sanoyag » Mon Jun 05, 2017 3:54 am

Hi all,

I would like to ask if is there a way for me to validate and compare an image from screenshots that I have saved in a folder? Like for example, I would need to compare images from the repository to the saved images that I have inside a folder. So if I would need to test something new, I would just update the images contained in that folder and compare it again with the repository item. Is it possible to do this? Also, after doing my test cases I compile it into an executable file, so I was wondering how can the saved images in my folder be copied onto my compiled executable file, i.e. I would only need to update/change the screenshots from that folder and then run the tests again. Thank you so much in advance. This is my first time doing the image validation and I am really still confused.

sanoyag
Posts: 7
Joined: Fri May 12, 2017 9:40 am

Re: Image validation through saved screenshot

Post by sanoyag » Mon Jun 05, 2017 4:41 am

My apologies...I just realized now that I would also need to update the image in the repository if I would update the images in the folder..Is it also possible to update the image in the repository? Thank you so much...

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3921
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Image validation through saved screenshot

Post by odklizec » Mon Jun 05, 2017 7:39 am

Hi,

Are you sure the image validation is the only way to validate something in your app? You see, the image validation should be used only in case, there is no other way to validate the elements via "normal" GUI validation. And even then, it's most reliable with small pictures. The bigger picture you want to validate, the greater chance it will fail due to a false positive error (e.g. because of different text or size of GUI element in a part of image that does not interest you at all).

Anyway, I don't think there is a way to automatically recreate repo screenshots, except doing it manually in Studio? As for validating images stored in a folder, it should be possible via code. Check for example this post:
loading-image-from-a-project-in-user-co ... tml#p33970
And I'm sure, you can find some more posts regarding this topic.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

User avatar
Stub
Posts: 173
Joined: Fri Jul 15, 2016 1:35 pm

Re: Image validation through saved screenshot

Post by Stub » Mon Jun 05, 2017 8:18 am

I just load the saved image:

Code: Select all

Bitmap expected_image = Ranorex.Imaging.Load(filename_goes_here);
And validate or compare:

Code: Select all

Ranorex.Validate.CompareImage(element, expected_image, find_options, description, validate_options);

Ranorex.Imaging.Compare(element, expected_image, find_options);
I try to do element validation through the API where I can, but for graphical elements I use saved images.

sanoyag
Posts: 7
Joined: Fri May 12, 2017 9:40 am

Re: Image validation through saved screenshot

Post by sanoyag » Mon Jun 05, 2017 11:47 am

Thank you so much! Yes, image validation is needed since I need to compare if the image logo of the model is what is expected. I tried to go through the link you have given and I was able to build successfully. But, on the logs, it shows Failed to load bitmap from file 'c:\path\Images\specific_image.png'.
c:\path\Images\specific_image.png . I am also not sure of the path where the images folder would really be on this path when I copy the exe file to a test pc. From what I understood, the code string path = Ranorex.Core.Testing.TestSuite.WorkingDirectory; was for getting the path of debug/release directory right? So my directory of loading the image may be wrong? Because what if the exe file is in the desktop? Is that why it failed on the logs even though I loaded correct images? Thank you so much in advance. I'm still really new here in learning ranorex...

User avatar
Stub
Posts: 173
Joined: Fri Jul 15, 2016 1:35 pm

Re: Image validation through saved screenshot

Post by Stub » Tue Jun 06, 2017 8:39 am

Once you know the binary's output folder you can use that as a basis for a relative path to a known folder e.g. by appending "..\..\images\image.png" to that path. I output my Ranorex test binaries to a fixed path in the folder structure of my test code so that I can judge where it needs to go to find an image file.

Hondo
Posts: 43
Joined: Thu Nov 03, 2016 12:03 am

Re: Image validation through saved screenshot

Post by Hondo » Thu Dec 07, 2017 2:24 am

I think I've run into this limitation using the Ranorex interface.
Is it absolutely necessary to load the image via code? I could use a snippet, no?

This is the kind of image I need to validate.
rrVersion.jpg
rrVersion.jpg (24.39 KiB) Viewed 944 times
I've had successful validations on the entire image and on small subsections.
HOWEVER, after the first pass, the Validation continues to Pass even after the image on screen has changed (False positive).

Any help would be appreciated.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3921
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Image validation through saved screenshot

Post by odklizec » Thu Dec 07, 2017 8:52 am

Hi,

I really doubt such kind of image could be consistently validated with Ranorex? The reason why you get false positives is most probably not optimally set Similarity value? Have you tried to increase Similarity value?

To be honest, I would never consider using Image validation for anything other than small and pretty simple images, with regular patterns. Ranorex image validation is meant to be used with UI and small images. Using it for large and complicated images is most probably a not very good idea ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration