All QTP-UFT Quality Center

Executing QC TestSet via OTA API (QCRunTestSet)

For the past few weeks, I have been actively working on Quality Center (ALM) and its integration with QuickTest Professional. One of the mini-projects I’ve worked on is creating a custom object that executes a test set and sends an email to the supplied distribution list from ALM TestSet’s Automation tab (as shown below):

Note: The above part (EMailTo) can be modified by either hard-coding it, or supplying an input from the Class Constructor.

I’ve extensively used the OTA API Reference to build this object and to understand how the API works. .NET developers having difficulty converting the VBScript code, please post in the comments section and I will mail you the class library (currently only C#).

Download (ALM Only)

QCRunTestSet is available for download, but comes as-is and currently executes TestSets on the localHost. However, I would be more than happy in helping you to modify this code to suit your needs.

QCRunTestSet.cls.vbs.zip [for ALM] (7108)

If you’re having issues creating an instance of the TSScheduler object, please read this thread. You may need to upgrade to a higher patch or perform a client registration on the execution machine.

Running QCRunTestSet from CommandLine

If you would like to pass parameters from the CommandLine instead of hard-coding them in the code, use WScript to pass arguments and WScript.Arguments to retrieve them in the class library. Example:

'Passing arguments
wscript C:\QCRunTestSet.cls.vbs "http//<server>:8080/qcbin" myUser myPassword myDomain _
                                                  myProject myTestSetPath myTestSetName
'Retrieving arguments
Set args = WScript.Arguments
 
QCServer = args(0)
UserName =  args(1)
Password = args(2)
QCDomain = args(3)
QCProject = args(4)
QCTestSetPath = args(5)
QCTestSetName = args(6)

101 comments… add one

Leave a Comment

  • ravi June 15, 2015, 7:25 pm

    Hi ,

    I have downloaded the code attached in the article and execute the script but it is failing at wscript.sleep(6000) with error vairable undefined. I am running this on VM machine. I tried to create wsshell object but no luck. Can you help how to resolved the issue?

    Thanks,
    Ravi

  • Hi June 15, 2015, 1:53 pm

    Hi Anshoo,

    I downloaded the code attached to this thread and tried to execute the code after installing all the prerequiste and it is failing at the following line where variable is not defined: Note I am executing the script on VM machine on windows7.

    wscript variable not defined. Can I use wait statement?

    Private Sub WaitWhileTestRunning(ByVal ExecutionStatus)
    Dim RunFinished: RunFinished = False

    While RunFinished = False
    ExecutionStatus.RefreshExecStatusInfo “all”, True
    RunFinished = ExecutionStatus.Finished

    WScript.Sleep(60000)

  • Anand Saboo June 10, 2015, 1:27 am

    Thanks for the response.
    It is updating the results in the “Runs” Tab (QC 11.0) but on the execution grid it is still showing as No Run.
    It would be great help if you could please let me know the solutions as i need for my project as soon as possible.

    Thanks in advance.

  • Nick May 28, 2015, 10:50 am

    Hi,

    This script is working great for me, except for one issue.

    When all my tests pass, the Test Execution Summary email shows them in a “Passed” status.

    When all of my tests fail, the Test Set Execution Summary email shows them in a “Failed” status.

    However, when I have tests in a set where some pass, and some fail, the Test Set Execution Summary email I receive always shows the tests in the test set in a “Passed” status. For my specific case, the first test fails, and the 2nd test (of 2 in the set) passes.

    In QC, you can clearly see the failure, but the Test Set Execution Summary email shows the same test as passing.

    TIA for any advice.

    • Anshoo Arora May 29, 2015, 12:02 am

      Nick, I will investigate tomorrow. What version of QC are you using? I dont have access to code right now but i am assuming that a way around would be to keep track of status internally instead of retrieving it from QC at the end.

    • Nick May 29, 2015, 9:03 am

      Thank you very much for your reply!

      ALM QC Enterprise Edition – 12.20.378

      All of the components, such as OTA client, UI, Site Admin, etc. are on Build 12.20.3264.0

      The target hosts (Win7, Win8) all have UFT 12.0.2181.0 installed.

      I am also now seeing something besides the emails — I’m intermittently having tests run with a final run status of “N/A”. That’s what the emails say, and that’s what shows up when I view the runs in QC. The Fast_Runs get created as usual when I use your script, but the “final” runs aren’t showing up with the final execution status anymore. Those never get created in the Test Run module now for some reason.

      Thanks in advance for any help.

    • Anshoo Arora June 2, 2015, 11:01 am

      Nick, sorry for the late reply. I did get a chance to look at the code, and it retrieves these status codes from QC itself. Is there a possibility that the way the status are named is different in ALM 12.0? I am not sure as we don’t use this version.. But if the way they read differently, you would have to modify this part of the code to correct the counts and status flags:

      ' load_ExecutionRunStatus() 
      
      ' Loop through all tests in the testSet list and retrieve status
      For ix = 1 To TSList.Count
          Select Case LCase(TSList.item(ix).Field("TS_EXEC_STATUS"))
              Case "blocked" : iBlocked = iBlocked + 1
              Case "failed" : iFailed = iFailed + 1
              Case "n/a" : iNA = iNA + 1
              Case "no run" : iNoRun = iNoRun + 1
              Case "not completed" : iNotCompleted = iNotCompleted + 1
              Case "passed" : iPassed = iPassed + 1
          End Select
      Next
      
      ' get_TSExecutionLog()
      
      'Test Name
      html = html & "<td style='" & style & "'>" & TSList.item(ix).field("TSC_NAME") & "</td>"
      
      'Status
      sStatus = TSList.item(ix).field("TS_EXEC_STATUS")
      Select Case sStatus
          Case "Passed"    : html = html & "<td style='color: #" & Trim(Split(color, ";")(0)) & ";" & style & "'>" & sStatus & "</td>"
          Case "Failed"    : html = html & "<td style='color: #" & Trim(Split(color, ";")(1)) & ";" & style & "'>" & sStatus & "</td>"
          Case Else        : html = html & "<td style='" & style & "'>" & sStatus & ""
      End Select
      
  • Akhandesh May 25, 2015, 10:56 am

    Helloo,

    I am trying to automate Web application in FireFox ESR v24.8.1 using UFT 12.01.
    There is a Menu item list present in top left of the application i.e Navigate , File, Explore etc.. When i try to spy on whole Menu list – It shows child element as WebElement but when i try to spy on individual item e.g “Navigate” it displays as “Window”.
    I cant able to see the properties and values of Individual Menu item.
    But the same application when i try in IE v8+ and try to spy on individual Menu items then the Properties and Values of menu items display properly.
    Oracle and Java Add-in have been added.

    Can you please suggest me a solution for this problem…Appreciate your help..

    Thank you

    • Anshoo Arora May 29, 2015, 12:03 am

      Akhandesh, I believe your best bet would be to contact HP for this. They should be able to provide you with a resolution.

  • Sunil Kumar May 25, 2015, 10:09 am

    Hello,

    Please help.. we run all our automation script from ALM, we have configuration file(.xml) which consist of filepath(Log), Generic scripts, URL, Datapath and Result_path(result). which we upload in ALM under, Test Resource/QTP Resources/project name/configuration script…/Resource Viewer-upload .xml file

    we will create Log and Results folder on desktop to capture logs and results befor execution, and path of this folders will be passed through filepath and result_path in configruation file.

    everytime we have to change filepath and result path in configuration file when we run the script from different system

    Can anybody please suggest me how to make this independent. how can we run the script on different machine without modifying configuration file(.xml)

    Thank You

  • sam May 21, 2015, 5:32 pm

    I am getting unable to create an instance of the Test Director API OLE (Test Director Connection) Object.” error when I try to run this script /? Please help

    • Anshoo Arora May 27, 2015, 12:16 pm

      Sam – do you have QC/ALM client installed on the system you’re running this script from?

  • Gireesh April 8, 2015, 1:03 am

    We are trying to change manual test case to automation using OTA used Below code converts the type in the Database (QC front end shows the change), but it is not creating the required script file in the file system (I am guessing), as I could not open this test case in QTP ( error message: Test [……] does not exist .

    Dim objTest As Test
    Dim objTestFact As TestFactory
    Set objTestFact = tdc.TestFactory
    Set objTest = objTestFact.Item(18316)
    objTest.Field(“TS_TYPE”) = “QUICKTEST_TEST” ‘The value is “MANUAL” for test script of type manual
    objTest.Post
    objTest.Refresh

    Any solution will be great help

    Thank you
    Gireesh.G

  • Shalabh Dixit February 10, 2015, 1:27 pm

    Hi ANshoo,
    I’m also getting the same error – unable to create an instance of the Test Director API OLE (Test Director Connection) Object.”
    The code ran fine yesterday but today it got stuck with this error.

    Please help

    Thanks
    Shalabh Dixit

  • Ranjith February 10, 2015, 1:05 pm

    Beautiful and useful website appreciate your hard work.
    Keep going :)

  • Maryam February 1, 2015, 10:57 pm

    Hi,

    I am completely new to software testing tools. I have knowledge of programming and would like to learn testing with QTP.
    Do you have a user manual with the installation CD for QTP so I can study at my own pace?
    I appreciate your help.

    Thanks

  • Pankaj August 15, 2014, 4:44 am

    Hi Anshu,

    You are doing tremendous stuff. Thanks for all this. Your book, co-authored with Tarun Lalwani has helped to clear a lot of doubts too. Though a bit pricey ;). Anyways, I am getting an issue with this startexecution method; I have racked my brains for two days, used the alm uninstaller, installed the tdconnect and qtp addin along with doing the alm client registration four times; but the issue refuses to go away. I have an alm 11 qc server installed in one of my virtual machines. I am using my machine as a client. This client has qtp 10 installed. I am not being able to execute tests using OTA due to this problem. Can you help me with this. Also, the patch which you talked about in the link of sqaforum which you have mentioned requires me to have a contract id to download from the hp site. I don’t have that ; so am unable to download that patch and try see if things work out. Can you help me here. I actually installed a trial version of qtp 11 in the qc server virtual machine hoping that there the issue might not come, but there also the same message about startexecution method comes up. Please help.

    Warm Regards,
    Pankaj

    Warm Regards,
    Pankaj

  • Anonymous July 23, 2014, 12:28 am

    Hi

    How We can get link to the current run test result on QC in your Script ?

  • RS June 27, 2014, 1:07 am

    Hi Anshoo, can this script be used for a non-QTP environment, just to kick off the performance tests on HP Performance Center 11? When I try the current code, I get the error in teh Test Run Scheduler ‘Cannot get remoteagent’s classid for test type ‘. I am executing this command remotely (The HP PC server is on another machine). I have installed the HP ALM Client on the machine from where I am executing the test. What other changes do I need to make for this to work?

  • Ronell March 19, 2014, 9:50 am

    Hi,

    I am trying to create a vbs file that will send an email and attach a file (excel file) from the client machine. Does anyone know how to do this?

    Thanks,
    Ronell

  • Mini March 11, 2014, 4:40 am

    Anshoo, as always this is very informative and useful. Thanks for sharing.

  • Arijit November 25, 2013, 6:50 am

    Hi,

    I’m preparing a vb script which will generate a report by clicking of a button and it will fetch me all the status updates that happened in QC last week.Please guide me through this or let me know how to proceed on this.Thanks a lot in advance.

    Thanks,
    Arijit

  • Ashish Hulgeri September 18, 2013, 12:52 am

    Hi Anshoo,

    I have a folder structure which contains sub folders with multiple test set. Below is example of the folder structure

    Main Folder
    SubFolder1
    TestSet1
    TestSet2
    SubFolder2
    TesSet1
    TestSet2

    I want to execute all the test sets under “MainFolder”. I tried using the below code. However on using the below code, only the first testset gets executed and execution stops after that. Could you please help me out. Thanks.
    Below is the code that i have used.

    QC_UserName=”QC User Name”
    QC_Password=”QC Password”
    QC_Domain=”Domain”
    QC_Project=”Project”
    set tdc = createobject(“TDApiOle80.TDConnection”)
    tdc.InitConnectionEx “QC URL”
    tdc.Login QC_UserName,QC_Password
    tdc.Connect QC_Domain,QC_Project
    nPath = “MyFolderPath”
    Set testSetTM=tdc.TestSetTreeManager ‘Create a Tree Manager Object
    Set testFolder=testSetTM.NodeByPath(nPath) ‘Navigate to the Path
    ‘Set tsInstances=tdc.TSTestFactory
    ‘Set tsFilter=tsInstances.Filter
    Set tsList=testFolder.FindTestSets(“”)
    Cnt=tsList.Count
    For i=Cnt to 1 Step -1
    Set theTestSet = tsList.Item(i)
    Set Scheduler = theTestSet.StartExecution(“”)
    Scheduler.RunAllLocally = True
    Scheduler.run
    Set execStatus = Scheduler.ExecutionStatus

    Do While RunFinished = False
    execStatus.RefreshExecStatusInfo “all”, True
    RunFinished = execStatus.Finished
    Set EventsList = execStatus.EventsList

    For Each ExecEventInfoObj in EventsList
    strNowEvent = ExecEventInfoObj.EventType
    Next

    For j= 1 to execstatus.count
    Set TestExecStatusobj =execstatus.Item(j)
    intTestid = TestExecStatusobj.TestInstance
    Next
    Loop
    WScript.Sleep 10000
    Next

    Set TestExecStatusobj=Nothing
    Set EventsList=Nothing
    Set execStatus=Nothing
    Set Scheduler=Nothing
    Set tsList=Nothing
    Set testFolder=Nothing
    Set testSetTM=Nothing
    Set nPath=Nothing

    If tdc.Connected Then
    tdc.Disconnect
    ‘print “Disconnected QC session successfully”
    End If

    ‘ Log off the server
    If tdc.LoggedIn Then
    tdc.Logout
    ‘print “Logged off from the Server successfully”
    End If
    ‘ Print total
    ‘ Release the TDConnection object.
    tdc.ReleaseConnection

  • Jack August 22, 2013, 10:05 pm

    Hi,
    you post is very helpful.

    i was wondering if you run only the failed test cases in a testset?
    these will not be run on a local host.

    could help me with that?

    Thax
    Jack

  • manal August 19, 2013, 10:04 am

    Hello. I need to attach a file to a test run at the end of its execution(when the test passes and when the test fails). Is that possible?
    •When run from test lab, can a component know whether it is the last in the test, or whether it is the last to run in the test (if the test does not complete)?
    •Is the test run object callable from QTP during the running of the test?
    •Is the test run object writable from QTP during the running of the test, or is it locked?
    Your help is much appreciated.

    Thanks,
    Manal

  • Amith July 24, 2013, 12:58 am

    Hello,

    Does the command line script work only when QTP is there? I have automated scripts from TestComplete. After the automated script is executed the test result needs to be recorded in QC run.
    Is this possible using OTA?

    Thanks,
    Amith

    • Anshoo Arora July 28, 2013, 12:22 pm

      Amith, I am not sure how this code will work for TestComplete. How do you currently run them manually? Same like you do with QTP?

  • Pramod Thatti June 16, 2013, 5:23 am

    Greetings,

    If i want to run a particular test in a testset how should I go baout doing it.Please let me know.

    Will tsTest.run command does not work?

    For Each testsetfound In tsList
    Set tsFolder = testsetfound.TestSetFolder
    Set tsTestFactory = testsetfound.tsTestFactory
    Set tsTestList = tsTestFactory.NewList(“”)

    ‘now update each test case status
    errmsg = “Error setting up RunFactory”
    For Each tsTest In tsTestList
    tsTest.run
    ‘If tsTest.Name = testrunname Then
    ‘Set RunFactory = tsTest.RunFactory
    ”Run_Name = “Auto_Run_” & myDate
    ‘Set obj_theRun = RunFactory.AddItem(CStr(testrunname))
    ‘obj_theRun.Status = testresult
    ‘errmsg = “Error posting to QC DB”
    ‘obj_theRun.Post
    ‘count = count + 1
    ‘End If
    Next ‘end loop of test cases’
    Next ‘end loop of test sets

  • Jay April 25, 2013, 3:58 pm

    So I got it working, but when my test set is done (59 scripts 1.5 hours later) it fails to send email on below line

    TSFolder.Refresh : WScript.Sleep(5000)

    due to the connection being closed(probably a X minute inactivity kickoff). I tried to write the below into the Class_Terminate() but no luck… any help please? Thanks

    Private Sub Class_Terminate()
    If IsObject(TSScheduler) Then
    If Not TSScheduler Is Nothing Then

    ‘JayAvondoglio: TRY: Server Connection was lost so need to disconnect and reconnect here
    On Error Resume Next
    ‘Disconnect TD session
    TDConnection.Disconnect

    ‘Disconect and quit QTP
    If IsObject(qtApp) Then
    If qtApp.TDConnection.IsConnected Then qtApp.TDConnection.Disconnect
    qtApp.Quit
    End If
    On Error Goto 0
    Call isQCConnected
    ‘JayAvondoglio: END

    TSFolder.Refresh : WScript.Sleep(5000)

    ‘Send an email to the distribution list
    TDSendMail()

    Set TSScheduler = Nothing
    End If
    End If

    On Error Resume Next
    ‘Disconnect TD session
    TDConnection.Disconnect

    ‘Disconect and quit QTP
    If IsObject(qtApp) Then
    If qtApp.TDConnection.IsConnected Then qtApp.TDConnection.Disconnect
    qtApp.Quit
    End If
    On Error Goto 0

    Set qtApp = Nothing
    Set TDConnection = Nothing
    End Sub

  • Jay April 25, 2013, 1:38 pm

    I love what I see, but right now I have a blank password and it will not allow it. I am sure I can set my password to be something other than blank in QC and this will work, but is there any way to modify it. I tried to take a look using common sense, and have found the location of the error, but am not sure where to tweak it.

    sErr = “Unable to execute RunTestSet. Please provide the ”
    arrArgs = Array(“QCServer”, “UserName”, “Password”, “QCDomain”, “QCProject”, “QCTestSetPath”, “QCTestSetName”)
    bExit = False

    Thanks for any help.

  • Raj December 6, 2012, 4:53 am

    Hi,

    Thanks for the article.
    I have many testsets which I wanted to executed. But each testset contain few Passed scripts and few failed. I just wanted to executed passed scripts only from each test set. So how to modify the code so that it executes testset with custom filters like ‘Status = Failed’

    Appriciate any indicator.

    Thanks
    RKJ

  • Greg Encke September 28, 2012, 2:57 pm

    Greetings,

    I want to run only certain tests in a test set and also on a specific host group. I have a query for my selected tests below (basically any test. Also, I just want a simple email that is send when all tests are completed. All of this is very new to me and I appreciate all the help I have already gotten from you.

    Thanks

    Select ts_name as TestName

    from td.TESTCYCL T
    inner join td.CYCLE C on c.CY_CYCLE_ID = T.TC_CYCLE_ID
    inner join td.CYCL_FOLD cf on c.cy_folder_id = cf.cf_item_id
    inner join td.TEST E on e.TS_TEST_ID = t.TC_TEST_ID

    Where c.CY_CYCLE = ‘Demo’ and TS_Status != ‘Repair’ and TC_status in (‘No Run’,’Not Completed’)

    Order by ts_name

    • Anshoo Arora October 10, 2012, 3:14 am

      Greg, if you would like to run this using OTA, then how are you running this query against the DB? I assume you’re using a RecordSet object. What does it return?

  • Shiv August 16, 2012, 2:42 am

    Hi Anshoo,

    I wanted to know that, how we can attach the results to the email sending option what you mentioned above. Please help me out in this.

    Regards,
    Shiv

    • Anshoo Arora August 24, 2012, 11:53 am

      Shiv, there are 2 ways you can do this:

      1. Add the emails to the EmailTo field in ALM
      2. Manually specify the recipients in the class library by modifying the caller function:

      Public Sub RunTestSet(Server, UserName, Password, QCDomain, QCProject, QCTestSetPath, QCTestSetName, EmailTo)
          Dim QCTestSetExec, sErr, arrArgs, ix, arg, bExit
          
          sErr = "Unable to execute RunTestSet. Please provide the "
          arrArgs = Array("Server", "UserName", "Password", "QCDomain", "QCProject", "QCTestSetPath", "QCTestSetName")
          bExit = False
          
          For ix = LBound(arrArgs) To UBound(arrArgs)
              Execute "arg = " & arrArgs(ix)
      
              If arg = "" Then
                  MsgBox sErr & arrArgs(ix) & ".", vbOkOnly, "Error!"
                  
                  bExit = True
              End If
          Next
          
          If bExit Then Exit Sub
          
          Set QCTestSetExec = New QCRunTestSet
          
          With QCTestSetExec
              .Server = Server
              .UserName = UserName
              .Password = Password
              .QCDomain = QCDomain
              .QCProject = QCProject
              .QCTestSetPath = QCTestSetPath
              .QCTestSetName = QCTestSetName
      		.EmailTo = EmailTo
              
              .Run
          End With
          
          Set QCTestSetExec = Nothing
      End Sub
      
  • Tracy August 1, 2012, 4:38 am

    Would you please send me the class library, i’m very interested? Thanks

  • Avinandan April 17, 2012, 5:00 am

    Thank a lot. This will also help me to run the scripts in batch mode from command line

  • Narayan April 16, 2012, 10:36 am

    I am not able to successfully execute the vbs file. It reports that the activeX component can not create Object . Please advice

    • Avinandan April 17, 2012, 5:16 am

      Narayan,

      If you are running the script in a win7 system then open the command fom Start- Accessaries – Right click on command promt and select “Run as Administrato”. Then go to type
      cd\ Enter
      then CD c:\windows\SysWOW64 Enter
      Now fom this directory run the vbs file.

      Try it out and reply back

    • Kiran March 19, 2015, 10:46 pm

      Hi Avinandan,

      I can find the SysWoW64 under Windows and any folder in my machine?
      Can you suggest me here.

      Regards,
      Kiran

    • Kiran March 19, 2015, 11:40 pm

      Hi Avinandan,

      I can’t find the SysWoW64 under Windows and any folder in my machine?
      Can you suggest me here.

      Regards,
      Kiran

    • Anshoo Arora April 18, 2012, 9:19 am

      Narayan, in addition to what Avinandan said, please also make sure you have ALM/QC 11.0 installed with QTP on the target machine. This error just means the correct COM object was not found, or is not registered.

    • Narasimha June 20, 2013, 10:54 am

      Thank you Avinandan. This has helped me a lot. I was struggling why the script was not ruuning on Win 7 OS. Thanks once again…

    • Anshu Khandelwal March 10, 2014, 6:21 pm

      Adding more to Avinandan and Anshoo comments,another resolution is try reinstalling TDConnectivity Add in again, it can be also possible reason and quick permanent fix.
      It’s works for me that’s why thought to share.

  • Amit Chaudhary March 26, 2012, 6:03 pm

    Greeting,

    I have a QC test which is automated using QTP, i want to run that test case automatically. Help please.

    I tried the way it’s mentioned in this thread but it’s not working.

    can someone help me here ?

    Thanks,
    Amit

    • Anshoo Arora March 28, 2012, 9:32 am

      Amit, this article will execute the entire Test Set. Also, there are some commands used which are only available with QC 11.0. If you are using version 11.0, can you share the code you’ve used to execute the Test Set?

    • Amit Chaudhary April 19, 2012, 4:58 pm
      Dim TSetFact, tsList 
      Dim theTestSet 
      Dim tsTreeMgr 
      Dim tsFolder
      Dim Scheduler 
      Dim execStatus 
      Dim tdc
      Dim nPath
      Dim TSTestFact, testList
      Dim tsFilter
      Dim TSTst
      
      Set tdc = CreateObject("TDAPIOLE80.TDConnection")
      If (tdc Is Nothing) Then
      MSGBOX "Connection is not created"
      Else
      MSGBOX "Connection is created"
      End If
      tdc.InitConnectionEx "http://symqc.prod.fedex.com:7117/qcbin"
      tdc.Login "685495", "Syntel24"
      tdc.Connect "BSTATS", "fedex-com-FedExWebIntegWizard"
      
      Set TSetFact = tdc.TestSetFactory
      Set tsTreeMgr = tdc.TestSetTreeManager
      nPath = "Root\" & Trim("SANDBOX\Amit Chaudhary")
      MSGBOX nPath
      Set tsFolder = tsTreeMgr.NodeByPath(nPath)
      
      If (tsFolder Is Nothing) Then
      MSGBOX "Folder is not found"
      Else
      MSGBOX "Folder is found"
      End If
      
      Set tsList = tsFolder.FindTestSets("OTA")
      If tsList.Count > 0 Then
      MSGBOX "FindTestSets found more than one test set"
      ElseIf tsList.Count < 1 Then
      MSGBOX "FindTestSets: test set not found"
      End If
      
      Set theTestSet = tsList.Item(1)
      
      'MSGBOX theTestSet.ID
      'Set TSTestFact = theTestSet.TSTestFactory
      'Set tsFilter = TSTestFact.Filter
      'tsFilter.Filter("TC_CYCLE_ID") = theTestSet.ID
      'Set testList = TSTestFact.NewList(tsFilter.Text)
      'For Each TSTst In testList
      'MSGBOX "Name: " & TSTst.Name & " ID: " & TSTst.ID 
      Set Scheduler = theTestSet.StartExecution("")
      Scheduler.RunAllLocally = True
      Scheduler.Run
      Set execStatus = Scheduler.ExecutionStatus
      'MSGBOX execStatus
      'Next 
      
      set obj = theTestSet.StartExecution("LocalHost")
      obj.RunAllLocally = True
      obj.Run()
      
      Set tdc = Nothing
      
    • Anshoo Arora May 2, 2012, 1:44 pm

      Amit, the one thing you are missing is the part where you have to wait until the execution is complete. You will have to retrieve the Scheduler status and check if it has finished execution. Besides this, your code seems correct. You didn’t specify it though – what is the issue you are having?

    • Anonymous August 7, 2012, 3:59 pm

      Hi Anshoo,

      Sorry, i was away from this project for a while. Can you please help me to resolve the issue as you mentioned of wait until execution is completed ?

      Issue is – test cases status is not initiating for execution ?

      Many thanks in advance for help !

      Thanks,
      Amit

    • Anonymous August 9, 2012, 11:41 am

      Getting error – ActiveX component can’t create object.

    • jyboo February 19, 2015, 10:30 am

      first login to HP QC with valid credentials, project and domain, click–> help –> add-in –> click Register and wait for the process to complete

    • Amit August 14, 2012, 4:48 pm

      Hi Anshoo,

      Still the issue is not resolved, can you please quickly check on some solution for this ?

    • Anshoo Arora August 24, 2012, 11:08 am

      Amit, you were missing the polling mechanism:

      Private Sub WaitWhileTestRunning(ByVal ExecutionStatus)
          Dim RunFinished: RunFinished = False
      		
          While RunFinished = False			
              ExecutionStatus.RefreshExecStatusInfo "all", True
              RunFinished = ExecutionStatus.Finished
      		
              WScript.Sleep(60000)
          Wend
      End Sub
      
    • Anshoo Arora August 24, 2012, 11:51 am

      Amit: Are you still getting an ‘ActiveX cannot create Component’ error?

    • Amit Chaudhary August 24, 2012, 11:54 am

      Hi Anshoo,

      Error is gone now,but actual test case is not runinng.

      FYI…it’s a BPT test case.

      Help please.

      Thanks,
      Amit

    • Amit Chaudhary September 26, 2012, 9:31 pm

      Hi Anshoo,

      Can you please help me on this ?

      Thanks,
      Amit Chaudhary

    • Anshoo Arora October 10, 2012, 3:12 am

      Amit, I am not sure what is causing it. Use the library in this post and run the following command:

      Call RunTestSet("http://symqc.prod.fedex.com:7117/qcbin", UserName, Password, "BSTATS", "fedex-com-FedExWebIntegWizard", "Root\" & Trim("SANDBOX\Amit Chaudhary"), "OTA")
      

      What behavior do you see? Does the test set run? Are there any error messages? Does an incorrect test set run?

      One other thing, are there any other test-sets with the word “OTA” in them?

  • mtl March 22, 2012, 12:47 pm

    Hi Anshoo,

    I am using ALM 11 and QTP 11. I updated your code with my testset info and run it from the command line. After the testset finish running, the Test Run Scheduler still active. After a couple of minutes, the same testset automatically ran again. Why is that?
    Thanks.

    • Anshoo Arora March 28, 2012, 9:29 am

      MTL: I am not sure why this would happen. I tested this library in the morning via command line and the Test Set was run only once and there was no execution afterwards. Please share the code you’ve used to run via command line.

  • SAM March 13, 2012, 2:40 am

    Hi Anshoo,

    Query on – QC 11-QTP11 Integration

    Precondition :- Selected 4 qtp scripts in QC TEst Set and Selected only 2 and run them
    Problem :-
    When it start execution, it opens QTP and run the first selected script multiple times and does not stop ?

    Is it a known issue ? Or is there any workaround ?

    Thx for your time,

    SAM

    • Anshoo Arora March 15, 2012, 9:28 am

      Sam, I haven’t encountered this issue. Are you on the current patch level for QC? Can you share the code?

    • SAM March 23, 2012, 1:42 pm

      Hi Anshoo,

      Unfortunately cannot share the code.. But this is very weird scenario observed.. will try on few other scripts and will keep posted ..

      Thx for ur time

    • SAM March 23, 2012, 1:43 pm

      Can u please elaborate ‘Current patch level’for QC.. Do I need to check with QC 11.0’s latest patch on HP site ?

    • SAM August 5, 2012, 7:47 am

      Hi Anshoo,

      Got to know the issue – its with Datatable issue with QTP 11 and QC 11 integration and there is a patch for it. Even though patch works fine but the issue is really a major one with this 11.0 version

      Thx

    • Anshoo Arora August 7, 2012, 10:52 am

      Sam, are you on version 11.0 or 11.5? Patch 01 for 11.5 was released last night.

  • Ashish Kumar Singh March 9, 2012, 8:18 am

    just to add to previous question i have been using QTP11.0 with QC9.2.

  • Ashish Kumar Singh March 9, 2012, 8:03 am

    Hi Anshoo
    I was trying to run the vbs file through command prompt with little modification in user name,password,domain,i have been getting an erros “Invalid server response”, please let me know what could be the reason.

    • Anshoo Arora March 15, 2012, 9:16 am

      Ashish, this library is only compatible with ALM (QC 11.0).

    • Jay April 25, 2013, 3:14 pm

      I may have gotten around this issue below…

      ‘TSReport represents the execution report settings for the current test set
      ”TODO::may need to comment this out and hardcode, while on QC 10.00
      ‘ Set TSReport = TestSet.ExecutionReportSettings
      ‘ TSReport.Enabled = True

      ‘This retrieves the EMail list from the recipients list from QC
      ‘ EMailTo = TSReport.EMailTo : Me.EMailTo = EMailTo
      EMailTo = “javondo”

  • Avinandan March 7, 2012, 2:09 am

    Hi Anshoo,

    I have installed your solution on XP and executed succefully. But recently I upgraded my OS to WIN7. And during run in Win7 I am getting following error “unable to create an instance of the Test Director API OLE (Test Director Connection) Object.” Please help me to resolve.

    • Arnold March 8, 2012, 6:47 pm

      avinandan,

      open notepad and save this as a bat file:

      bcdedit /set {current} nx Alwaysoff

      Run bat file.

    • Anshoo Arora March 15, 2012, 8:59 am

      Avinandan, this should only occur if the following statement fails:

      Set TDConnection = CreateObject("TDApiOle80.TDConnection")
      

      Do you have the QC add-in installed on this box?

    • Jay April 25, 2013, 3:16 pm

      I had the same issue and I fixed it like so(in my case due to 32/64 bit):

      C:\Windows\SysWOW64\wscript C:\QualityCenterSchedul……..

    • Jay April 25, 2013, 3:57 pm

      So I got it working, but when my test set is done (59 scripts 1.5 hours later) it fails to send email on below line

      TSFolder.Refresh : WScript.Sleep(5000)

      due to the connection being closed(probably a X minute inactivity kickoff). I tried to write the below into the Class_Terminate() but no luck… any help please? Thanks

      Private Sub Class_Terminate()
      If IsObject(TSScheduler) Then
      If Not TSScheduler Is Nothing Then

      ‘JayAvondoglio: TRY: Server Connection was lost so need to disconnect and reconnect here
      On Error Resume Next
      ‘Disconnect TD session
      TDConnection.Disconnect

      ‘Disconect and quit QTP
      If IsObject(qtApp) Then
      If qtApp.TDConnection.IsConnected Then qtApp.TDConnection.Disconnect
      qtApp.Quit
      End If
      On Error Goto 0
      Call isQCConnected
      ‘JayAvondoglio: END

      TSFolder.Refresh : WScript.Sleep(5000)

      ‘Send an email to the distribution list
      TDSendMail()

      Set TSScheduler = Nothing
      End If
      End If

      On Error Resume Next
      ‘Disconnect TD session
      TDConnection.Disconnect

      ‘Disconect and quit QTP
      If IsObject(qtApp) Then
      If qtApp.TDConnection.IsConnected Then qtApp.TDConnection.Disconnect
      qtApp.Quit
      End If
      On Error Goto 0

      Set qtApp = Nothing
      Set TDConnection = Nothing
      End Sub

    • Jay April 25, 2013, 3:59 pm

      Please delete this duplicate comment(and this one). Sorry, could not remove myself.

  • Nitin February 6, 2012, 2:32 am

    Hi ,
    I have a different problem. I hope Anshu or someone could help.
    I an trying to write an exe using QC OTA to update the status of my test cases in QC.I am facing two issues:

    1. When I am using run.Status =”Pass”; getting an error saying Field requires a value from the corresponding list

    2. How to provide several other information for test case updation like OS,Locale,IE version, Product Version.

    I am using QC 10.0.0.2248 on Win7 SP1 Ultimate32 bit

    My code snippet is

    foreach (TSTest tsTest in tsTestList)

    { Console.WriteLine(tsTest.Name);

    Run lastRun = (Run)tsTest.LastRun;
    Console.WriteLine(lastRun.Name);
    RunFactory runFactory = (RunFactory)tsTest.RunFactory;
    String date = DateTime.Now.ToString(“yyyyMMddhhmmss”);
    Run run = (Run)runFactory.AddItem(“Run” + date);
    run.Status = “Pass”;
    run.Post();

    }

    Any help in this regard is highly appreciated as this is the first time I am using QC.

    • Parul March 23, 2012, 5:43 am

      Hi Nitin,

      you need to pass the status “Passed” insted of “pass”.
      I hope it will work for you.

      Thanks.

  • Karan November 10, 2011, 11:16 pm

    Hi,

    I had a small concern as this coode works superb but TestSet.Tefresh does not work and i get the same status of the test case in the test set.

    Please let me know how to change the status or maybe refresh the status of a test script.

  • Arnold October 25, 2011, 9:06 pm

    Is this compatible with QC9.2?

  • Paulo September 6, 2011, 9:10 am

    Hi,
    Is it possible to filter witch tests of the TestSet should be executed? For example: in the last execution 2 tests of a 10 tests Testset failed and I only want to execute those 2 that failed. Is that possible to archive via the OTA API?

  • mehmet June 6, 2011, 6:45 am

    Hi very good implementation, thanx.
    My test sets take parameters.
    How can i set test set parameters with this function?

  • Drunlar April 13, 2011, 5:30 pm

    Cherry the “TD object not found” error message can be a few different things. In order for this script to work you must be able to run QC from IE (Not QCExplorer.exe). Also if you are using a 64 bit system the script must be ran from a 32 bit prompt…
    %windir%\SysWOW64\cscript.exe //nologo …

    If you are using a 64 bit system getting QC 9.5 running in IE is a complicated setup.

  • AK April 5, 2011, 6:29 am

    Hi Anshoo,
    I need to download report from QC via vb script or QTP Script.Can u help me in doing this?I need this urgently.

    Thanks

  • Cherry March 24, 2011, 11:12 am

    Hi
    Can anyone share the VB script to Connect ALM 11/QC11 and QTP10.00.
    I see an error TD object not found
    I had this script – Used to download the file from QC to Temp Directory

    Func_GetFolderAttachmentPath(sTDFolderPath, sTDAttachmentName)

    Dim oAttachmentFactory, oAttachment, oAttachmentList, oAttachmentFilter, oTreeManager, oSysTreeNode, iNdId,sPath
    Set oTreeManager = QCUtil.TDConnection.TreeManager
    Set oSysTreeNode = oTreeManager.NodeByPath(sTDFolderPath)
    Set oAttachmentFactory = oSysTreeNode.Attachments
    Set oAttachmentFilter = oAttachmentFactory.Filter
    iNdId = oSysTreeNode.NodeID
    oAttachmentFilter.Filter(“CR_REFERENCE”) = “‘ALL_LISTS_” & iNdId & “_” & sTDAttachmentName & “‘”
    Set oAttachmentList = oAttachmentFilter.NewList

    If oAttachmentList.Count > 0 Then
    Set oAttachment = oAttachmentList.Item(1)
    oAttachment.Load True, “”
    sPath = oAttachment.FileName
    End If
    Func_GetFolderAttachmentPath = sPath
    Set oAttachmentFactory = Nothing
    Set oAttachment = Nothing
    Set oAttachmentList = Nothing
    Set oAttachmentFilter = Nothing
    Set oTreeManager = Nothing
    Set oSysTreeNode = Nothing

    End Function

  • Srinivas March 22, 2011, 12:55 pm

    Hi,

    I am currently using QTP 10 and QC9.5. Can any body help me out how to download scripts, attachments etc… from qc to local machine so that i can run from local machine and fix the fixes to the code.
    Regards,
    Srinivas

    • Anshoo Arora June 29, 2011, 7:22 pm

      Srinivas: After connecting QTP to QC from your machine, you can open any of the resources in Quality Center from QTP.

    • Srinivas March 8, 2012, 1:40 pm

      Hi Anshoo, As per the client requirement we need to download all the resources which are there in QC to local machine and map them (resources) to locally and execute them. Its a one time activity to download them for the test cycle. Can you explain how we can do this. One of my colleague said we can do it using OTA to download and map the resources locally but not sure about it. Can u send any relevant code for the same.

      Thanks in advance
      Srinivas

    • Anshoo Arora March 15, 2012, 9:13 am

      Srinivas, I cannot send you the code as I do not have access to ALM. Your colleague has pointed you in the right direction though. First, download the resources to local machine, use LoadFunctionLibrary to associate. You can also directly connect to ALM before running the test and use resources directly from ALM.

  • shiva March 3, 2011, 1:17 am

    can any one help me ,
    how to automate test cases from JSP(java)
    ???

  • subrata fouzder February 21, 2011, 11:09 am

    Hi Anshoo
    This is very generic question regarding Testing
    Our software has its own Object model and corresponding methods .attributes defined ( taken fro VB). Now in the new requirement another new 2 editors are getting added C# and VB.NET so users can use this two editors for Scripting.I have to test this scenario whether the Object model is ported correctly to C# and .NET or not.
    Can you suggest any suitable automation method for this?
    Thanks in advance

  • AK February 3, 2011, 9:13 am

    Hi ,

    Can QC can be installed at my home system , I mean is it freely available or licence one.If it is can u plz provide me the link of the site from where i can download it.

    Thanks!!

    • Anshoo Arora February 19, 2011, 7:08 am

      AK: I believe you can download a trial version for a short period of time. The last time I installed QC, the trial version lasted for 30 days. You will be directed to the downloads section from this link + you will need to be registered to download the software.

    • Kumar April 13, 2013, 10:05 am

      Hi,

      How to export QTP batch test results to QC using OTA API.
      For example I have three manual test cases in QC(id :100,101,102)for those manual test cases I have three automation scripts. I wan to execute these three automation scripts from QTP and want to send the results to QC(just update the manual test case status as PASS OR FAIL in QC automatically).Please help me.

      Regards,
      Kumar

  • Raja February 2, 2011, 4:33 am

    Hi Anshoo,

    I have saved one excel sheet in Test Resources of QC. But I am not able to access that excel sheet value.

    Can you please let me how can we access the excel sheet saved in QC.

    Thanks,
    Rajasekhar

  • Anonymous January 26, 2011, 12:21 pm

    Anshoo,

    I removed the code to send an email from the VBS file and executed it from CMD. Noticed the status of each script initially is N/A and for couple of scripts the status remained same, in other words only FEW scripts from testset were executed.
    I am unable to see the results in CMD prompt (not sure if it shows any) as the scripts close all open files(browsers and cmd prompts at the start of each script ). How can I check the executionStatus of the Execution Controller (TSScheduler) when scripts are executing ,can you please shed some light?
    I’m not sure why some of the scripts in test set are not being executed. Thanks in Advance!
    -Sri

  • Sri January 25, 2011, 4:44 pm

    Hi Anshoo,

    I executed the vbs file from commandline, received an error “Object doesn’t support this property or method: ‘TestSet.ExecutionReportSettings’

    All I did is updated theVBS file with the values to the QC URL,ID/pwd,test folder and testset.
    Executed using cscript.exe QCRunTestset.cls.vbs

    Also, We are using QualityCenter 10.0 and QTP 10.0 versions.I do not see select Fields section under Automation tab in QC to notify by email. Is this something customized by QC Admin?or QC 11.0 feature?
    I would love to do the same setup, receive an email with Test results report.

    PS. I am trying to perform get this setup so scripts can be executed automatically following builds.

    • Anshoo Arora June 29, 2011, 7:21 pm

      Sri: You received this error because the Interface ITestSet2 was introduced in QC 11/ALM. There are several enhancements made to this code and it only supports version 11.

    • Sankar June 5, 2015, 12:16 am

      Hi Anshoo,

      I need to Import the test execution summary according to project/module wise from QC to Excel.
      Can you please share the code snippets for the same