Welcome To Automation Testing

Before starting with tips of automation of SAP using QTP Let me give a small introduction of SAP and QTP.

SAP stands for System Applications and Products. It is the name of both the online financial and

Administrative software and the company that developed it. SAP is made up of individual modules that perform various organizational system tasks.



Quick Test Professional (QTP) is an automated functional Graphical User Interface (GUI) testing tool that allows the automation of user actions on a web or client based computer application.

It is primarily used for functional regression test automation. QTP uses a scripting language built on top of VBScript to specify the test procedure, and to manipulate the objects and controls of the application under test. It supports many applications through the support of add-ins.



We will be using SAP add-in with QTP to work on the SAP automation.

Monday 15 October 2012

Working with SAPGuiTree - Search and Activate Node


Hi All. I am back with this new post. Many times this question has been asked on many forums. However, there are hardly any suitable/complete answer. One of my reader has requested me to post on this topic. I took some time out of my schedule and am posting my findings. I hope you find it useful.
Below code is a sample code which I have written. This uses a descriptive programming which means it will work for any SAPGuiTree. No need to bother about objects. This code searches for a particular node  and activates it. This function also gives the total node count and navigates through each one of them. Please leave your comment if you find it useful.


'************************************************************************​ 'Function Name: SAP_Search_And_Activate_Node_In_SAPGuiTree
'Description: Searches and activates a node in SAPGuiTree using the search node text parameter.
'Parameter: Search node text, enter a value that you want to search,
'                        For example if you are looking for Outbound delivery no, you can enter the full text or just delivery for search key
'Return Value: Returns True/False
'Author: Ankesh
'Creation Date:
'**********************************************************************

Function SAP_Search_And_Activate_Node_In_SAPGuiTree(strSearchNodeText)

    'get all the objects of SAPGUITree
    'Descriptive programming has been used
    Set ObjSAPGuiTree = SAPGuiSession("micclass:=SAPGuiSession").SAPGuiWindow("micclass:=SAPGuiWindow").SAPGuiTree("micclass:=SAPGuiTree").Object

    'Get the node keys , a key is a number/position in the
    'A key value starts from 1.
    Set ObjKeyValues = ObjSAPGuiTree.GetAllNodeKeys

    'get the total count
    ''This count indicates the number of items/nodes in the Tree
    intNodeCount = ObjKeyValues.Count

    blnFlag=False
    'Iterate through the nodes of the tree
    For i = 0 to intNodeCount-1
        'Get the node text
        strNodeText=ObjSAPGuiTree.GetNodeTextByKey(ObjKeyValues(i))

        'Check if the match was found for the key that you are looking for
        'if yes then activate the item
        If Instr(strNodeText,strSearchNodeText)>0 Then
            'Select the node and double click on it
            'This is equivalent to ActivateItem
            ObjSAPGuiTree.SelectNode ObjKeyValues(i)
            ObjSAPGuiTree.DoubleClickNode ObjKeyValues(i)
            blnFlag=True 'set a flag to indicate the macth was found
            Exit For
        End If
    
    Next

    'Chk the flag and return values to function
    If blnFlag Then
        SAP_Search_And_Activate_Node_In_SAPGuiTree=True
    Else
        SAP_Search_And_Activate_Node_In_SAPGuiTree=False
    End If

    'Release the objects
    Set ObjKeyValues=Nothing
    Set ObjSAPGuiTree=Nothing

End Function