Is there any method to check whether the image is exist or not

Ask general questions here.
premravi
Posts: 128
Joined: Tue Jan 08, 2019 1:55 pm

Is there any method to check whether the image is exist or not

Post by premravi » Fri Sep 13, 2019 2:28 pm

Hi,

In my application there are few elements which are not identifiable using Ranorex spy,

So to perform any operations on it I am using image based validation,

Now, the scenario is just to verify whether the image exists or not, if exist "pass" else "fail",

I am not able to achieve this using .exist , .visible , .ensurevisible methods

Please suggest me which method can I use to just verify whether the image is present or not

Regards

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

Re: Is there any method to check whether the image is exist or not

Post by odklizec » Mon Sep 16, 2019 8:15 am

Hi,

Is there something wrong with Validate - Compare Image/Contains Image action? This is exactly what's the Validate action for.
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: 515
Joined: Fri Jul 15, 2016 1:35 pm

Re: Is there any method to check whether the image is exist or not

Post by Stub » Mon Sep 16, 2019 8:17 am

Have a look at Ranorex.Imaging.

premravi
Posts: 128
Joined: Tue Jan 08, 2019 1:55 pm

Re: Is there any method to check whether the image is exist or not

Post by premravi » Mon Sep 16, 2019 11:28 am

Hi,

Thanks a lot for your valuable solutions,

I tried Validate.containsImage and its working

On top of it one quick doubt is

Do we need to right the validate contians code inside if else condition
OR
Directly we can right validate contain image code (single line code)

Because Validate.ContainsImage is a bool method and it will anyway return true or false

Please suggest me here

Regards

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

Re: Is there any method to check whether the image is exist or not

Post by odklizec » Mon Sep 16, 2019 12:26 pm

Hi,

You can make the Validation method to throw exception (if validation fails) by setting exceptionOnFail parameter to True.
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