Wednesday, July 29, 2009

Find all tests in a folder path

'***********************************************************************
'Purpose: This script displays all test names in a folder(path) in Test Plan module
'This example you can run from .vbs run-time or from QTP.
'Scripted by: Uday
'***********************************************************************


QCServerURL="QC server path
QCUserLogInName="user name"
QCUserPwd="password"
QCDomain="domain name"
QCProject="project name"

Set QCConnObj=createobject("TDApiole80.TDConnection")

TestsInPath="Folder Path"


ConnectToQCProj()
FindTestsInANode(TestsInPath)
DisConnectProj()



Public Function ConnectToQCProj
'User Login to QC
QCConnObj.InitConnectionEx QCServerURL
QCConnObj.Login QCUserLogInName,QCUserPwd

If QCConnObj.LoggedIn<>TRUE Then
msgbox "QC User Authentication has failed"
WScript.Quit
End If

'User connect to QC
QCConnObj.Connect QCDomain,QCProject
End function

Public Function DisConnectProj()
QCConnObj.Disconnect
QCConnObj.Logout
QCConnObj.ReleaseConnection
Set QCConnObj=Nothing
End function

Public function FindTestsInANode(TestsInPath)
'Here we need to goto the path
Set TreeManagerObj=QCConnObj.TreeManager
Set ParentFolderObj=TreeManagerObj.NodeByPath(TestsInPath)
'Here we are picking all the tests in that folder
Set TestFactObj=ParentFolderObj.TestFactory
Set TestListObj=TestFactObj.NewList("")
For each testObj in TestListObj
msgbox testObj.Name
Next
End Function

No comments:

Post a Comment