Tuesday

Skillset - Test Automation Architect

Continuing the series of posts under the skillset category, here is another very interesting job profile for a Test Automation Architect:

Note the Skillset category is just to gauge where you stand in terms of the skills required for the role.

Primary Purpose:
Top level technical expert with extensive business knowledge responsible for supporting a major application or suite of applications within an IT Section
 
Essential Duties and Responsibilities:
Following is a summary of the essential functions for this job.  Other duties may be performed, both major and minor, which are not mentioned below.  Specific activities may change from time to time.
1. Work as a technical/business consultant with clients, analysts, programmers, and team members to solve complex business problems; including development of feasibility studies, project plans, cost/benefits, alternative solutions, resource requirements, and project estimates.
2. Develop detailed specifications from which complex systems/subsystems/programs will be written.
3. Instruct, direct, and quality assure the work of other programmers and analysts.                        
4. Stay abreast of the latest technology architecture and “best practices” in the technology marketplace.
 
Required Skills and Competencies:
The requirements listed below are representative of the knowledge, skill and/or ability required.  Reasonable accommodations may be made to enable individuals with disabilities to perform the essential functions.
1. Bachelor’s degree in Information Technology related curriculum or equivalent work experience
2. Eight to ten years of experience in application design and programming
3. Working knowledge of PC applications such as Microsoft Office
4. Ability to work independently or as a member of a team
5. Ability to train others
6. Ability to travel as needed
 
SPECIFIC POSITION DESCRIPTION:
  1. Top-level technical test automation expert with extensive progressive knowledge and skills in the area of automated test design and execution using various test automation frameworks
  2. Coordinates with the QA Lead to facilitate the gathering and documenting of test automation objectives and requirements for input into Automation Strategy and Design approach
  3. Documents test automation requirements and other test planning artifacts in preparation for test automation design
  4. Designs and develops test automation artifacts (scripts, functions, scenarios, processes) for simple to complex automated testing situations using various tools (primarily HP Quick Test Pro / Quality Center).
  5. Has expert level understanding of complete test automation and various test automation frameworks (i.e. data driven, keyword driven, table driven, hybrid, etc.)
  6. Collects, organizes, and analyzes statistical information from a variety of sources (both technical i.e. web logs, and non-technical i.e. product management interviews) to support high-quality test design
  7. Designs, executes, monitors, and troubleshoots HP QTP automated tests in a variety of situations and conditions
  8. Works collaboratively with other departments to understand project objectives, gather automation requirements, design automated tests, troubleshoot issues, and implement scalable test automation solutions
  9. Analyzes statistical results for baselines, trends, and anomalies to facilitate problem solving, application improvements, and reporting. Contributes ideas and recommends action based on that analysis.
  10. Manages automated testing artifacts to ensure proper reuse, versioning, backups, organization and retention.
  11. Coordinates and facilitates test automation planning, design and execution sessions.
  12. Constantly evaluates test automation strategy and approach to identify areas of improvement (i.e. test automation frameworks, dynamic data collection methodologies, coding standards, components and object repository methods, etc.)
  13. Trains and mentors other departmental resources on the proper selection, design and implementation of various Test Automation Frameworks, Tools and Strategies
  14. Compiles test results data, prepares and reports test results both formally and informally
  15. Makes performance and process improvement recommendations as needed
  16. Communicates results information to technical and non-technical audiences
  17. Interfaces as needed with the Section Manager or Team Lead to report status
 
Time Allocation:
60% - Test automation architecture – defining frameworks, methodologies, strategies and approaches, driving improvements in test automation, expanding and growing automation team
30% - Oversight and leadership of assigned Test Automation Analyst resources (both FTE and Contractors)
10% - Career development and expansion of knowledge in business and technical areas

Desired Skills & Experience

Position Requirements:
  1. Candidate should be a high-performing test automation expert, preferably using HP Quick Test Pro and HP Quality Center, having the ability to train and mentor other automation analysts on the effective design and implementation of various test automation frameworks as needed.
  2. Minimum of 10 years of progressive test automation experience, preferably using Mercury WinRunner/HP QTP
  3. Advanced experience with driving test automation through the use of HP Quality Center
  4. Advanced experience and competency using standard test automation methodologies and direct scripting and coding in HP QTP such as Linear Scripting and Structured Scripting
  5. Advanced experience and competency using various test automation frameworks such as Data Driven, Table Driven, Keyword Drive, Hybrid
  6. Advanced knowledge of test automation tools, frameworks, design approaches, and effective implementation techniques
  7. Advanced experience working with highly complex target application environments (i.e. combination of client, web, middleware, database, mainframe, third-parties, etc)
  8. Strong technical and testing skills - Knowledge of various software testing strategies and approaches
  9. Requires little supervision, self-starter that can work independently and collaboratively, while remaining effective at reporting status on tasks daily
  10. Very detail oriented
  11. Strong communication skills - Ability to communicate and document status and complex issues effectively
  12. Strong documentation skills – Ability to create clear, concise, detailed project artifacts that meet the standards of the Testing Center of Excellence and Software Quality Management process
  13. Illustrated experience and competency with at least one programming and/or scripting language – preferably Java/C# and VBScript or Perl
  14. Experience with testing applications that make heavy use of web services, Pega and Tibco technologies
  15. Experience with technologies such as IIS, Apache, Websphere, XML, XSLT, etc
  16. Experience with various client side scripting technologies such as AJAX, ASP.NET AJAX, JavaScript, JQuery, JSON, etc
  17. Knowledge and experience with distributed systems, web application technologies, web services, and multi-layered architectures.
  18. Knowledge and experience using Windows tools and utilities – some experience with UNIX/AIX tools is a plus
  19. Knowledge and experience with multiple relational database systems – primarily DB2 and SQL Server.
  20. Some knowledge and experience with IBM mainframe systems as they relate to end-to-end testing
  21. Knowledge of various environmental elements as they relate to testing (i.e. networking, hardware, software, mid-tier, etc.), and the ability to effectively assist with troubleshooting as needed

Thursday

What is UFT - Unified Functional Testing ??

UFT or Unified Functional Testing



HP is now selling a new tool license called UFT which is nothing but QTP 11.0 (for GUI testing) and Service test (for non GUI testing) under one umbrella.

If you try to download the tool from HP's website you would be downloading nothing but QTP 11.0!!
They also have a website which is "http://unifiedfunctionaltesting.com/" which is under construction :-)

You can download their brochure about the tool from here , which says that they are targeting at multiple layers of an application from one single place.

Layers of Application are
  1. Business Process Testing
  2. Application level / GUI testing
  3. Headless layer / Web services testing / Java/JMS or .NET API
Hope this tool is much more than a gimmick by HP to sell a new license..

Wednesday

VAPI Script to kill QTP process



There are instances when you want to kill qtp after "x" number of runs. This VAPI script does exactly that:

' ----------------------------------------------------
' Main Test Function
' Debug - Boolean. Equals to false if running in [Test Mode] : reporting to Quality Center
' CurrentTestSet - [OTA COM Library].TestSet.
' CurrentTSTest - [OTA COM Library].TSTest.
' CurrentRun - [OTA COM Library].Run.
' ----------------------------------------------------
Sub Test_Main(Debug, CurrentTestSet, CurrentTSTest, CurrentRun)
  ' *** VBScript Limitation ! ***
  ' "On Error Resume Next" statement suppresses run-time script errors.
  ' To handle run-time error in a right way, you need to put "If Err.Number <> 0 Then"
  ' after each line of code that can cause such a run-time error.
  On Error Resume Next


  ' clear output window
  TDOutput.Clear
  Dim rc
  Dim strProcessName:strProcessName = "QTPro.exe"
  rc = ProcessExists (strProcessName)
  If rc = TRUE Then
    rc = ProcessKill (strProcessName)
    If rc = -1 Then
       TDOutput.Print "Failed to kill the " & strProcessName & " process...."
       CurrentRun.Status = "Failed"
       CurrentTSTest.Status = "Failed"
    Else
       TDOutput.Print "Successfully killed the " & strProcessName & " process...."
       CurrentRun.Status = "Passed"
       CurrentTSTest.Status = "Passed"
    End If
  Else
      TDOutput.Print "There is no " & strProcessName & " process running to kill it...."
      CurrentRun.Status = "Passed"
      CurrentTSTest.Status = "Passed"
  End If


End Sub


'##----------------------------------------------------------------------------------------------------
'##        FUNCTION NAME:        ProcessExists
'##----------------------------------------------------------------------------------------------------
'##
'##        DESCRIPTION:
'##
'##                Checks for the existance of the specified process.
'##
'##        PARAMETERS:
'##
'##                1. ProcessName:
'##
'##                        PASSING MECHANISM:        ByVal
'##
'##                        DATA TYPE:        String
'##
'##                        REQUIRED:        Yes
'##
'##                        DESCRIPTION:        Name of the process to be checked. If NULL, then returns error code -1.
'##
'##        RETURNS:        True if the process exists and FALSE if the specified process does not exists.
'##
'##        EXAMPLES:
'##
'##                1: This example decrypts the string which is encrypted using Encrypt Function.
'##
'##                                        rc = ProcessExists ("notepad.exe")
'##
'##        USAGE NOTES: None.
'##
'##        REQUIRED FUNCTIONS: None.
'##
'##        RELATED FUNCTIONS: ProcessKill, KillProcessFunc.
'##
'##        SCREENSHOTS: None.
'##
Public Function ProcessExists (ByVal strProcessName)


        Dim strFuncName:strFuncName = "ProcessExists: "
        Dim strComputer, strProcess
        Dim objService


            If Trim (strProcessName) = "" Then
                ProcessExists = FALSE
                Exit Function
        End If


        ' This statement tells to use the current machine
        strComputer = "."


        ' "winmgmts:" is used to access the root of the CIM library
        Set objService = GetObject ("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
        For Each strProcess in objService.InstancesOf ("Win32_process")
                If LCase (strProcess.Name) = LCase (strProcessName) Then
                        ProcessExists = TRUE
                        Exit Function
                End If
        Next


        ' Return
        ProcessExists = FALSE


End Function
' End of ProcessExists common function
'##----------------------------------------------------------------------------------------------------
'##        FUNCTION NAME:        ProcessKill
'##----------------------------------------------------------------------------------------------------
'##
'##        DESCRIPTION:
'##
'##                Kills all occurences of the specified process.
'##
'##        PARAMETERS:
'##
'##                1. ProcessName:
'##
'##                        PASSING MECHANISM:        ByVal
'##
'##                        DATA TYPE:        String
'##
'##                        REQUIRED:        Yes
'##
'##                        DESCRIPTION:        Name of the process to be killed. If NULL, then returns error code -1.
'##
'##        RETURNS:        0 for successfully killing the process, 1 if the specified process is not found and -1 if failed to kill the specified process
'##
'##        EXAMPLES:
'##
'##                1: This example decrypts the string which is encrypted using Encrypt Function.
'##
'##                                        rc = ProcessKill ("notepad.exe")
'##
'##        USAGE NOTES: None.
'##
'##        REQUIRED FUNCTIONS: None.
'##
'##        RELATED FUNCTIONS: None.
'##
'##        SCREENSHOTS: None.
'##
Public Function ProcessKill (ByVal strProcessName)


        Dim strFuncName:strFuncName = "ProcessKill: "
        Dim rc:rc = 1
        Dim strComputer, strProcess
        Dim objService


        ' This statement tells to use the current machine
        strComputer = "."


        ' "winmgmts:" is used to access the root of the CIM library
        Set objService = GetObject ("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")


        For Each strProcess in objService.InstancesOf ("Win32_process")
                If LCase (strProcess.Name) = LCase (strProcessName) Then
                        rc = strProcess.Terminate ()
                        If rc <> 0 Then
                                ' Returns -1 as it has failed to kill the specified process
                                ProcessKill = -1
                        Exit Function
                        End If
                End If
        Next
        ProcessKill = rc


End Function
' End of ProcessKill common function


--------------------------------------------------------------------------------

Happy testing!


Tuesday

Utility to create tests in test plan of Quality Center

Problem: Create tests in the test plan by copying a base test in QC to a destination folder in QC with the test names from the file system's existing folders/files.

Solution: Created a macro using OTA to do the same:

Code:

Private Sub CommandButton1_Click()
   
    If LoadQCConnectForm Then
    End If
   
    Dim FSO As Object
    Dim Folder As Object
    Dim FolderName As String
    Dim SubFolder As Object
    Dim strTestCase As String
    Dim TestCaseName As String
   
    'Parent Directory - Change this to whichever directory you want to use
    FolderName = GetVariable("Fitnesse Path")
    
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set Folder = FSO.GetFolder(FolderName)
          
    For Each Folder In Folder.SubFolders
            TestCaseName = GetVariable("QC Fitnesse Path") & "." & Folder.Name
            Call TestPlanCopyPasteTest(GetVariable("QC Source"), GetVariable("QC Dest"), "BaseTest", TestCaseName)
            Call RebootQCCon
    Next Folder
   
    Set FSO = Nothing

    MsgBox "All Fitnesse tests created"
   
End Sub

###########################################################
'Module1
Option Explicit
Public Const SHT_VARIABLES = "variables"

'Function Name:     GetVariable
'Function Purpose:  Returns the value of a variable
'Input Parameters:  strVariableName - Name of the variable to lookup
'Output Parameters: None
'Return Value:      String containing the variable value
Function GetVariable(ByVal strVariableName As String) As String
    Dim n
   
    n = 2
   
    While Sheets(SHT_VARIABLES).Cells(n, 1) <> ""
        If Sheets(SHT_VARIABLES).Cells(n, 1) = strVariableName Then
            GetVariable = Sheets(SHT_VARIABLES).Cells(n, 2)
            Exit Function
        End If
        n = n + 1
    Wend
   
    MsgBox "Variable not found: " & strVariableName, vbCritical + vbOKOnly
End Function

'Function Name:     SetVariable
'Function Purpose:  sets the value of a variable
'Input Parameters:  strVariableName - Name of the variable to set
'                   strValue - value of the variable to set
Sub SetVariable(ByVal strVariableName As String, ByVal strValue As String)
    Dim n
   
    n = 2
   
    While Sheets(SHT_VARIABLES).Cells(n, 1) <> ""
        If Sheets(SHT_VARIABLES).Cells(n, 1) = strVariableName Then
            Sheets(SHT_VARIABLES).Cells(n, 2) = strValue
            Exit Sub
        End If
        n = n + 1
    Wend
   
    MsgBox "Variable not found: " & strVariableName, vbCritical + vbOKOnly
End Sub

###########################################################
'Module2


Option Explicit


Global tdc As TDConnection 'Global object storing the QC connection
Public QCConnected As Boolean


Public sHost    'stores the host name for the QC connection reboot
Public sDomain  'stores the domain for the QC connection reboot
Public sProject 'stores the project for the QC connection reboot
Public sUser    'stores the username for the QC connection reboot
Public sPassword 'stores the password for the QC connection reboot
Public sPort   'stores the port for the QC connection reboot


'Function Name:     RebootQCCon
'Function Purpose:  Resets the connection to Quality Center - required for some of our actions which are breaking due to QC bug that doesn't let us set filters
'Input Parameters:  None
'Output Parameters:
'Return Value:      Boolean - True or False
Public Sub RebootQCCon()
    Call ConnectToQC(sHost, sDomain, sProject, sUser, sPassword, sPort)
End Sub


'Function Name:     ConnectToQC
'Function Purpose:  Makes the connection to Quality Center - taken from the OTA help reference
'Input Parameters:  qcHostName$ - name of the qc server e.g "server085"
'                   qcDomain$ - Domain to connect to
'                   qcProject$ - QC project to connect to
'                   qcUser$ - QC username
'                   qcPassword$ - QC password
'                   qcPort - port to connect to
'Output Parameters:
Public Function ConnectToQC(qcHostName, qcDomain, qcProject, _
    qcUser, qcPassword, Optional qcPort) As Boolean
    
    QCConnected = False
    On Error Resume Next
    tdc.DisconnectProject
    tdc.Disconnect
    tdc.Logout
    On Error GoTo 0
    
    'Assign these to the private variables - useful if we need to reboot the QC connection
    sHost = qcHostName
    sDomain = qcDomain
    sProject = qcProject
    sUser = qcUser
    sPassword = qcPassword
    sPort = qcPort
    
    '------------------------------------------------------------------------
    ' This routine makes the connection to the gobal TDConnection object
    ' (declared at the project level as Global tdc as TDConnection)
    ' and connects the user to the specified project.
    '-----------------------------------------------------------------------
    Dim qcServer As String
    Dim errmsg As String
    Const fName = "makeConnection" 'For error message


    On Error GoTo makeConnectionErr
    errmsg = ""


    ' Construct server argument using format:
    ' "http://server:port/qcbin"
    qcServer = "http://" & qcHostName


    If Not (IsMissing(qcPort)) Then
        If Len(qcPort) > 0 Then qcServer = qcServer & ":" & qcPort
    End If


    qcServer = qcServer & "/qcbin"


    ' Check status (for demonstration purposes only).
    ' MsgBox tdc.LoggedIn 'Error: OTA Server is not connected
    ' MsgBox tdc.Connected 'False
    ' MsgBox tdc.ServerName 'Blank string
    ' Create the connection.
    errmsg = "Failed to create TDConnection"
    If (tdc Is Nothing) Then Set tdc = New TDConnection
    If (tdc Is Nothing) Then GoTo makeConnectionErr
    errmsg = ""
    tdc.InitConnectionEx qcServer
    ' Check status.
    ' MsgBox tdc.LoggedIn 'False
    ' MsgBox tdc.Connected 'True
    ' MsgBox tdc.ServerName 'http:///qcbin/wcomsrv.dll


    
    tdc.Login qcUser, qcPassword
    ' Check status.
    ' MsgBox tdc.LoggedIn 'True
    ' MsgBox tdc.ProjectName 'Empty String
    ' MsgBox tdc.ProjectConnected 'False
    ' Connect to the project and user.
    tdc.Connect qcDomain, qcProject
    ConnectToQC = True
    QCConnected = True
    Exit Function


makeConnectionErr:
    ConnectToQC = False
    MsgBox Err & " " & fName & " " & Err.Description & vbCrLf & errmsg


End Function


'Function Name:     LoadQCConnectForm
'Function Purpose:  Loads the Quality Center Connection Form
'Input Parameters:  None
'Output Parameters:
'Return Value:      True if the user connected to QC
Public Function LoadQCConnectForm() As Boolean


    If Not ConnectToQC(GetVariable("QC Server"), GetVariable("QC Domain"), GetVariable("QC Project"), GetVariable("QC Username"), GetVariable("QC Password"), "") Then
        Load QCConnect
        QCConnect.Show
        LoadQCConnectForm = QCConnected
    Else
        LoadQCConnectForm = True
    End If
End Function
###########################################################
'Module3

'Function Name:     TestPlanCopyPasteTest
'Function Purpose:  Copies a test in the test plan (taken from the OTA documentation). Tweaked to actually work!!
'Input Parameters:  strSourceFolderPath - source folder path to copy
'                   strDestFolderPath - destination to copy to
'                   strSourceTestName - name of test to copy
'                   strNewTestName - new name to give test
Function TestPlanCopyPasteTest(strSourceFolderPath, strDestFolderPath, strSourceTestName, strNewTestName) As Boolean
    'Copy a test, including design steps and parameters.
    ' For example:
    ' CopyPasteTest "Subject\TestFolder1", "Subject\TestFolder2", "Test1"
    ' Copies Test1 to TestFolder2

     Dim sourceFolder As SubjectNode
     Dim destFolder As SubjectNode
     Dim treeMng As TreeManager
     Dim iscp As ISupportCopyPaste
     Dim clipboard As String
     Dim oSourceTest As Test
     Dim oNewTest As Test
     
     'Check that the source file exists
     If Not TestPlanDoesTestExist(strSourceTestName, strSourceFolderPath, False, "") Then
        TestPlanCopyPasteTest = False
        MsgBox "Source test does not exist: " & strSourceFolderPath & "\" & strSourceTestName, vbExclamation + vbOKOnly, "TestPlanCopyPasteTest"
        Exit Function
     End If
    
    'Check that the destination test does not exist
     If TestPlanDoesTestExist(strNewTestName, strDestFolderPath, False, "") Then
        TestPlanCopyPasteTest = False
        MsgBox "Destination test already exists: " & strDestFolderPath & "\" & strNewTestName, vbExclamation + vbOKOnly, "TestPlanCopyPasteTest"
        Exit Function
     End If
     
     'On Error GoTo errCondition
    
     Set sourceFolder = TestPlanGetSubjectNode(strSourceFolderPath)
     Set testF = sourceFolder.TestFactory
     ' Find the test ID.
     Set oSourceTest = TestPlanFindTest(strSourceTestName, strSourceFolderPath, False, "", True)
     ' Copy the source test.
     Set iscp = testF
     clipboard = iscp.CopyToClipBoard(oSourceTest.ID, 0, "")

     ' Paste the test in the destination folder.
     Set destFolder = TestPlanGetSubjectNode(strDestFolderPath)
     Set testF = destFolder.TestFactory
     Set iscp = testF
     iscp.PasteFromClipBoard clipboard, destFolder.NodeID
     
     'Now it's pasted, rename it
     'Reboot the QC connection as we get some failures around this point
     Call RebootQCCon
     Set oNewTest = TestPlanFindTest(strSourceTestName, strDestFolderPath, False, "")
     oNewTest.Name = strNewTestName
     oNewTest.Post

     ' Clean up.
     Set iscp = Nothing
     Set treeMng = Nothing
     Set sourceFolder = Nothing
     Set destFolder = Nothing
     Set oNewTest = Nothing
     Set oSourceTest = Nothing
     
     TestPlanCopyPasteTest = True
     Exit Function
     
errCondition:
     MsgBox "Error: " & Err.Description, vbExclamation + vbOKOnly, "TestPlanCopyPasteTest"
     TestPlanCopyPasteTest = False
End Function

'Function Name:     TestPlanCreateFolderStructure
'Function Purpose:  Creates a Folder Structure in the Test Plan
'Input Parameters:  strFullPath - Full Path of the Structure to Create e.g "Subject\A\B\C"
Sub TestPlanCreateFolderStructure(strFullPath)
    Dim arrFolders() As String
    Dim n As Integer
    Dim strParentPath As String
    Dim strThisPath As String
    Dim oParentFolder As SubjectNode
    
    'First of all, does the folder structure already exist?
    If TestPlanDoesPathExist(strFullPath) Then Exit Sub
    
    'Now split the path up into its individual folders
    arrFolders = Split(strFullPath, "\")
    
    'does the first element contain subject? if not, exit
    If UCase(arrFolders(0)) <> "SUBJECT" Then
        MsgBox "Error: The first element in the folder path must be 'Subject'", vbExclamation + vbOKOnly, "TestPlanCreateFolderStructure"
        Exit Sub
    End If
    
    'iterate the array
    For n = 0 To UBound(arrFolders)
        'Create the folder if it doesn't exist
        If strParentPath <> "" Then
            strThisPath = strParentPath & "\" & arrFolders(n)
            Debug.Print "strThisPath=" & strThisPath
            'Does this path exist? If not we need to create it
            If (TestPlanDoesPathExist(strThisPath) = False) And (arrFolders(n) <> "") Then
                'Create it
                'Get the parent folder
                Set oParentFolder = TestPlanGetSubjectNode(strParentPath)
                'Create this folder underneath it
                oParentFolder.AddNode (arrFolders(n))
            End If
        End If
        
        'before we move on, set the parent path
        If strParentPath = "" Then
            strParentPath = "Subject"
        Else
            strParentPath = strThisPath
        End If
    Next n
    
    'Release all objects
    Set oParentFolder = Nothing
End Sub


'Function Name:     TestPlanDoesPathExist
'Function Purpose:  Returns True if the path exists
'Input Parameters:  strPath - Path in the test plan to search for
'Output Parameters: None
'Return Value:      True or False
Function TestPlanDoesPathExist(ByVal strPath As String) As Boolean
    Dim TreeMgr As TreeManager
    Dim SubjRoot As SubjectNode
    Dim SubjectNodeList As List
    Dim oSubjectNode As SubjectNode
    
    
    Set TreeMgr = tdc.TreeManager
    Set SubjRoot = TreeMgr.TreeRoot("Subject")
    
    If UCase(strPath) = "SUBJECT" Then
        TestPlanDoesPathExist = True
        Exit Function
    End If
    
    Set SubjectNodeList = SubjRoot.FindChildren("", False, "")
    
    For Each oSubjectNode In SubjectNodeList
        If UCase(oSubjectNode.Path) = UCase(strPath) Then
            TestPlanDoesPathExist = True
            Set TreeMgr = Nothing
            Set SubjRoot = Nothing
            Set SubjectNodeList = Nothing
            Set oSubjectNode = Nothing
            Exit Function
        End If
    Next
    
    TestPlanDoesPathExist = False
    Set TreeMgr = Nothing
    Set SubjRoot = Nothing
    Set SubjectNodeList = Nothing
    Set oSubjectNode = Nothing
End Function

'Function Name:     TestPlanDoesTestExist
'Function Purpose:  Determines if a test exists in a certain location
'Input Parameters:  strTestName - Name of the test to find e.g. "Test 001"
'                   strFolderToSearchPath - Name of the folder to search e.g. "Subject\Regression\Project A"
'                   SearchChildFolders - Set to true to look in child folders
'                   strTestType - The type of test to find, e.g. "QUICKTEST_TEST"
'Output Parameters: None

Function TestPlanDoesTestExist(ByVal strTestName As String, ByVal strFolderToSearchPath As String, ByVal SearchChildFolders As Boolean, Optional ByVal strTestType As String) As Boolean
    Dim oTempTest As Test
    
    Set oTempTest = TestPlanFindTest(strTestName, strFolderToSearchPath, SearchChildFolders, strTestType, True)
    
    If (oTempTest Is Nothing) Then
        TestPlanDoesTestExist = False
    Else
        TestPlanDoesTestExist = True
    End If
    
    Set oTempTest = Nothing
End Function


'Function Name:     TestPlanFindTest
'Function Purpose:  Searches for a test within a folder and returns it as a Test Object
'Input Parameters:  strTestName - Name of the test to find e.g. "Test 001"
'                   strFolderToSearchPath - Name of the folder to search e.g. "Subject\Regression\Project A"
'                   SearchChildFolders - Set to true to look in child folders
'                   strTestType - The type of test to find, e.g. "QUICKTEST_TEST"
Function TestPlanFindTest(ByVal strTestName As String, ByVal strFolderToSearchPath As String, ByVal SearchChildFolders As Boolean, Optional ByVal strTestType As String, Optional blnSilentMode As Boolean) As Test
    
    Dim oParentNode As SubjectNode
    Dim SubjectNodeList As List
    Dim oSubjectNode As SubjectNode
    Dim intMatchCount As Integer: intMatchCount = 0
    Dim TestFact As TestFactory
    Dim oReturnValue As Test
    Dim TestFilter As TDFilter
    Dim TestList As List
    Dim oTest As Test
    Dim blnTypedMatched As Boolean: blnTypedMatched = True
    
    Set oParentNode = TestPlanGetSubjectNode(strFolderToSearchPath)
    Set TestFact = tdc.TestFactory
    
    'If there was an error getting the parent node then exit
    If (oParentNode Is Nothing) Then
        Set TestPlanFindTest = Nothing
        Exit Function
    End If

    'See if the parent folder has any tests that match the name we are looking for
    Set TestFilter = TestFact.Filter
    TestFilter.Filter("TS_SUBJECT") = Chr(34) & oParentNode.Path & Chr(34)
    Set TestList = TestFact.NewList(TestFilter.Text)
    For Each oTest In TestList
        'Debug.Print "Test Name='" & oTest.Name & "' Test Type=" & oTest.Type
        If (UCase(oTest.Name) = UCase(strTestName)) Then
            'See if we should match the type - by default it is set to matched (true)
            If (strTestType) <> "" Then
                If (oTest.Type = strTestType) Then
                    blnTypedMatched = True
                Else
                    blnTypedMatched = False
                End If
            End If
            
            If blnTypedMatched Then
                intMatchCount = intMatchCount + 1
                Set oReturnValue = oTest
            End If
        End If
    Next
    
    'Now check to see if we wanted to search child folders? If so search them
    If SearchChildFolders Then
        'Get all the child folders of the parent folder
        Set SubjectNodeList = oParentNode.FindChildren("", False, "")
        If Not (SubjectNodeList Is Nothing) Then
            For Each oSubjectNode In SubjectNodeList
                'Debug.Print oSubjectNode.Path
                Set TestFilter = TestFact.Filter
                TestFilter.Filter("TS_SUBJECT") = Chr(34) & oSubjectNode.Path & Chr(34)
                Set TestList = TestFact.NewList(TestFilter.Text)
                For Each oTest In TestList
                    'Debug.Print "Test Name='" & oTest.Name & "' Test Type=" & oTest.Type
                    If (UCase(oTest.Name) = UCase(strTestName)) Then
                        'See if we should match the type - by default it is set to matched (true)
                        If (strTestType) <> "" Then
                            If (oTest.Type = strTestType) Then
                                blnTypedMatched = True
                            Else
                                blnTypedMatched = False
                            End If
                        End If
                        
                        If blnTypedMatched Then
                            intMatchCount = intMatchCount + 1
                            Set oReturnValue = oTest
                        End If
                    End If
                Next
            Next
        End If
    End If
    
    
    'Clean Up
    Set oParentNode = Nothing
    Set SubjectNodeList = Nothing
    Set oSubjectNode = Nothing
    Set TestFact = Nothing
    Set TestFilter = Nothing
    Set TestList = Nothing
    Set oTest = Nothing
    
    
    'Now return a value
    Select Case intMatchCount
        Case 0
            If Not blnSilentMode Then
                MsgBox "Error: The Test could not be found with the parameters: " & Chr(10) & _
                    "Test Name:" & strTestName & Chr(10) & _
                    "Parent Folder Path:" & strFolderToSearchPath & Chr(10) & _
                    "Test Type:" & strTestType & Chr(10) & _
                    "Search child folders?:" & SearchChildFolders, vbExclamation + vbOKOnly, "TestPlanFindTest"
            End If
            Set TestPlanFindTest = Nothing
        Case 1
            Set TestPlanFindTest = oReturnValue
        Case Else
            If Not blnSilentMode Then
                MsgBox "Error: A total of " & intMatchCount & " tests were found with the following criteria: " & Chr(10) & _
                    "Test Name:" & strTestName & Chr(10) & _
                    "Parent Folder Path:" & strFolderToSearchPath & Chr(10) & _
                    "Test Type:" & strTestType & Chr(10) & _
                    "Search child folders?:" & SearchChildFolders, vbExclamation + vbOKOnly, "TestPlanFindTest"
            End If
            Set TestPlanFindTest = Nothing
    End Select

End Function

'Function Name:     TestPlanGetSubjectNode
'Function Purpose:  Returns a SubjectNode object for a given path in the Test Plan
'Input Parameters:  strPath - Path in the test plan to return as a SubjectNode

Function TestPlanGetSubjectNode(ByVal strPath As String) As SubjectNode
    Dim TreeMgr As TreeManager
    Dim SubjRoot As SubjectNode
    Dim SubjectNodeList As List
    Dim oSubjectNode As SubjectNode
    
    
    Set TreeMgr = tdc.TreeManager
    Set SubjRoot = TreeMgr.TreeRoot("Subject")
    
    'Trim any trailing \
    If Right(strPath, 1) = "\" Then strPath = Left(strPath, Len(strPath) - 1)
    
    If UCase(strPath) = "SUBJECT" Then
        Set TestPlanGetSubjectNode = SubjRoot
        Set TreeMgr = Nothing
        Set SubjRoot = Nothing
        Exit Function
    End If
    
    
    Set SubjectNodeList = SubjRoot.FindChildren("", False, "")
    
    For Each oSubjectNode In SubjectNodeList
        If UCase(oSubjectNode.Path) = UCase(strPath) Then
            Set TestPlanGetSubjectNode = oSubjectNode
            Exit Function
        End If
    Next
    
    MsgBox "Test Plan path not found: " & strPath, vbExclamation + vbOKOnly, "TestPlanGetSubjectNode Error"
    Set TestPlanGetSubjectNode = Nothing
    Set TreeMgr = Nothing
    Set SubjRoot = Nothing
    Set SubjectNodeList = Nothing
    Set oSubjectNode = Nothing
End Function

###########################################################
'Module4
Option Explicit

Public Type ScannedTreeItems
    strKey As String
    strParentKey As String
    strValue As String
    strFullQCPath As String
End Type

Public Enum QCPlanExplorerSelection
    SelectAny = 0
    SelectFolder = 1
    SelectAnyTest = 2
    SelectQTPTest = 3
End Enum

Public QCTestPlanItems() As ScannedTreeItems
Public QCTestPlanItemsInitialised As Boolean
Private gintKey As Integer
Public gItemSelectedPath As String 'stores the path of the item selected from the explorer userform

'Function Name:     ResetQCTestPlanItems
'Function Purpose:  Resets the data structures keeping track of the scanned test plan folders
'Input Parameters:  None
'Modification Date:
Public Sub ResetQCTestPlanItems()
    ReDim QCTestPlanItems(0)
    QCTestPlanItemsInitialised = False
    gintKey = 0
End Sub

'Function Name:     ResetQCTestPlanItems
'Function Purpose:  Increments and returns the unique key ID
'Input Parameters:  None
Public Function GetNextKey() As Integer
    gintKey = gintKey + 1
    GetNextKey = gintKey
End Function

'Function Name:     AddQCTestPlanItem
'Function Purpose:  Inserts an item into the QCTestPlanItems datastructure. This will be read into the treeview so most of these
'                   attributes correlate to treeview attributes
'Input Parameters:  strKey - Unique key for the item
'                   strParentKey - Key of the parent item that owns it
'                   strValue - Value of the node item
Public Sub AddQCTestPlanItem(strKey, strParentKey, strValue, strFullQCPath)
    If QCTestPlanItemsInitialised Then
        ReDim Preserve QCTestPlanItems(UBound(QCTestPlanItems) + 1)
        QCTestPlanItems(UBound(QCTestPlanItems)).strKey = strKey
        QCTestPlanItems(UBound(QCTestPlanItems)).strParentKey = strParentKey
        QCTestPlanItems(UBound(QCTestPlanItems)).strValue = strValue
        QCTestPlanItems(UBound(QCTestPlanItems)).strFullQCPath = strFullQCPath
    Else
        ReDim QCTestPlanItems(0)
        QCTestPlanItems(0).strKey = strKey
        QCTestPlanItems(0).strParentKey = strParentKey
        QCTestPlanItems(0).strValue = strValue
        QCTestPlanItems(0).strFullQCPath = strFullQCPath
        QCTestPlanItemsInitialised = True
    End If
End Sub


'Function Name:     BuildTestPlan
'Function Purpose:  Builds the data structure for the Test Plan. It iterates the folder contents and recursively calls itself.
'Input Parameters:  strParentKey - Key of the parent owning
'                   strNodePath - QC Path of the Node to add to the datastructure
'Modification Date:
Public Sub BuildTestPlan(ByVal strParentKey As String, ByVal strNodePath As String)
    Dim intUniqueKeyNo As Integer
    Dim strThisKey As String
    Dim oSubjectNode As SubjectNode
    Dim ChildSubjectNodes As List
    Dim oChildNode As SubjectNode
    Dim strExpectedPath As String
    Dim TestFact As TestFactory
    Dim TestFilter As TDFilter
    Dim TestList As List
    Dim oTest As Test
    Dim strTestKey As String
    
    'Get the Subject Node
    Set oSubjectNode = TestPlanGetSubjectNode(strNodePath)
    If (oSubjectNode Is Nothing) Then Exit Sub
    
    'Setup the key - Folders always have a key prefix of "f"
    intUniqueKeyNo = GetNextKey
    strThisKey = "f-" & intUniqueKeyNo
    
    'Add this Folder into the datastructure
    Call AddQCTestPlanItem(strThisKey, strParentKey, oSubjectNode.Name, strNodePath)
    
    'Does it have any child folders?
    Set ChildSubjectNodes = oSubjectNode.FindChildren("", False, "")
    If Not (ChildSubjectNodes Is Nothing) Then
        'This gives us a list of all children + subchildren so we need to filter it a bit
        For Each oChildNode In ChildSubjectNodes
            strExpectedPath = strNodePath & "\" & oChildNode.Name
            If strExpectedPath = oChildNode.Path Then
                'It's a direct child so iterate it
                Call BuildTestPlan(strThisKey, strExpectedPath)
            End If
        Next
    End If
    
    'Now it's processed all the child folders, look to see if there are any tests
    Set TestFact = tdc.TestFactory
    Set TestFilter = TestFact.Filter
    TestFilter.Filter("TS_SUBJECT") = Chr(34) & strNodePath & Chr(34)
    Set TestList = TestFact.NewList(TestFilter.Text)
    
    'Scan through all of the tests
    For Each oTest In TestList
        If (oTest.Type = "QUICKTEST_TEST") Then
            'mark it as a QTP test ("q" prefix)
            strTestKey = "q-" & GetNextKey
            Call AddQCTestPlanItem(strTestKey, strThisKey, oTest.Name, strNodePath)
        Else
            'mark it as a normal test ("t" prefix)
            strTestKey = "t-" & GetNextKey
            Call AddQCTestPlanItem(strTestKey, strThisKey, oTest.Name, strNodePath)
        End If
    Next
    
End Sub
###############################################################

To use the above code, copy the code into new modules respectively
Happy coding to test the code ;)




Monday

All about Business Process Testing (BPT)


I shall share my experience here that might help folks who are planning to adopt BPT :

HP Business Process Testing in a nut shell is used for designing business components that can be reused in business process tests.

Pre- requisite : A separate add-in which comes along with Quality Centre.
QC 10 - [http://update.external.hp.com/qualitycenter/qc100/mictools/qtp/qtp_10/QuickTest_Add-in_for_Quality_Center.msi]

Terminologies:
Components are easily-maintained, reusable units that perform a specific task. Quick Test provides two types of components: Manual / QTP / Winrunner
QTP - business components and scripted components
Business Components are keyword driven components
Scripted Components are regular code driven components.

Application Area: Collection of testing resources  like function libraries, shared object repositories, keywords, testing preferences and recovery scenarios

Component Input and Output Parameters - Variable values to and from a business component.

1. Creating Application Areas
Create, populate, and maintain shared object repository files that are used by Quick Test to identify the objects in your application
Create function libraries that contain functions, or operations/keywords that can be called by a component.
You can create multiple application areas , each one focusing on a particular part of the application.

2. Creating Components in the Quality Center Business Components Module
Details: pre-conditions and post-conditions
Snapshot:  If needed
Parameters: Specifies the input and output component parameter values for the business component. Design Steps: Create or view the manual steps of your business component
Automation:  Create keyword driven components and scripted components
Used by:  Business process tests that include the currently selected business component.
Component Requests pane: Handle new component requests that were generated in the Test Plan module.

3. Creating Business Process Tests and Flows in the Quality Center Test Plan Module SME creates a business process test or flow in the Test Plan module by dragging and dropping required components.

4. Run the BPT tests like regular tests from test lab



Advantages of Business Process Testing Framework:

  1. Eliminates the need of creating a separate framework for the Automation.
  2. Both input and output parameters can be directly added in Quality Centre
  3. A manual tester can remove the unwanted component from the test flow without affecting the code
  4. Single point of maintenance for all elements associated with the testing of a specific part of your application
  5. High reusability with data-driven test components
  6. Quickly test multiple flows , suitable for agile frameworks
  7. Need not have expertise in automation to create and run tests once the components are built
Practical way of applying BPT to your project:
  1. Create components from QC using scripted components
  2. Create atleast one initialization / driver component
  3. Create one component for each reusable functionality
  4. Create Verification components
  5. Create new tests by choosing test type = business component
  6. Drag and drop components into test case templates under test plan
  7. Link parameters between components
  8. Add the tests to test sets in test lab

Update: With QC 10 being really slow wrt BPT HP came up with ALM(Application Lifecycle Managemet) for QC11
In QC 10 every single component that is in a BPT test has to be downloaded separately and run
In QC 11 there is a "BPTWrapperTest" that takes a BPT test, downloads all its components, and generates a single QTP - BPT Wrapper test to run

Thursday

Where Good Ideas Come From ...



A must watch for all the testers to get innovative @ work!

Wednesday

QTP Secrets - Undocumented Features



Get Text Location
  • Unidentified objects
  • Forced to use Object’s relative location using Get text location method.
    • Find = Window(“Login”).GetTextLocation (“OK” ,x1,y1,x2,y2)
    • If find =True Then
    •     Window(“Login”).Click (x1+x2)/2 ,(y1+y2)/2
    • End If
    • Window(“Login”).Clickontext “OK”,0,0,0,0,”false”,micRightbtn,”false”
Optional Steps
  • Comment code or delete it?
  • Object does not exist at runtime
  • What if QuickTest bypasses this step and continues to run
  • OptionalStep.Statement
  • Warning Message
Multiple tests
  • Want to open more than one test /Compare tests
  • Use the QTP Script editor (NOT the QTP IDE)
  • Start > Programs > QTP > Tools > Quick test Script editor
Stop QTP at x tests
  • Close Quick Test after runs
  • QTP tests run from QC
  • C:\Program Files\HP\QuickTest Professional\bin
  • Mic.ini
  • Edit change appropriate tags
  • [RemoteAgent]
  • CloseToolAfterRuns=
Reuse web objects after browser reloads
  • Parsing the DOM to find an element
  • Grab enough properties to make it unique
  • Build a description with those properties and finally get the right micobject
  • Reload the page, and my object is useless











How do you get qtp tips ?
  • QTP tips file
  • QTP installation Folder -->Dat --> Tips.txt