Showing posts with label QTP and QC Connection. Show all posts
Showing posts with label QTP and QC Connection. Show all posts

Friday, January 25, 2013

Connecting QC with QTP using scripting (borrowed from http://jiteshsojitra.blogspot.in/)

Connecting QC with QTP using scripting (borrowed from http://jiteshsojitra.blogspot.in/)


Set qtApp = CreateObject("QuickTest.Application")
qtApp.Launch
qtApp.Visible = True
qtApp.TDConnection. Connect "URL", "DOMAIN", "PROJECT", "USERNAME", "PASSWORD", False

'Further code here

qtApp .Disconnect
qtApp .Logout
Set qtApp =nothing

Wednesday, January 23, 2013

Running Test Cases in QC using QTP

Sometimes it might be required to match the data provided say in an excel with Test case name as in QC while running Automated Test Cases using QTP.Then QTP allows user to create QTP object inside QTP and killing of QTP object or deallocation of QTP object will not affect currently opened QTP.

Function tc_check(TCName)
Set oQTP=createobject("quicktest.application")
QC_Loc=oQTP.Test.Location
bStatus=instr(1,lCase(QC_Loc),trim(lcase(TCName) ) )
if bStatus>0 then
msgbox "matching TC found"
else
msgbox "TC does not match"
end if
oQTP=nothing
End Function

Monday, January 21, 2013

Script to Run Multiple test sets in Test Lab of QC via QTP

Vb Script to Run MultipleTest Sets in Test Lab of Quality Center via QTP

'All the test sets should reside inside single parent folder

''To execute the this file enter the below line into commond prompt
     'C:\Windows\SysWOW64\cscript.exe "C:\Path of this file.vbs"

Dim aSet_name
Dim iCount
Dim QCConnection
Set QCConnection = CreateObject("TDApiOle80.TDConnection")
'---------------------------------------------------------------------------------------------------------------

QCConnection.InitConnectionEx "http://server address/qcbin"  '<--------------- Fill in server address
     
QCConnection.login "Username ", "Password"   '<---------------- QC Username and Password

QCConnection.Connect "QC Domain", "Qc Project"   '<---------------- FILL Domain/Project
nPath ="Root\Test1\Path"               '<----------------Parent Path 
aSet_name=array("TestSet1","TestSet2","TestSetn")   '<-------Test Set names
'-----------------------------------------------------------------------------------------------------------------

Set TSetFact = QCConnection.TestSetFactory
Set tsTreeMgr = QCConnection.TestSetTreeManager
Set tsFolder = tsTreeMgr.NodeByPath(nPath)

If tsFolder Is Nothing Then
 'msgbox "error"
 wscript.echo "error"
 Call QC_Disconnect()
End If

for iCount=0 to ubound(aSet_name)
 Set tsList = tsFolder.FindTestSets( aSet_name(iCount) )

 If tsList.Count > 1 Then

  'MsgBox "FindTestSets found more than one test set: refine search"
  wscript.echo "FindTestSets found more than one test set: refine search"

 ElseIf tsList.Count <> 1 then
  'MsgBox "FindTestSets: test set not found"
  wscript.echo  "FindTestSets: test set not found"
 else
        'End If

  Set theTestSet = tsList.Item(1)
  Set Scheduler = theTestSet.StartExecution("")
  Scheduler.RunAllLocally = True
  Scheduler.HostTimeOut = 100000  'The time to wait for response before  failing.
  Scheduler.run
  Set execStatus = Scheduler.ExecutionStatus
  RunFinished = False

  while RunFinished = False
   execStatus.RefreshExecStatusInfo "all", True
   RunFinished = execStatus.Finished
  wend

  wscript.echo "Completed Execution of Test Set "&aSet_name(iCount)
 end if
next


Call QC_Disconnect()
'-----------------------------------------------------
Function QC_Disconnect()
 QCConnection.Disconnect
 QCConnection.Logout
 Set QCConnection = Nothing
End Function