Forum Discussion

Oferv's avatar
Oferv
Super Contributor
14 years ago

WaitProperty stop the script instead of moving on to Else

Hi,



can anyone explain me pls why the bold line, in case it's False, stop my script from running instead of moving on to the else statement?




if(Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["WPFObject"]("ContentPanel")["WPFObject"]("PART_SelectedContentHost")["WPFObject"]("AssemblyViewTabControl")["WPFObject"]("Grid", "", 1)["WPFObject"]("Grid", "", 1)["WPFObject"]("UserControl")["WPFObject"]("UserControl")["WPFObject"]("TabItem", "", NumberOfTabs)["WPFObject"]("UserControl")["WPFObject"]("StackPanel", "", 1)["WaitWPFObject"]("TextBlock", FileWithoutExt, 10000)["Exists"])    

    {

    Log["Message"]("File " + "'" + File + "'" + " opened properly,New tab was created for it")  

    //Stop the time counter 

    TimeToolDocumentFullyLoad.Stop();

    // Posts the elapsed time to the test log 

    Log.Message("The time took the document to load is : " + TimeToolDocumentFullyLoad.ToString());

    }

  else

    {

    Log["Warning"]("File " + "'" + File + "'" + " wasn't open properly,No tab created")

    }               


Thanks

15 Replies

  • Oferv's avatar
    Oferv
    Super Contributor
    Hi Margaret,



    sorry for the delay i thought i solved this one but i didn't.

    i'm dealing with a similar problem.



    why this line is working:



    Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["WaitWPFObject"]("Grid", "", 1)["Exists"]



    while this line is not:



    Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["WPFObject"]("Grid", "", 1)["Exists"]



    the only different is WPFObject via WaitWPFObject i'm sorry but i don't understand why



    if(Object.exists) doesn't work why do i have to use the Wait in order for it to work?



    Thanks
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    The reason for this is that in the case where the object does not exist, you cannot call the "Exists" property.  Just like you can't call the "Name" property for a non-existant object.



    The WaitWPFObject method, if the object does not exist, will return an empty object with an Exists property that is set to false.  Meanwhile, WaitWPFObject will wait up until the Auto-wait timeout for the object to exist while WPFObject tries to get it immediately.



    The WaitWPFObject method is actually the recommended method to use to test "Exists" for this reason.
  • Oferv's avatar
    Oferv
    Super Contributor
    Thx Robert,

    So, what you're saying that in this case for example:

    Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["WPFObject"]("Grid", "", 1)["Exists"]



    if this object Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"] doesn't exist i have no reason to look for Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["WPFObject"]("Grid", "", 1) existance because ("Grid", "", 1) is a child object of ["PART_SelectedContentHost"].



    is that true?