Forum Discussion

Dénésys's avatar
Dénésys
New Contributor
10 years ago

Exists methode on WPFobject

Hi,

 

I'm a starter on TestComplete and I search a methode for check if my window exist. I know the methode "Exist" but it seems that it don't work on my problem.

 

I explain :

Two kind of window can apear when I click on a button :

Sys.Process("SEE").WPFObject("HwndSource: *CadDialog", "*").WPFObject("*CadDialog", "*", 1).WPFObject("Grid", "", 1).WPFObject("CADContent").WPFObject("CADControl").WPFObject("Grid", "", 1).WPFObject("seePropertyCard").WPFObject("barPropertyCard")

or

Call Sys.Process("SEE").WPFObject("HwndSource: *CadDialog", "*").WPFObject("*CadDialog", "*", 1).WPFObject("Grid", "", 1).WPFObject("CADContent").WPFObject("TabControl").WPFObject("CADControl").WPFObject("Grid", "", 1).WPFObject("seePropertyCard").WPFObject("barPropertyCard") 

 

In the first version I've got "TabControl" and in the second not.
When I try a Exists methode ion the second or on the first TestComplete said :

Unable to find the object WPFObject("TabControl"). or Unable to find the object WPFObject("CADControl").

 

Thanks for your help !

  • sbkeenan's avatar
    sbkeenan
    Frequent Contributor

    Hi

     

    I think that you might be trying to test the Exists property of an object that doesn't actually exist.  This will cause an error.  You can only check the Exists property of an object when it actually exists, so in order to get round this you will need to use one of the wait methods, such as waitChild() or waitAliasChild().  You can read about how/when to use these in the online help - just search for the method name.

     

    Basically, what they do is wait for a specified amount of time for the object to 'appear', if it doesn't then it returns a stub object with just the Exists property, which will be set to false.  Your test will then be able to pick this up and move on without crashing out.

     

    Hope this helps.

     

    Regards

    Stephen.

    • Dénésys's avatar
      Dénésys
      New Contributor

      Hi sbkeenan,

       

      You are absoluty right ! I doesn't understand the Exists methode like that ! It a bit strange that for this methode the item need to exists for test if it exists ! But I understand your methode with waitChild and I will test on my script !

       

      Thank a lot for your answer !

       

      EDIT : I tried this :

      if Sys.Process("SEE").WPFObject("HwndSource: *CadDialog", "*").WPFObject("*CadDialog", "*", 1).WPFObject("Grid", "", 1).WPFObject("CadContent").WaitChild("TabControl").Exists = False Then

      Console.message("OK")

      else

      Console.message("not OK")

       

      But in all the case "OK" is write. I tried with WaitAliasChild too same... I do it wrong ?