Forum Discussion

sony_ratnakar's avatar
sony_ratnakar
New Contributor
12 years ago

Access ListBox control

Hi am trying to access a listbox control of a desktop application on server using the following the script. Using 'Finchild' method the listbox control is recognized, but am unable to access using 'window' method. Any suggestions?






Sub Main


 


 'Launch CATS UI application


  


  LaunchOAG


  delay(25000)


  


 'Select the state "02-Arizona" from list of states in Login window


 


  Dim Login,ListBox


  Set Login = Sys.Process("OilAndGasUI").FindChild("WndCaption", "Login", 2)


  


  If Login.Exists Then


  


  ListBox = Login.Window("WindowsForms10.LISTBOX.app.0.3e799b","",1)


  Listbox.ClickItem(4)


  


  Else 


    Log.Error "The window ""Login"" was not found."


  End If


  


end sub


 


 


 


 


Sub LaunchOAG


 


  Dim WshShell, path


  


  path = "D:\OilandGas\GUI_bin\OilAndGasUI"


  Set WshShell = CreateObject("WScript.Shell")


  WshShell.Run(path)


 


end sub


  • Hi Sony,


     


    As far as I understand, you are testing the .NET app. TestComplete should recognize all objects of this app via WinFormsObject instead of Window.


    I suggest that you set a breakpoint on the problematic line and explore the Login object to see what child you can get access to.


     

  • Ravik's avatar
    Ravik
    Super Contributor
    Hi Sony, Change Depth in your Code   Set Login = Sys.Process("OilAndGasUI").FindChild("WndCaption", "Login", 2)                                                     Change Depth from 2 to n and try, it will work