VB Script code to upload multiple test in ALM without any Manual intervention
Below code can be used within excel also as a Macro and the details required for the ALM connection and list of tests with the ALM folder where tests needs to be updated.
'Gets the count of the QTP tests needs to be uploaded in ALM
RowCnt = Sheets("Sheet2").Range("A1").End(xlDown).Row
'Credentials required to connect QTP with ALM
ALMUrl = Sheets("Sheet1").Range("B1").Value
ALMDomain = Sheets("Sheet1").Range("B2").Value
ALMProject = Sheets("Sheet1").Range("B3").Value
ALMUserId = Sheets("Sheet1").Range("B4").Value
ALMUserPwd = Sheets("Sheet1").Range("B5").Value
'Below steps makes QTP connection with ALM using the above credentials
Set objQTP = CreateObject("QuickTest.Application")
If Not objQTP.TDConnection.IsConnected Then
objQTP.TDConnection.Connect ALMUrl, ALMDomain, ALMProject, ALMUserId, ALMUserPwd, False
End If
'Source path and destination path of the QTP test
LocalFolderPath = Sheets("Sheet1").Range("B6").Value
QCFolderpath = Sheets("Sheet1").Range("B7").Value
'Below code uploads all the tests to ALM
For i = 2 To RowCnt
LocalTest = Sheets("Sheet2").Range("B" & i).Value & "\" & Sheets("Sheet2").Range("A" & i).Value
QCTest = "[ALM] " & Sheets("Sheet2").Range("C" & i).Value & "\" & Sheets("Sheet2").Range("A" & i).Value
objQTP.Open LocalTest, False, False
Set objLib = objQTP.Test.Settings.Resources.Libraries
objLib.RemoveAll
'If the library is not already associated with the test case, associate it..
If objLib.Find("[ALM] Resources\<File Name and Path>") = -1 Then
objLib.Add "[ALM] Resources\<File Name and Path>", 1
End If
objQTP.Test.SaveAs QCTest
Next
MsgBox "All tests are loaded in ALM"
'Gets the count of the QTP tests needs to be uploaded in ALM
RowCnt = Sheets("Sheet2").Range("A1").End(xlDown).Row
'Credentials required to connect QTP with ALM
ALMUrl = Sheets("Sheet1").Range("B1").Value
ALMDomain = Sheets("Sheet1").Range("B2").Value
ALMProject = Sheets("Sheet1").Range("B3").Value
ALMUserId = Sheets("Sheet1").Range("B4").Value
ALMUserPwd = Sheets("Sheet1").Range("B5").Value
'Below steps makes QTP connection with ALM using the above credentials
Set objQTP = CreateObject("QuickTest.Application")
If Not objQTP.TDConnection.IsConnected Then
objQTP.TDConnection.Connect ALMUrl, ALMDomain, ALMProject, ALMUserId, ALMUserPwd, False
End If
'Source path and destination path of the QTP test
LocalFolderPath = Sheets("Sheet1").Range("B6").Value
QCFolderpath = Sheets("Sheet1").Range("B7").Value
'Below code uploads all the tests to ALM
For i = 2 To RowCnt
LocalTest = Sheets("Sheet2").Range("B" & i).Value & "\" & Sheets("Sheet2").Range("A" & i).Value
QCTest = "[ALM] " & Sheets("Sheet2").Range("C" & i).Value & "\" & Sheets("Sheet2").Range("A" & i).Value
objQTP.Open LocalTest, False, False
Set objLib = objQTP.Test.Settings.Resources.Libraries
objLib.RemoveAll
'If the library is not already associated with the test case, associate it..
If objLib.Find("[ALM] Resources\<File Name and Path>") = -1 Then
objLib.Add "[ALM] Resources\<File Name and Path>", 1
End If
objQTP.Test.SaveAs QCTest
Next
MsgBox "All tests are loaded in ALM"
Comments
Post a Comment