Page 1 of 1

Image Validation based on a Variable Value

Posted: Mon Apr 15, 2019 9:37 am
by Lyuba Boerma
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 !

Re: Image Validation based on a Variable Value

Posted: Mon Apr 15, 2019 10:43 am
by odklizec
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

Re: Image Validation based on a Variable Value

Posted: Mon Apr 15, 2019 12:02 pm
by Lyuba Boerma
Thank you!
You are right! ( as always :D )

Now it works!)