Forum Discussion

vthomeschoolmom's avatar
vthomeschoolmom
Super Contributor
13 years ago

selecting a treeview node

From the help file, I see that I can use the ClickItem method of the treeview control.



treFolder.ClickItem "|Desktop|My Computer|Local Disk (C:)|TestCompleteScripts|App9.11.10|AppRegressionTests|SupportingFiles"



where treFolder is an variable reference to a treeview object. (VB6, class SysTreeView32).



The string I am using was the string test Compelte recorded when I recorded the snippet in use. But when I execute this line of code I receive the error:



"The TreeView node 'AppRegressionTests' not found. " 



Yah I can SEE it right there. TC found it when it was recording. TC finds everything UP to that folder/node?



Can someone help me see what I am doing wrong here? (Please note that the actual string is longer since I changed the names of the controls and forms to protect our privacy. Further note that this is Test Complete 7.)



Thanks.

1 Reply


  • Hello Lane,





    A similar problem was fixed in TestComplete 8.50. However, if you cannot update to this version for some reason, use the following script as a workaround:











      path = "|Desktop|My Computer|Local Disk (C:)|TestCompleteScripts|App9.11.10|AppRegressionTests|SupportingFiles"  

      Call ExpandPath(treFolder, path)  

      Call treFolder.ClickItem.ClickItem(path)

      

    Sub ExpandPath(TreeView, path)

      Dim items, treeItems,itemFound

      Dim i, j, start

      items = Split(path, "|")

      TreeView.Refresh()

      Set treeItems = TreeView.wItems

      itemFound = True





      Log.Enabled = False  

      start = 0

      If items(0) = "" Then

         start = 1

      End If 

      For i = start to UBound(items)

        Dim currentItem, timeout, time

        Set currentItem = Nothing

        timeout = 20000

        time = Win32API.GetTickCount()

        While(Win32API.GetTickCount() - time < timeout AND currentItem Is Nothing)

          For  j = 0 to treeItems.Count - 1

            If( treeItems.Item(j).Text = items(i)) Then 

              Set currentItem =  treeItems.Item(j)

              Exit For

             End if 

          Next 

        Wend

        If(Not currentItem Is Nothing) Then

          currentItem.Expand()

          Set treeItems = currentItem.Items

        Else

          itemFound = False

        End if

      Next

      Log.Enabled = True  

      If NOT itemFound Then 

        Log.Error("Item not found: " + items(i))

      End If 

    End Sub







    Does this help?