Image Validation based on a Variable Value

Class library usage, coding and language questions.
Lyuba Boerma
Posts: 27
Joined: Mon Apr 01, 2019 12:12 pm

Image Validation based on a Variable Value

Post by Lyuba Boerma » Mon Apr 15, 2019 9:37 am

Hi)
I am trying to use Image validation based on a value of variable.
with a If - else construction
One repoelement has different screenshots , based on previous user actions.
I am trying to do something like this

Code: Select all

public void Validate_Barcode_Image(RepoItemInfo imgtagInfo)
        {
        	
        if (varBarcodeValue.Equals("111111"))
        		
        {
          Report.Log(ReportLevel.Info, "Validation", "Validating ContainsImage (Screenshot: 'Screenshot1' on item 'imgtagInfo'.", imgtagInfo);
           Validate.ContainsImage(imgtagInfo, Barcode_Image_Screenshot1, Barcode_Image_Screenshot1_Options);
        }
          Report.Log(ReportLevel.Info, "Validation", "Validating ContainsImage (Screenshot: 'Screenshot2'   on item 'imgtagInfo'.", imgtagInfo);
          Validate.ContainsImage(imgtagInfo, Barcode_Image_Screenshot2, Barcode_Image_Screenshot2_Options);
         }
               
 
but i get an error "The name 'Barcode_Image_Screenshot2' does not exist in the current context (CS0103)
The name 'Barcode_Image_Screenshot2_Options' does not exist in the current context (CS0103)

I am validating same repoelement, but with different screenshots... So i don't know how to add this attributes to me conditions
Please help me to get it work)
i know nothing about c#.. And i would appreciate any help.

Thanks !

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

Re: Image Validation based on a Variable Value

Post by odklizec » Mon Apr 15, 2019 10:43 am

Hi,

I guess you copied part of the validation code from recording's 'cs' file? But you most probably forgot to copy also "Image Feature Data", as described here:
image-validation-user-code-issue-t10263.html#p41188
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

Lyuba Boerma
Posts: 27
Joined: Mon Apr 01, 2019 12:12 pm

Re: Image Validation based on a Variable Value

Post by Lyuba Boerma » Mon Apr 15, 2019 12:02 pm

Thank you!
You are right! ( as always :D )

Now it works!)