Jump to content

Not able to identify the buttons/objects present inside a panel


Recommended Posts

I am new to AutoIT and seeking the AutoIT community's help on the challenge I am facing.
 
I need to write the AutoIT automation test scripts for my esteemed project built in .NET. AutoIT's Object Identifier tool correctly identifies the panel but it is not able to locate the buttons/tools present inside the panel. The panels are designed using the 'ASP.NET Infragistics controls'.

Whenever I drag and drop the 'Object Finder tool' on any button, it highlights the whole panel in which the button is present and returns the whole panel information in the 'window' and 'control' tabs of the 'Object Identifier window'.

Please let me know if there is any step that I am missing or is there any configuration that I should ask the developers for. I would also love to know how to identify the objects/items present inside the tree view. Say tree view present inside My Computer.

P.S. I am able to Identify the objects of other .Net application where no Panel is implemented.

Edited by ArpitSinghal
Link to comment
Share on other sites

This will grab all the controls, and output them with enough data to help you find the control...there are also filters (I just added them recently) to get only a certain class of control...or only visible controls...or containing some text string:

#include <Array.au3>
#include <WinAPI.au3>

ConsoleWrite("Make your window active!" & @CRLF)
Sleep(5000)

GetAllWindowsControls(WinGetHandle("[ACTIVE]"))

Func GetAllWindowsControls($hCallersWindow, $bOnlyVisible=Default, $sStringIncludes=Default, $sClass=Default)
    ; Get all list of controls
    If $bOnlyVisible = Default Then $bOnlyVisible = False
    If $sStringIncludes = Default Then $sStringIncludes = ""
    If $sClass = Default Then $sClass = ""
    $sClassList = WinGetClassList($hCallersWindow)

    ; Create array
    $aClassList = StringSplit($sClassList, @CRLF, 2)

    ; Sort array
    _ArraySort($aClassList)
    _ArrayDelete($aClassList, 0)

    ; Loop
    $iCurrentClass = ""
    $iCurrentCount = 1
    $iTotalCounter = 1

    If StringLen($sClass)>0 Then
        For $i = UBound($aClassList)-1 To 0 Step - 1
            If $aClassList[$i]<>$sClass Then
                _ArrayDelete($aClassList,$i)
            EndIf
        Next
    EndIf

    For $i = 0 To UBound($aClassList) - 1
        If $aClassList[$i] = $iCurrentClass Then
            $iCurrentCount += 1
        Else
            $iCurrentClass = $aClassList[$i]
            $iCurrentCount = 1
        EndIf

        $hControl = ControlGetHandle($hCallersWindow, "", "[CLASSNN:" & $iCurrentClass & $iCurrentCount & "]")
        $text = StringRegExpReplace(ControlGetText($hCallersWindow, "", $hControl), "[\n\r]", "{@CRLF}")
        $aPos = ControlGetPos($hCallersWindow, "", $hControl)
        $sControlID = _WinAPI_GetDlgCtrlID($hControl)
        $bIsVisible = ControlCommand($hCallersWindow, "", $hControl, "IsVisible")
        If $bOnlyVisible And Not $bIsVisible Then
            $iTotalCounter += 1
            ContinueLoop
        EndIf

        If StringLen($sStringIncludes) > 0 Then
            If Not StringInStr($text, $sStringIncludes) Then
                $iTotalCounter += 1
                ContinueLoop
            EndIf
        EndIf

        If IsArray($aPos) Then
            ConsoleWrite("Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[" & StringFormat("%4s", $aPos[0]) & "] YPos=[" & StringFormat("%4s", $aPos[1]) & "] Width=[" & StringFormat("%4s", $aPos[2]) & "] Height=[" & StringFormat("%4s", $aPos[3]) & "] IsVisible=[" & $bIsVisible & "] Text=[" & $text & "]." & @CRLF)
        Else
            ConsoleWrite("Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[winclosed] YPos=[winclosed] Width=[winclosed] Height=[winclosed] Text=[" & $text & "]." & @CRLF)
        EndIf

        If Not WinExists($hCallersWindow) Then ExitLoop
        $iTotalCounter += 1
    Next
EndFunc   ;==>GetAllWindowsControls
Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Thanks for looking into this, but I am still not able to figure out the exact way of finding out the controls for a button present inside the panel.

When I ran your script, it returned the controls of all the panels present inside my application.

It would be really appreciable if you could be more descriptive on this. Please refer the attached file for the application' screenshot.

post-87377-0-51498900-1410534080_thumb.p

Link to comment
Share on other sites

Focus on the control, and then output the Toolbar tab, and Summary tab, here...from the spy tool.

Look into using the following functions: _GUICtrlToolbar_*

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Thanks for replying!

I made the function to login into the application, it worked fine. Then at the end of the script I added your code, ran the code and when it said-"make your window active", I clicked on the button. It printed some control information in the results but the button control information was not there. 

Please let me know if I need to modify your test script according to my application and if yes, then what changes I need to make.

Link to comment
Share on other sites

Focus on the control, and then output the Toolbar tab, and Summary tab, here...from the spy tool.

Look into using the following functions: _GUICtrlToolbar_*

The spy tool is the one provided with autoit.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...