Forum Discussion

brian_kratsch's avatar
brian_kratsch
Contributor
12 years ago

Help finding a value in a winformsobject

I have encountered a window where I am not sure how to specify the correct object to click in the tested application. By default it uses coordinates but that won't work long term. I was thinking I could use FindChild of the parent but the property for ChildCount is 0 in the Object Browser. I will include a screenshot of the object I am referring to. If anyone has any ideas I would appreciate the help.



EDIT* So I can find the Common/Inquiries/Periodic/etc controls but none of the values below them 
  • Finally managed to resolve this issue. TestComplete couldn't see all the controls on the window by default. I ended up adding the window class into the MSAA section of the project file and like magic all the controls were exposed on the window.
  • are you sure you are looking at the right place in the object tree for the "Main area" controlls?

    You included a screenshot of the tree for the left 'sales and marketing' menu, but the arrow in the application's screenshot points for a control in the main area.



    did you try using the object spy over that control?



    And if you do mean the 'sales and marketing' controls, you might need to click them first to expand them, only then the object tree will display its children.
  • I did provide a screenshot of the of the tree from the 'main control'. Here is another screenshot, directly from the object spy of the Common section in the main control. The reason is, the object spy can only find the Common section on the main window, not the individual items in the tree (Customers, Prospects, Leads, Contacts, etc).



    Pic 3 = what I'm trying to do

    Pic 4 = Object Spy and Properties

    Pic 5 = Methods for the common section
  • Update:



    I am using keyword testing as I'm no coder :P

    Using an onscreen action I have the following item:

    Aliases.Ax32.wndAxMainFrame.MDIClient.wndContentFrame.AxContainerControl.SalesAndMarketing.Common.Nodes (which I can see has 12 nodes which looks correct so I think I'm on the right track)



    Can I possibly use the operation: Item [Set] or Item [Get] and tell it to select the 4th node?
  • Further update:



    I've made some progress using the following line of code:

    Aliases.Ax32.wndAxMainFrame.MDIClient.wndContentFrame.AxContainerControl.SalesAndMarketing.Common.Nodes.get_Item(3).set_Expanded(true)



    This expands the Contacts node but I don't see the change until the window is redrawn, there has to be a better way than this:


    Aliases.Ax32.wndAxMainFrame.Restore


    Aliases.Ax32.wndAxMainFrame.Maximize



    Now that I have the node open how do I go about clicking the child node All Contacts? 

    I wrote this:




    Aliases.Ax32.wndAxMainFrame.MDIClient.wndContentFrame.AxContainerControl.SalesAndMarketing.Common.Nodes.get_Item(3).Nodes.get_Item(0). I can't find a suitable method 


      

  • Hmm Keyword recorded tests are ugly and pretty limited..

    Can you use the .Click() method? it should do the job instead of "expand" too.

    (ie, Aliases.Ax32.wndAxMainFrame.MDIClient.wndContentFrame.AxContainerControl.SalesAndMarketing.Common.Nodes.get_Item(3).Nodes.get_Item(0).Click()

    Also, you can use the .Refresh() method on the window to reload its object tree.