Validate.ContainsImage is causing a 'Ranorex.ImageValidationException'

Ask general questions here.
martynf
Posts: 2
Joined: Wed Sep 02, 2020 2:23 pm

Validate.ContainsImage is causing a 'Ranorex.ImageValidationException'

Post by martynf » Wed Sep 02, 2020 2:28 pm

I am validating if a Cell is checked, or not.
This Cell is part of a Table, and does not have a "Checked" property, so we need to compare the Cell image against a stored image, coding in c#.

When running, the following information is available: "'ex' threw an exception of type 'Ranorex.ImageValidationException'"

This worked in Ranorex v8.3.2, but throws an exception following an upgrade to Ranorex v9.3.2 (the project was rebuilt successfully).

Has anyone come across this issue, or any ideas of why it might be causing an exception?

try
{
bool bIsUnChecked = Validate.ContainsImage(
c,
Table_Cell_WinXP_Check_FALSE_32021414,
ImagingFindOptions995,
sValidateMessage,
validateOptionsDebug);
}
catch(Exception ex)
{
throw new ApplicationException("Something wrong in the Validate.ContainsImage function :", ex);
}

Extract of the declarations for the above variables:
Cell c

public static CompressedImage Table_Cell_WinXP_Check_FALSE_32021414
{ get { return repo.Application_Image_Picker.Container.Table_CellInfo.GetWinXP_Check_FALSE(new Rectangle(34, 2, 14, 14)); } }

public static Imaging.FindOptions ImagingFindOptions995
{ get { return Imaging.FindOptions.Parse("0.995;None;0,0,0,0;True;10000000;0ms"); } }

string sValidateMessage = "";

public static Validate.Options validateOptionsDebug =
new Validate.Options(false,
ReportLevel.Debug,
ReportLevel.Debug,
Validate.ResultOption.Never);

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

Re: Validate.ContainsImage is causing a 'Ranorex.ImageValidationException'

Post by odklizec » Fri Sep 04, 2020 6:44 am

Hi,

Could you please recreate the validation with Ranorex recording actions, at first with default settings, then with your image validation settings used in code? Just to see if Ranorex validates the image OK or if it's a matter of settings.
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

martynf
Posts: 2
Joined: Wed Sep 02, 2020 2:23 pm

Re: Validate.ContainsImage is causing a 'Ranorex.ImageValidationException'

Post by martynf » Tue Sep 08, 2020 3:15 pm

Thank you for your response.

I have re-created this as a recording action with default settings, which results in a failure validation, as the images do not compare.
This is as expected.
Note: I didn't use the original comparison image from C#, I used the image captured as part of the recording action.

Then, I converted this to user code.
I did look at the Args that can be added, but an image was not listed in the drop down list, which is the next setting in the C# code.

I'm not sure how to add all of the original settings.

I'm really new to Ranorex and C#. Please can you advise how to do this next stage?