Forum Discussion

pashooo's avatar
pashooo
Contributor
13 years ago

Expected value: true & Actual value: true - give an error!!!

This code generate strange error:

aqObject.CheckProperty(Aliases.OptionsWorkshop.HwndSource_ScheduleForm, "Exists", cmpNotEqual, true);



TC says error message:


































Object: Sys.Process("OptionsWorkshop").WPFObject("HwndSource: ScheduleForm",

"Activity schedule")
Property: Exists


































Expected value: true
Actual value: true

The object really exists.

Log.zip is attached

4 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    If you are looking to test if an object exists, CheckProperty is not necessarily the best way to do so.



    I would suggest code more like



    var ScheduleFormObject = Aliases.OptionsWorkshop.WaitAliasChild("HwndSource_ScheduleForm")

    if (ScheduleformObject.Exists) then

    {

        Log.Message("The form exists")

    }

    else

    {

        Log.Warning("The form does not exist")

    }




    While this does not answer your question, it may head off future problems of attempting to check the property of a non-existant object.
  • yeah! I know about such way. I tried it but TC couldnt find object therefore.



    But the problem is that object exists, and TC says actaul value==true, expected value==true, but its errror.



    I was confused a bit. But today the error dont occur any more. Dont konow what is it...
  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Pasha,



    aqObject.CheckProperty(Aliases.OptionsWorkshop.HwndSource_ScheduleForm, "Exists", cmpNotEqual, true);
    You're using the cmpNotEqual condition here, which means that the checkpoint passes if Exists is not True (that is, if it's False) and fails if Exists is True. So, the checkpoint result is perfectly correct.



    Actually, property checkpoints aren't aimed at checking whether an object exists — they are aimed at checking properties of already existing objects. So, I recommend that you use the approach that Robert suggested instead.