Sunday 13 January 2013

Upload QTP scripts to Quality Center / ALM

More useful code. This time it's to add a whole bunch of tests to QC from QTP if they aren't uploaded already. This code is from a mate of mine who is now working in HP. We both shared a lot of useful code so I hope this is useful for you. For all code taken from this blog, please reference the author! That's all we ask :)

' Author: Mohamed Ali
' Date: 01/08/06
'CAUTION: USE THIS SCRIPT WITH EXTREME CARE SINCE IT ACCESSES QC.
'Note: QTP Must be open and QC connection must be setup BEFORE running this script

Const QTPPath = "G:\"
Const QCPath = "[QualityCenter] Subject\Automation\"
Dim qtApp, objFSO

Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(QTPPath)
Set colListOfFiles = objFolder.SubFolders
'open qtp if it isn't already open
qtApp.Visible = False
On Error Resume Next
  If qtApp.TDConnection.IsConnected Then ' If connection is successful
   For Each objFile in colListOfFiles
    'open temp locally then save file to QC
    qtApp.Open QTPPath & objFile.name
    qtApp.Test.SaveAs QCPath & objFile.name, True
   Next
  Else
   MsgBox "Please Setup QTP Connection to Quality Centre"
  End If
On Error GoTo 0


2 comments:

  1. how should be handle for overwrite scripts. If the scripts are already exists then how to overwrite it

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete