Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Run Script in multiple versions simultaniously
#5
Not Solved
Hi basanth,
I need to programatically initiate QC execution.I need to connect to QC. Then execute a testset on a particular remote Host machine.
I tried the below code. But it is not working.


Option Explicit

Code:
Public Sub RunTestSet(otdc, tsFolderName, tSetName, HostName, runWhere)

    Dim TSetFact, tsList
    Dim theTestSet
    Dim tsTreeMgr
    Dim tsFolder
    Dim Scheduler
    Dim nPath
    Dim execStatus
    
    ' Get the test set tree manager from the test set factory
    'tdc is the global TDConnection object.
    Set TSetFact = otdc.TestSetFactory
    Set tsTreeMgr = otdc.TestSetTreeManager
    ' Get the test set folder passed as an argument to the example code
    'subject\functionality\SUB FOLDER NAME"
    'nPath = "Root\" & Trim(tsFolderName)
    nPath = "Root\"& Trim(tsFolderName)
    Set tsFolder = tsTreeMgr.NodeByPath(nPath)
    If tsFolder Is Nothing Then
        err.Raise vbObjectError + 1,"RunTestSet", "Could not find folder" & nPath
    End If
    
    'Search for the test set passed as an argument to the example code
    
    Set tsList = tsFolder.FindTestSets(tSetName)
    
    If tsList Is Nothing Then
        err.Raise vbObjectError + 1, "RunTestSet", "Could not find test set in the " & nPath
    End If
    
    If tsList.Count > 1 Then
        MsgBox "FindTestSets found more than one test set: refine search"
        Exit Sub
    ElseIf tsList.Count < 1 Then
        MsgBox "FindTestSets: test set not found"
        Exit Sub
    End If
    Set theTestSet = tsList.Item(1)
    'Debug.Print theTestSet.ID
    
    'Start the scheduler on the local machine
    Set Scheduler = theTestSet.StartExecution(HostName)
    
    'Set up for the run depending on where the test instances
    ' are to execute.
    
    Select Case runWhere
        Case "RUN_LOCAL"
            'Run all tests on the local machine
            Scheduler.RunAllLocally = True
        Case "RUN_REMOTE"
            'Run tests on a specified remote machine
            Scheduler.TdHostName = HostName
            ' RunAllLocally must not be set for
            ' remote invocation of tests.
            ' Do not do this:
            ' Scheduler.RunAllLocally = False
        Case "RUN_PLANNED_HOST"
            'Run on the hosts as planned in the test set
            Dim TSTestFact, TestList
            Dim tsFilter
            Dim TSTst
            'Get the test instances from the test set
            Set TSTestFact = TestSet.TSTestFactory
            Set tsFilter = TSTestFact.Filter
            tsFilter.Filter("TC_CYCLE_ID") = theTestSet.ID
            Set TestList = TSTestFact.NewList(tsFilter.Text)
            Scheduler.RunAllLocally = False
    End Select
    
    'Run the tests
    Scheduler.run
    
    Set execStatus = Scheduler.ExecutionStatus
    
'    While (RunFinished = False)
'        execStatus.RefreshExecStatusInfo "all", True
'        RunFinished = execStatus.Finished
'    Wend

End Sub

'================================

Const qcHostName = "mendelbrot:8080"
Const qcDomain =  "HOSP"
Const qcProject = "QC_Test"                      'Please define here the name of the project
Const qcUser = "bheemanagoud"                                            'Please define here the username
Const qcPassword = "manasa556$"                                 '‘Please define here the password
Dim tdc
Dim qcServer
Dim objArgs
Dim strArg
Dim strTestSet
Dim bRunCode

'======GETTING ARGUMENTS==============   pxb
set objArgs = WScript.Arguments
If WScript.Arguments.Count<1 Or WScript.Arguments.Count>2 Then
    WScript.Echo "Please enter the name of the test set"
    bRunCode = False
Else
    For Each strArg in objArgs
        WScript.Echo strArg& "is starting…"
        strTestSet = strArg
        bRunCode = True
    Next
End If
'===========================================================


    qcServer = "http://" & qcHostName
    qcServer = qcServer & "/qcbin"
    Set tdc = CreateObject("TDAPIOLE80.tdconnection")

If (tdc Is Nothing) Then
    MsgBox "tdc object is empty"
End If

tdc.InitConnectionEx qcServer
tdc.Login qcUser, qcPassword
tdc.Connect qcDomain, qcProject

'RunTestSet tdc,"Insert here path to the test set", strTestSet , "nsert here the name of the machine", "RUN_LOCAL"
RunTestSet tdc,"trial1", "deleted" , "TA-Q5", "RUN_REMOTE"


'Disconnect from the project
If tdc.Connected Then
    tdc.Disconnect
End If
'Log off the server
If tdc.LoggedIn Then
    tdc.Logout
End If
'Release the TDConnection object.
tdc.ReleaseConnection
'Check status (For illustrative purposes.)
Set tdc = Nothing

Please let me know how to do this.

Thanks,
Pallavi
Reply


Messages In This Thread
RE: Run Script in multiple versions simultaniously - by Pallavi - 08-10-2009, 12:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to send/pass UFT Run Error Dialog as output value to main driver script lravi4u 0 592 11-05-2023, 03:55 PM
Last Post: lravi4u
  How do you Change Run mode mid script? Caleytown 6 7,223 03-25-2021, 08:27 AM
Last Post: RB26578
  How to run driver script to kick off scripts stored in QC? shipu 0 3,596 04-30-2014, 02:39 AM
Last Post: shipu
  Flight API does not run and QTP not recording the script Ruch 0 2,600 08-15-2013, 04:57 AM
Last Post: Ruch
Exclamation Getting run time error while executing the QTP script in command prompt. vishruth143 1 5,658 07-15-2013, 05:41 PM
Last Post: vinod123

Forum Jump:


Users browsing this thread: 3 Guest(s)