Forum Discussion

BD_Geoactive's avatar
BD_Geoactive
Occasional Contributor
7 days ago

Help with VLCNETObject (tree) and finding its items

Hello all,

I am trying to figure out if I can write a script to try and select an item in a tree view object. Unfortunately, the tree view in question doesn't have SelectItem()/ClickItem() methods in it.

when looking at the Object Browser, the Tree in question is a VLCNETObject. So this is where i though i can write a simple experimental script (python) to see if i can find the 'child' of the object. but to no avail :/

I have set the screenshots below to show the application's treeview and what i can see via Accessibility Insight - see image 0.png

The simple script I have is basically go find the treeview object in question and use the method FindChild and if found click on it.

The issue are:

  • i cannot find the child of VLCNETObject tree
    • What do i need to enter for the PropValues in
      TestObj.FindChild(PropNamesPropValuesDepthRefreshTree)
      • its pointed in the image 1.png

Advise seeked: if this kind of components that dont have ClickItem() or SelectItem for treeview, how can i go about it in test complete without using the OCR action?

Any help is much appreciated. note: i am no developer

Regards

17 Replies

  • BD_Geoactive's avatar
    BD_Geoactive
    Occasional Contributor

    Plus, on the other matter (unrelated) the python intellesense (once you hit the . key on the keyboard) is pretty rubbish - it just flashes and not giving you options. You can do it blindly though :/

  • scot1967's avatar
    scot1967
    Icon for Champion Level 3 rankChampion Level 3

    I let GPT have a go...  This may allow you get a richer version of the tree and run a find method against it instead.  However it's only a little better than flying blind because you can't browse the objects.  This does keep it out of the project scope. I don't know if it will work.  I have bever tried it.  Maybe some clues for a slick way to solve this here?

    function getTree() {
      var p = Sys.Process("Intepro");
      var tree = null;
    
      try {
        tree = p.UIAObject("TDBTree");   // UIA first
        if (!tree.Exists)
          tree = p.VCLNETObject("DBTree"); // fallback
      } catch (ex) {
        tree = p.VCLNETObject("DBTree");
      }
    
      return tree;
    }
    
    var treeObj = getTree();
    Log.Message("Found: " + treeObj.FullName);

     

    • scot1967's avatar
      scot1967
      Icon for Champion Level 3 rankChampion Level 3

      🤣 I ran round a circle here...  This is more or less what you were doing in the first place minus the MSAA thing...  Well...  So if you have verified vlcNetTree is valid and added a valid PropertyName, Value and Depth in the parameters for findchild use FindAllChildren to return an array of what objects are there if any...

      https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/common-for-all/findallchildren-method.html

      • BD_Geoactive's avatar
        BD_Geoactive
        Occasional Contributor

        wow, thanks for all your effort to try and help me. I shall give it a try again once I can. I will update my progress in this post. Cheers

        Note: I have written a script for trying to find the parent tree (VLCNETObject) . it is there and found it...but I couldn't dive deeper than that just yet.

         

  • scot1967's avatar
    scot1967
    Icon for Champion Level 3 rankChampion Level 3

    What rraghvani​ and Hassan_Ballan​ were pointing out about the code is correct, you need a PropertyName, Value pair there.    However I would guess that to be more or an example than actual code possibly. 

    That said MSAA ( rraghvani​ ) and UI Automation would be worth checking out.  Tools, Current Project Properties, Open Applications...  You may be able to add  TDBTree* or DBTree*  as an accepted window and open up more things to use with your object.  I would do this in both and experiment with this combination.   

    Word of warning, this will affect all matching controls and could change mapping behavior in other parts of your application (voice of experience) so be as specific as you can and do some research. 

    [This may also be done in script to limit the scope however.] Not sure about this, I have never done it.

    Supported VCL and CLX Controls

    https://support.smartbear.com/testcomplete/docs/general-info/supported-technologies/controls/vcl.html

    You may have already mentioned and consulted this page but it should have some useful content as well.

    As always,  If you find my posts helpful drop me a like! 👍 Be sure to mark or post the solution to help others out and/or to credit the one who helped you. 😎

    • scot1967's avatar
      scot1967
      Icon for Champion Level 3 rankChampion Level 3

      [This may also be done in script to limit the scope however.] Not sure about this, I have never done it.

  • Hassan_Ballan's avatar
    Hassan_Ballan
    Icon for Champion Level 3 rankChampion Level 3

    In addition to the great suggestions above, here’s one more TestComplete-native approach you might try:

    🔍 Brute-force child inspection:

    Since VLCNETObject may not expose tree methods, loop through its direct children to inspect properties dynamically:

    for i in range(vlcNetTree.ChildCount):
        node = vlcNetTree.Child(i)
        Log.Message(f"{i}: " + node.Name)  # Try .Text, .WText, or .AccessibleName too
    

    This can help you identify which property actually holds your target value like "(12) Well Test 1", and confirm if the node even exists before trying FindChild().

    🔍 Refined FindChild():

    Once you know the correct property:

    target = vlcNetTree.FindChild("AccessibleName", "(12) Well Test 1", 10)
    if target.Exists:
        target.Click()
    

    If the nodes don’t exist until expanded, you’ll need to click parents first or simulate arrow keys.

    🤖 AI-assisted response
    👍 Found it helpful? Click Like
    ✅ Issue resolved? Click Mark as Solution

  • rraghvani's avatar
    rraghvani
    Icon for Champion Level 3 rankChampion Level 3

    You've written the following code,

    targetItem = vlcNetTree.FindChild("(12) Well Test 1", "*", 3)

    Where parameters are -

    PropNames - A property or an array of properties by which the method will search for an object.

    PropValues - A value of a single property or an array of values of properties that the PropNames parameter specifies.

    Depth - An integer value that sets the maximum level of the object’s hierarchy that the method will reach while searching for the specified object.

    Hint: Using the Object Browser, where is the Property Name of "(12) Well Test 1"? And where is the Property Value of "*"? Refer to the FindChild method examples, and note the parameters

     

    • BD_Geoactive's avatar
      BD_Geoactive
      Occasional Contributor

      The example i throw out there is just an example i want to do not actually what im expecting to work.

      I have read the FindChild() article and none of the properties/methods for the treeview im having difficulty with giving me any options to do what i want. Again, the treeview in question is custom drawn components (legacy code) and is pain in back to try to use with automation with T.C

      example of what i can see using MS Accessibility Insight vs Test Complete Object Browser is attached. In our previous Framework using selenium > WinAppDriver, i can access these tree items no problem.

      I think i can say i cannot access those treeitems under the troubled treeview - anyway i have logged a support case - see what they can advice me to do.

      thanks though for your reply

       

       

      • rraghvani's avatar
        rraghvani
        Icon for Champion Level 3 rankChampion Level 3

        For reference, the parameters you have passed into FindChild() method is incorrect. The parameter "(12) Well Test 1" is a Property Value, not a Property Name.

        In TC, you might have to enable MSAA (or UI Automation), to expose more UI objects of you application. Ensure your VCL Classes is supported by TC, see https://support.smartbear.com/testcomplete/docs/general-info/supported-technologies/index.html 

        What does "Panel1" show if you expand it?

        You also have .NET method, which you might be able to use to select your item.

  • BD_Geoactive's avatar
    BD_Geoactive
    Occasional Contributor

    hi scot1967​ 

    Unfortunately, my test complete license is not working today and so i couldn't follow up on some of the suggestion you made. 

    I'm, pretty sure I have tried using index(es) related methods, but the only I can find is only something like getSelected() or selectedIndex() vice versa. 

    I also uses a (string) variable to hold the actual value when it come to try and find the tree item in question in the troublesome tree view. so using indexes may works but probably wont be reliable. 

    To-date, as its too much pain trying to get something simple working, I may just use the keyword OCR action key to cover this bit of automation.

    I'll get back to some findings once my license is sorted! and the person whom manages it is off for week from today :/ regards, B

    • scot1967's avatar
      scot1967
      Icon for Champion Level 3 rankChampion Level 3

      Look for 'node' related methods and properties.  That was the key for me.  Your object my not have them though.  OCR should work if you can navigate the tree.  

      Good luck, let us know what you figure out and post back any other questions.

  • scot1967's avatar
    scot1967
    Icon for Champion Level 3 rankChampion Level 3

    PS... In one case I had to write code to search the treeview object using methods like this with indexes expanding things as I went because the objects didn't exists at all until expanded.  YUCK!  It worked but it was a brittle kludge.

  • scot1967's avatar
    scot1967
    Icon for Champion Level 3 rankChampion Level 3

    .... OK, this is object is exposed through Microsoft UIA, that is apparent.  I found you may have success from the parent object looking for methods related to nodes like, GetFocusedNode() and ExpandAll() / CollapseAll()  There may be similar methods or indexes you can use to navigate and focus objects in the tree.  I have a similar tree view in an app I have written tests for a few years ago.

    Hope this helps!

     

  • scot1967's avatar
    scot1967
    Icon for Champion Level 3 rankChampion Level 3

    Good day BD_Geoactive,

    I'll have a go at this.  Have you inspected the treeview object parent for properties or methods that can be used to interact with it? In many cases I have found the parent object has properties and methods for navigation the child objects don't have.  I'll do some poking around with the info you have shared (nice btw) and see if I find anything.

      ... If you find my posts helpful drop me a like! 👍 Be sure to mark or post the solution to help others out and/or to credit the one who helped you. 😎