How to connect ALM from Excel VBA
Open test architecture is one type of API which is integrated with ALM. Through excel VBA , ALM can be connected. While working in projects , we may be face a time consuming activities like generating reports,Exporting results,modifying set of values,Custom graphs in Test plan or Test lab .
And also every time generating report we might need to open and generate the report. To accelerate these activities , ALM has a API , using that we can automate the ALM application as you wish.I am going to write a serious of posts for this ALM automation using Vb script. Each post once activity will be there such as connect to ALM, fetch data from Test plan etc. In this post first we will start with how connect the ALM through vb script , Configuration details and Code.
OTA API DLL for corrsponding version should be downloaded from HP website and same should be installed in your machine. Once installed that , now we can able to connect ALM OTA library from any programming language which supports it.
Main Module:
Dim ErrorString As String'Create Connection Object of OTA APIDim OQCConnection As New TDAPIOLELib.TDConnectionSub TestALMOTAConnection() If ConnectALM("http://yourQCServer/qcbin", "yourusername", "password", "yourdomainname", "yourprojectnane") = True Then MsgBox "Connected to ALM" If DisConnectALM = True Then MsgBox "Project Disconnected Successfuly" Else MsgBox ErrString End If Else MsgBox ErrorString End IfEnd Sub
Function to Connect ALM:
Public Function ConnectALM(URL As String, UserName As String, Password As String, Domain As String, Project As String) On Error GoTo Err_Handler ErrorString = "" 'Initiate connection with ALM Server OQCConnection.InitConnectionEx URL 'Connect to User OQCConnection.Login UserName, Password 'Connect to Domain and Project OQCConnection.Connect Domain, Project '"Successfully Connected to the project, Enjoy!!!" ConnectALM = True Exit FunctionErr_Handler: 'Check if the connection is successfull If OQCConnection.Connected = False Then ErrorString = "QC Server URL Initialization failed!!!" ConnectALM = False Exit Function End If 'Check if Login is Successfull If OQCConnection.LoggedIn = False Then ErrorString = "Unable to Login to ALM using the provided Credentials" ConnectALM = False Exit Function End If 'Check if project is connected If OQCConnection.ProjectConnected = False Then ErrorString = "Unable to Connect to the Domain or Project" ConnectALM = False End IfEnd Function
Function to Disconnect ALM
Public Function DisConnectALM() On Error GoTo Err_Handler ErrString = "" If OQCConnection.ProjectConnected Then OQCConnection.Disconnect End If If OQCConnection.LoggedIn Then OQCConnection.Logout End If If OQCConnection.Connected Then OQCConnection.ReleaseConnection End If 'Logged Out of QC DisConnectQC = True Exit FunctionErr_Handler: If OQCConnection.Connected Then ErrString = "Error Occurred while Disconnecting the QC Connection Object" End If If OQCConnection.ProjectConnected Then ErrString = "Error Occurred while disconnecting project" End If If OQCConnection.LoggedIn Then ErrString = "Error Occurred while Loggin out the User" End If DisConnectQC = FalseEnd Function
Comments
Post a Comment