5.4.14

Connect to ALM-QC via VbS or QTP


You can use the following code to connect to ALM\QC via pure VbScript, without using QTP, even though this code would work from QTP as well.

Prerequisite:
  • ALM\QC should be installed

Code -

'''----------------------------------------------------------------------------------------------------------------------
'' Function Name:            funcGetALMConnectionObj
'' Description:                   This will connect to the ALM\QC server via either pure VbS or QTP
'' Input Parameters:        sQCServer
''                                         sQCUsername
''                                         sQCPassword
''                                         sQCDomain
''                                         sQCProject
'' Output Parameters:     oALMConnObj [The ALM Connection Object]
'' Author:                          Ashish Jaiswal
'''----------------------------------------------------------------------------------------------------------------------
Function funcGetALMConnectionObj (sQCServer, sQCUsername, sQCPassword, sQCDomain, sQCProject)

    ''Defining the Parent QC OTA Object
    Set oALMConnObj = CreateObject("TDAPIOLE80.TDConnection")

    ''Initiating the connection to the QC Server
    oALMConnObj.InitConnectionEx sQCServer

    ''Logging in
    oALMConnObj.Login sQCUsername, sQCPassword

    ''Connecting to the required project and domain
    oALMConnObj.Connect sQCDomain, sQCProject

    ''Returning the object
    Set funcGetALMConnectionObj = oALMConnObj

End Function
'''----------------------------------------------------------------------------------------------------------------------

Usage:

''Defining the connection parameters for QC
sQCServer = "http://ealm11.anyorg.net/qcbin/"
sQCUsername = "username"
sQCPassword = "password"
sQCDomain = "domain"
sQCProject = "projectname"

Set oALMConnObj = funcGetALMConnectionObj (sQCServer, sQCUsername, sQCPassword, sQCDomain, sQCProject)

''Proceeding ahead only if connected
If oALMConnObj.Connected Then

    MsgBox "Connected to QC!"
    MsgBox oALMConnObj.ProjectName

Else

    MsgBox "Not connected to QC"

End If
'''----------------------------------------------------------------------------------------------------------------------

Common troubleshooting measures -

  • Register the OTAClient.dl
    • For this put the OTAClient.dll in the "C:\Windows\System32" drive, if its not already there
    • Run the following command to [re]register the dll from the Run window
                      RegSvr32 "C:\Windows\System32\OTAClient.dll"

  • If you are getting an error something like 'ActiveX can't create object - TDConnection' then try running the connection code by putting in a .vbs file, from the Run window as follows, via the WScript.exe -
           C:\Windows\SysWOW64\wscript.exe "C:\Automation\QC-Connection.vbs"

No comments:

Post a Comment