Forum Discussion

msap's avatar
msap
Frequent Contributor
7 years ago

how to compare validation error messages using test complete

hi

I got a validation error message which is correct how to compare expected  and actual have same validation error message boxes.

any suggestions.

 

 

8 Replies

  • Iamvinod's avatar
    Iamvinod
    Occasional Contributor

    Expected = "Attribute Level and Attribute Type must be selected"

    Prop = "ContentText"

    Set Obj = Sys.Browser().FindChild(PropName, PropValue ,30)
    Actual = aqObject.GetPropertyValue(Obj, Prop)

     

    If Expected = Actual then

    Log.message "Validation Passed"

    Else

    Log.message "Validation Failed"

    End If

    • msap's avatar
      msap
      Frequent Contributor

      martin:

       

      Could you please give some suggestions for validation messages comparision.

      I have written below:


      xtraMessageBoxForm.Click(126, 12);
      Expected="Some errors occurred during validation"
      //PropArray= new Arry("WndCaption","Error")
      PropName ="ContentText"
      Prop="WndCaption"
      PropValue="Some errors occurred during validation"
      Obj = Aliases.Framework.ExcelImportForm.grid.FindChild(PropName,PropValue,30)
      Actual=aqObject.GetPropertyValue(Obj,Prop)

      If(Expected == Actual)

      Log.message("Validation Passed")

      Else

      Log.message("Validation Failed")

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Well, I would throw out the code you have.  It really doesn't do what you think it does.  Here's what I read:

         

        1) Take a piece of text

        2) Go find an object that contains that piece of text

        3) Compare the piece of text to the text contained in the object

         

        Basically, you are finding an apple by looking for apples and then making sure it's an apple.  

         

        I would simplify it down to identifying the object by some value OTHER than the error text you're looking for.  No, don't ask me what properties to use... I don't know your application or your object.  Just look for the object first using some generic parameters that identify the object.

         

        Then simply do something like 

         

        EDIT:  I looked at your screenshot and it looks like a straight forward window.  So...  

         

        Obj = Aliases.Framework.ExcelImportForm.grid.FindChild('WndCaption', 'Error',30)

        if (Obj.contentText != 'Some errors occurred during validation')

           Log.Error('Validation Failed')

        else Log.Message('Validation Passed')