≡ Menu
Joe Colantonio – Selenium-UFT-QTP-SoapUI-ALM-LoadRunner & more

QC & QTP – How to schedule a recurring test set

QC & QTP – How to schedule a recurring test set post image

Problem – Quality center’s issue with running periodic testsets

This has been a long standing issue with me and Quality Center. You can use QC to schedule a testset to run at a given time but the issue is when you need to have a testset run at a recurring time — say every day at 5:00 am.

Solution

To get testsets to run periodically you can use Vbscript with QC’s OTA API and Windows scheduler.

Vbscript code needed to run testset in QC

First you need to setup a VBScript that calls the Quality Center’s testset that you want to run:

set tdc = createobject("TDApiOle80.TDConnection")
tdc.InitConnectionEx "http://qcURL/qcbin/"
tdc.login "yourUserName","yourPassword"
tdc.Connect "yourDomain","yourProject"

Set objShell = CreateObject("WScript.Shell")
Set TSetFact = tdc.TestSetFactory
Set tsTreeMgr = tdc.TestSetTreeManager
Set tsFolder = tsTreeMgr.NodeByPath("Root\Formal Tests\YourTestDirectory")
Set tsList = tsFolder.FindTestSets("Your TestSet name. This is case sensitive!")
 
Set theTestSet = tsList.Item(1)
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 i= 1 to execstatus.count
  Set TestExecStatusobj =execstatus.Item(i)
  intTestid = TestExecStatusobj.TestInstance
 Next
Loop

Window’s Scheduled Tasks

Next you need to setup the windows scheduler to run at the desired time. See video for step by step instructions.

RunTestSet.exe – Another option

If you do not want to create your own VBScript to run your testsets you can also try an unsupported tool from HP – RunTestSet.exe. RunTestSet is a VC++ console application that you can send command line options to in order to run a QC testset. You can download RunTestSet and its documentation from HP or from http://www.joecolantonio.com/downloads

62 comments… add one

  • byzoor

    Hi Joe,
    Woww… Nice… in 2007 one of my wipro officemate ‘ Jagdeswaran Elumalai ‘did for the same. But one more point . He using triger mail, mail will triger the vbscript, script will triger to QC 8.2. once exceution complte automatically send status report to mail to user.
    Thanks for sharing the scripts.

    • Joe Colantonio

      byzoor » Thanks – glad you like it! Good point — there is a SendMail method that can be email (using QC) a high level report. I’m sure, like you said, a fancier report could be created that is automatically sent. Cheers~Joe

  • Rob

    Hi Joe,

    Its Awesome.Its really helpful for some one learning OTA.

    However , i have put this script in a note pad and saved it as .vbs file . After i double click on that , its through errors
    “—————————
    Windows Script Host
    —————————
    Script: C:\Documents and Settings\nap0587\Desktop\test.vbs
    Line: 6
    Char: 1
    Error: ActiveX component can’t create object: ‘WSscript.Shell’
    Code: 800A01AD
    Source: Microsoft VBScript runtime error

    —————————
    OK
    —————————

    and

    “—————————
    WScript.exe – Application Error
    —————————
    The instruction at “0x100dfacf” referenced memory at “0x0195724c”. The memory could not be “read”.

    Click on OK to terminate the program
    —————————
    OK
    —————————

    Set tdc = CreateObject(“TDAPIOLE.TDConnection”)
    tdc.InitConnectionEx “http://qcurl/qcbin”
    tdc.Login “username”, “password”
    tdc.Connect “Domain”, “Project”

    Set objShell = CreateObject(“WSscript.Shell”)
    Set tsetfact = tdc.TestSetFactory
    Set tstreeMgr = tdc.TestSetTreeManager
    Set tsFolder = tstreeMgr.NodeByPath(“Root\Google”)
    Set tsList = tsFolder.Findtestsets(“Phase1″)
    Set theTestSet = tsList.Item(1)
    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 i= 1 to execstatus.count
    Set TestExecStatusobj =execstatus.Item(i)
    intTestid = TestExecStatusobj.TestInstance
    Next
    Loop
    WSscript.quit

    I request you to please assist.

    Thanks,
    Rob

    • Joe Colantonio

      Rob » Thanks Rob! This error usually means that your machine has an issue with ActiveX. I found the following fix. Can you try these steps:

      Click Start, Run and type:
      regsvr32 wshom.ocx
      regsvr32 scrrun.dll

      If the above does not help, or if you receive an error message when running the two commands above, then you may need to reinstall Windows Script 5.6 from Microsoft site.
      Let me know if this helps. Cheers~Joe

      • Andrei

        Hi, joe
        I have the same problem as Rob, but your solution with regsvr32 didn’t help me. Neither reinstall of Windows Script.
        Do you have any ideas what else can helps to resolve this issue?

        Thanks

        P.S. the only difference is that I got error on line “Set Scheduler = theTestSet.StartExecution()”
        P.P.S. I’m running on Windows 2003 SP2 x86

        • Benoit

          Hello,

          Thx Joe ;)

          But i have the same problem too. “ActiveX component can’t create object” on line “Set Scheduler = theTestSet.StartExecution(“”))

          … :S

          Benoit.

          • Joe Colantonio

            Benoit » What I usually try, on the machine that is giving me issues,is the following:

            1) Navigate to QC (even if this is just a qtp run test machine) and let it download the QC active-x control
            2) Install or Re-Install the HP Quality Center Connectivity add-in
            3) Install or Re-Install the QuickTest Pro Add-in

            Please let me know if this helps. Cheers~Joe

          • Benoit

            Hello,

            Thank you for your answer.

            Running the “ALM Client Registration” solved my problem: http://XXXX/qcbin/start_a.jsp?common=true

            Best regards,
            Benoit.

  • Rob

    Hey Joe,

    Thank you so much its working :)

    Appreciate your effort and support.

    Regards,
    Rob

    • Joe Colantonio

      Rob » Excellent news Rob!

    • rishim

      Hi Rob,
      Could you pls tell me the steps as how it works ?

  • Ben

    Hello,

    My last comment was moderate about the issue with the ActiveX. Anyway i resolved the problem and i wanted to share with you the solution.
    I just run the ALM Client Registration. I’m using ALM 11 so the link is: http://:8080/qcbin/start_a.jsp?common=true. It works fine right after for me.

    But, i have an other problem.. I use your code in a VAPI-XP program. And i never get out of the While Loop. The “execstatus.Finished” is always False even after the end of the test. Actually it’s even worse it returns nothing, so i use the code below if i want the executionStatus returns something but it is always False.

    (This code below run QTP scripts on a remote virtual machine by the way. This part works fine.)

    ——————-
    ——————-

    Set TestSetFact = TDConnection.TestSetFactory
    Set tsTreeMgr = TDConnection.TestSetTreeManager

    Set TestSetFact = tdc.TestSetFactory
    Set tsTreeMgr = tdc.TestSetTreeManager

    ‘Get the test set folder.
    Set tsFolder = tsTreeMgr.NodeByPath(“”)

    ‘On Error GoTo RunTestSetErr
    Set tsList = tsFolder.FindTestSets(“”)
    If tsList.Count > 1 Then
    MsgBox “FindTestSets found more than one test set: refine search”
    ElseIf tsList.Count < 1 Then
    MsgBox "FindTestSets: test set not found"
    End If

    Set theTestSet = tsList.Item(1)

    'Start the scheduler on the local machine.
    Set Scheduler = theTestSet.StartExecution("")

    ''''''''''''''''

    Set TSTestFact = theTestSet.TSTestFactory
    Set tsFilter = TSTestFact.Filter
    tsFilter.Filter("TC_CYCLE_ID") = theTestSet.ID
    Set testList = TSTestFact.NewList(tsFilter.Text)

    'For each test instance, set the host to run depending
    'on the planning in the test set.
    For Each TSTst In testList
    Scheduler.RunOnHost(TSTst.ID) = TSTst.HostName
    Next
    Scheduler.RunAllLocally = False

    ''''''''''''''
    Scheduler.Run

    'set execStatus = Scheduler.ExecutionStatus
    'execStatus = Scheduler.ExecutionStatus.Finished
    While (RunFinished = False)
    'execstatus.RefreshExecStatusInfo “all”,True
    'RunFinished = execstatus.Finished
    Scheduler.ExecutionStatus.RefreshExecStatusInfo "all", True
    RunFinished = Scheduler.ExecutionStatus.Finished

    'Set EventsList = execStatus.EventsList
    'For Each ExecEventInfoObj In EventsList
    ' strNowEvent = ExecEventInfoObj.EventType
    'TDOutput.Print strNowEvent
    'Next

    'For i = 1 To execStatus.Count
    ' Set TestExecStatusObj = execStatus.Item(i)
    ' intTestID = TestExecStatusObj.TestInstance
    'TDOutput.Print intTestID
    'Next
    Wend
    ——————-
    ——————-

    Any help would be very appreciate.
    Thank you for your time.

    Best regards,
    Ben.

    • Ben

      Hello,

      For you information. I’m using the Test Run Scheduler now. I call it from a VAPI-XP program. It works fine.

      It works when i run the tests on a remote host. But It does not work when i run them in local. It seems the VAPI-XP window block the execution of QTP. I don’t know why. If you have any idea..

      Thank you.

      Regards,
      Ben.

  • shar

    Hi Joe,

    I’m an novice on using on QC and just trying to install it. After at least one week wrestling with the installation process and getting stuck in multiple integrity issues with my db… now I’m stuck with a jboss integration issue. As jboss zip file coming along with the QC pkg didn’t unpack, I had to do a workaround and point the QC config tool to my own instance jboss which I downloaded myself. I did run the run script for jboss so I could get things going. However, for launching QC I’m still hitting the wall. I get this error: The requested resource (/qcbin/SiteAdmin.jsp) is not available. The QC bin is somehow still stuck in the war file. Any idea? I do appreciate your help. Thanks. Shar

    • Joe Colantonio

      shar » Hi Shar – I’m not sure what is happening. I do not see any known issues. What version of QC are you trying to install? Also what verison of Jboss and what db are you using? Has anyone else seen issue similar QC/jboss install issues?

      • shar

        Hi. Thanks for your reply. I’ve been looking for clues and similar problems and even used HP’s self-solve km to look for issues like this. But I’ve not found much. I’m using ALM 11, jboss 5.1 and sql server 2005. Any thoughts? Thanks.

  • Changa

    Hi Joe,

    I am trying to run my QTP(v11) scripts using Windows Scheduler. I have created a vbs file to launch the application and open the QTP script and run it.

    But when tasks gets executed, .vbs file is getting opened instead of launching an application and running the script.

    Could you please let me know what might be the problem.

    Thank you

  • Changa

    Hi Joe,

    Any idea pls, how can we schedule QTP scripts in Windows7.

    Thank you

  • Lorena

    I have been trying tio use the RunTestSet method with no luck.

    I have my Run set as:
    “C:\Documents and Settings\a641422\Desktop\RunTestSetScheduler\Release\RunTestSet.exe \s:http:\qc-alm.wellsfargo.com\qcbin \n:W_S \d:BS \u:a641400 \p:$Mikie201 \f:O:\QTP Tests \t: 1 – Image Access by ENV-5 \l”

    And my Start In set as:
    “O:\QTP Tests\NightlyRegressionTesting”

    am I missing anything?

  • Lor

    I have been working with your document TestSet Sceduler Solution with no luck. Can we get a copy of your vbs file?

    I also need to run the scheduler after my system has timed out or logged off due to inactivity.

    Any ideas on this?

    • Joe Colantonio

      Lor » HI Lor – I placed a copy of one of my vbs testset sceduler scripts (QC_TestSet_scheduler.vbs) on my downloads section:

      http://www.joecolantonio.com/downloads/

      Also on all my lab machines I have the screensaver turned off and a registry setting that automatically logs me on to the machine.

      Hope this helps,

      Joe

      • Johan

        Hi Joe,

        I created a similar solution for running automated tests (BPT) using QTP11 and QC11 where the user plans tests in QC and they are run on the specified date/time on a specified remote host.
        Nevertheless, I do have some trouble with the automatic logon. As you are saying “a registry setting that automatically logs me on to the machine”, I suppose that you have a solution for this problem. Can you specify which regkey you are manipulating?

        Thanks!
        Johan

  • Lor

    I guess that is my issue. I cannot turn my screen saver off. I thought I had Admin rights but I guesss not. I think I will need to run via QC or contact the help desk to configure my system.

    I did look in my regestry but I could not find any settings to turn off the screedn saver or change my settings to automaticlly log me in. We have tons of security systems monitoring our every key punch.

    thx Joe

  • Hi,

    I am trying something similar for HP Service Test scripts.I need to download the “replay log file” after executing the Test.Please inform how can i download the log file after execution.

    Thanks,
    Aditya Reddy

    • Joe Colantonio

      aditya » Hi Aditya – when you say “replay log file” are you referring to the Output>Run results? If so I don’t think they are stored in QC (i’m not 100% sure). After you run a ST test the log files are stored locally under ST>Tools>Open Containing Folder> There should be a Log directory. The file named vtd_user.log contains the output>run results. You could create code that attaches each output results to a test lab in QC. Please let me know if I’m misunderstanding your question. Cheers~Joe

  • Tony

    hello Joe–thanks for providing this resource! i have been using RunTestSet.exe, but have recently run into an issue where it crashes trying to disconnect from the TD Server.

    given that, i’m looking forward to implementing this solution. One thing though, with RunTestSet, i point to a host group so that the tests are spread out to all of my QTP machines. how can i do this with the above example? i see “Scheduler.RunAllLocally = True”, which implies to me there could be a way i could point to a particular host group (?). if that’s the case, could you explain the syntax to achieve that?

    much appreciated.

    • Tony

      i seem to have it working. had to add Scheduler.TdHostName = “” and remove Scheduler.RunAllLocally. when i just changed that from True to False, I received an error.

      • Tony » Cool you got it. Yup QC doesn’t like when you try to use the RunAllLocally property when you are running on a specified remote machine.

  • Manish

    Hi Joe,
    your solution worked perfectly for me to schedule batch jobs on QC 11 (ALM) and QTP 11. Thanks for your help and insight. I was trying to take it a step further by trying to invoke the automatic email generated with results summary (under the Automation tab) from QC which works when your run tests thru QC but doesnt generate when the tsts are executed thru batch job. have you had any experience with this feature?

    Thanks
    Manish

    • Manish » Hi Manish does using the SendMail method in your scheduling vbscript help?

      set tdc = createobject("TDApiOle80.TDConnection")
      tdc.SendMail "listOfEmailAddress","","Subject","Message"

      • Anca

        Hy Joe,
        Any idea on how to also attach the status report?

  • Vikas Gholap

    Hi Joe,
    I want to execute all the test sets in a given folder, so I modified above code as below. However it execute only first test set from test folder and wscript.exe get closed. Second test set does not execute.
    My test folder contains 5 test sets.
    below is the code
    ‘********************************************************************
    TSFolderPath = “Root\Z.Delete\A TEST\”
    Set TSetFact = tdc.TestSetFactory
    Set tsTreeMgr = tdc.TestSetTreeManager
    Set tsFolder = tsTreeMgr.NodeByPath(TSFolderPath)
    Set tsList = tsFolder.FindTestSets(“”) ‘ Get all test sets
    If tsList.count >= 1 Then
    For tsIndex = 1 to tsList.count
    Set theTestSet = tsList.Item(tsIndex) ‘ TestSet Object
    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 i= 1 to execstatus.count
    Set TestExecStatusobj =execstatus.Item(i)
    Next
    WScript.Sleep 5000
    Loop
    Next ‘Go to next TestSet
    else
    Msgbox “Test Set not found under test folder : ‘” & TSFolderPath & “‘.”
    End If

    Please tell me where I have to modify the script.

    Thanks,
    Vikas

    • Vikas Gholap

      Hi Joe,
      I’m able to execute all automated BPT test set in a given test folder.
      Thanks for this code.
      Vikas

      • Viki

        One more query.
        How we can execute fixed number of test cases from a single test set?
        Consider I have a test set with 20 test cases.
        I want to execute only first 10 test cases out of 20 from a test set. Where I have to change the code.

        Please suggest.

        • Viki » You can hard code the test case count in the script. So for the line that has For i = 1 to execStatus.Count change to the value to 10

  • Pradeesh

    Hi Joe,
    I’m trying to run the script on windows 7 32 bit with QC 9.0.When i run manually from browser my test case is running fine.When I tried use this script It starts the TD test run scheduler but wont execute the test and it stops at that point. Same code is working in Windows XP. Using Msgbox i tried to display testcase ID ,name. Its returning it properly.Its failing at the point of execution. I tried everything mentioned in the site. Still it dint work for me.Its really urgent for me as i wasted 1 week already on troubleshooting this.

  • Vincent

    Hi Joe,

    Very good job. It works here. One more concern, in the third line of your script:
    “set tdc = createobject(“TDApiOle80.TDConnection”)
    tdc.InitConnectionEx “http://qcURL/qcbin/”
    tdc.login “yourUserName”,”yourPassword”

    I need put my username&password here, so there is a security concern here. Can we encrypt password here like what QTP does?

    • Vincent » HI Vincent – We use a generic ALM/QC user for our scheduler scripts so we don’t usually encrypt the password. You could store the password in a DB and write some code that reads the password from the DB but I don’t think that would be super secure. Anyone else have any ideas?

  • Rohith

    Hi Joe,

    Thanks for the helpful post. I had tried the RunTestSet.exe. It was successful. Moreover, I found an issue that, in the email notification the test set name and tester name are displaying in symbols..Any thought on this?? Thanks in advance

    Regards
    Rohith

    • Rohith » Hi Rohith – unfortunately I cannot think of what would cause this behavior. Anyone else have any suggestions?

  • Madhu Suthanan

    @ zoor
    I know this guy Jagadeeswaran Elumalai.
    What is the tool name that will schedule the qtp scripts in batch mode?
    To run independently.
    I forgot that application.

  • Saro

    Hi All,.
    I am looking for QTP code for Sending the email with Test Result attachment from QC through Lotus Notes.
    I did QTP script to attach the Test Results in Test Lab module, but the email is triggered without the attachment.

    Can any one please help me on this.

    Thanks

  • DM

    Thank you ver much for such a great information. Is there any way I can provide specific test names of test set to execute instead of executing whole test set.
    Thanks

  • Jez

    Hey Rob,
    My question is related to Saro’s, I have an email notification set on my testset in case of a failure, but since IE doesn’t actually open QC can’t send the email upon failure. Is there a way to run this script with QC being visibly open? Thanks.

  • Priyank

    hi Joe,

    After running above steps, my Test Run scheduler is opening but getting error “the requested operation requires elevation”. Tried both the methods, but getting same error in Test Run scheduler. I am using Win 7. Please assist.

    Thanks in advance

    • Priyank » Verify your QC/ALM and local machine permissions. I’ve never seen this error before but I’ve seen similar errors caused by permission or misspelling errors. Anyone else seen this before?

  • Sam

    I have question in QTP n QC…

    Scenario: how to run multiple QTP scripts from QC on different remote machines, say for example 100 script in QC test lab, to run on 5 machines, each machine having 20 scripts, while running all at a time from QC, if one of the machine’s h/w got crashed, these scripts are stopped, so at any cost we need to execute them (not manually) those scripts should automatically distribute or run on any available machine.

    Plz help me in this

    -thanks,
    SK

  • Jürgen P.

    Hi Joe,

    I’ve tried the RunTestSetScheduler tool from your website and ran into the following issue:

    C:\>RunTestSet /s:https://myalmserver/qcbin /n:DOMAIN /d:Project /u:myUser /p: /l /t:MyTestSet /f:Root\folder
    Initializing TDServer https://myalmserver/qcbin
    Connecting to DOMAIN.Project project
    Checking TestSet : Root\folder\MyTestSet
    Opening Scheduler…
    Error: Error: Class not registered

    Do you have any idea what’s wrong? It “feels” like Opening Scheduler times out:

    printf(“Opening Scheduler…\n”);
    // get scheduler
    ITSSchedulerPtr spScheduler = spTestSet->StartExecution(_T(“”));

    I have the Remote Agent installed as well as the connection AddIn. Are there any requirements I missed?

    Thanks!

    • Jürgen P.

      Joe,.

      in the meatime I’ve solved the issue.

      I had to reregister the HP ALM client from https://xxx/qcbin/start_a.jsp?common=true. I’ve seen this solution here before, but it did not work for me the first time.

      But after deleting the client directory at
      C:\Users\All Users\Application Data\HP\ALM-Client it was successfully installing the client and registering all DLLs.

      All issues gone now. Hope this helps!

      • Jürgen P. »Sorry I planned to get back to you today.The registering of the ALM client does tend to solve a lot of these types of issues. Thanks for the update!

      • bchan

        The solution to deleting: C:\Users\All Users\Application Data\HP\ALM-Client, was key to solving my problem of not being able to re-register the client!!

        Thanks for finding this elusive folder and trying it out.

        What’s confusing is this same folder exist under my user account and is recreated when accessing QC from my Web Browser for the first time…

        Wish this solution was more clearer as I even went the route of uninstalling C++ 2005, 2008 distributable with no success there.

        I’m now able to use RunTestSet!!

  • Pradeep

    hi Joe,

    Nice job, I am able to run the whole test set using the above code. But is there a way where we can just run only the failed scripts in a test set and also can we run only few scripts from a give test set. Like only 5 scripts from a test set which as 20 scripts.

    thanks,

  • Gaurav

    HI,
    I have created batch runner as above. I am taking Test set name value from Excel file. There will be more than 25 testsets I will be executing from batchrunner.
    Now, batchrunner is running for first testset and it is trying for second one before first completes run. I can not put wait as i do not know how much time each test will take to execute.
    Now I want to put wait time so until one test set gets executed, Loop should not go to next test set from Excel.
    I need to do it. Can someone help to resolve issue?

  • Nagaraj N

    Joe ,

    The script is very helpful to me.But i am very weak at scripting languages.

    could you please customize it to me as per my rewuirement..

    It will be great help…

    Scenerio :

    I don’t want execute all tests under the TestSet..

    i wan’t to execute selected test under Testset..

    Please help me….

    Thanks
    Nagaraj

  • Nagaraja N

    Hi Joe ,

    Nice work…Script & concept helped me a lot….
    I am able to execute all the Testcases under Testset….

    Suppose i wan’t to execute required test cases (not all only few) then where shall i have to change the code…Please help me….

    If anyone knows about this ,Please help me ….:)

  • Jai

    Hi Joe,

    I have created below .VBS file for QTP11 and QC11. It’s not running the qtp scripts. When I am directly running it from QC it’s running fine. Please have a look and revert.

    ‘************************************START*******************************************

    Const QCuser=”q1wa”
    Const QCpassword=””
    Const QCdomain=”X_FORVALTNING”
    Const QCproject=”Bankplatform_finacle_auto”
    Const QCURL=”http://nkm18du3.nykreditnet.net:8080/qcbin”
    ‘********Declare the variables*******
    Dim qtpApp,logFileName,QCConnect,tsTreeManager,testSetFolder,mytestSet,tsList
    ‘*************************************
    logfileName = replace(replace(now,”/”,”_”),”:”,”_”)&”.txt”
    logfilepath =”C:\AutomateTest\Logs\”& logfileName
    msgbox logfilepath
    ‘************************************
    QCLogin
    mytestSet=”Set1″
    ‘Found the test set
    ‘Code to select the testset need to run
    set tsTreeManager= QCConnect.TestSetTreeManager
    set testSetFolder=tsTreeManager.NodeByPath(“Root\My_Suite”)
    set tsList=testSetFolder.FindTestSets(mytestSet)
    LogThis”Total Test Sets found are ” & tsList.count
    set theTestSet=tsList.Item(1)
    LogThis “Name of TestSet is “& theTestSet.Name
    LogThis “ID of TestSet is “& theTestSet.ID
    Set scheduler= theTestSet.StartExecution(“”)

    ‘scheduler.runAllLocally=True
    Scheduler.TdHostName = “NKM17ARI”
    scheduler.run
    set execStatus= scheduler.ExecutionStatus
    RunFinished=False
    While (RunFinished=False)
    execStatus.RefreshExecStatusInfo theTestSet.ID,True
    RunFinished=execStatus.Finished
    Wscript.Sleep 5000
    Wend
    LogThis”Test Set Executed Sucessfully”

    ‘While Not scheduler.executionstatus.finished
    ‘Wscript.Sleep 5000
    ‘Wend
    ‘LogThis”Test Set Executed Sucessfully”

    Set tsTestFact=theTestSet.TSTestFactory
    Set testSetTestsList=tsTestFact.NewList(“”)
    For Each theTSTTest In testSetTestsList
    With theTSTTest
    ‘LogThis “Name: “& .Name & “, ID: ” & .ID & “, status: ” & .Status
    End With
    Next
    Logout
    LogThis”Logged Out to QC”
    ‘************************************
    Public Function QCLogin
    LogThis(“Connecting to QC”)
    Set QCConnect=CreateObject(“TDApiole80.TDConnection”)
    ‘Give QC URL
    QCConnect.InitConnectionEx QCURL
    ‘Check if we are able to hit the qc server
    If Not QCConnect.connected Then
    LogThis “Not able to hit the QC Server”
    WscriptQuit
    End if
    ‘Give Username and password
    QCConnect.Login QCuser,QCpassword
    ‘Checked If you logged in
    If Not QCConnect.LOggedIn Then
    LogThis “Not able to Logged to QC”
    WscriptQuit
    End If
    LogThis “Sucessfully Login in QC”
    ‘select domain & project
    QCConnect.Connect QCdomain,QCproject
    ‘Checked If you get connected to domain and project
    If Not QCConnect.ProjectConnected Then
    LogThis “Not able to connect to project”
    WscriptQuit
    End If
    LogThis “Sucessfully Login in Project — Continue”
    End Function
    Public Function Logout
    ‘LogOut
    QCConnect.Disconnect
    QCConnect.LogOut
    QCConnect.ReleaseConnection
    End Function
    Function LogThis(msg)
    Dim fso,myfile
    Const ForAppening=8
    Set fso=CreateObject(“Scripting.FileSystemObject”)
    Set myfile=fso.OpenTextFile(logfilepath,ForAppening,true)
    myfile.writeLine now &” –> ” & msg
    Set fso=Nothing
    Set myfile=nothing
    End function
    ‘******************************************END*********************

  • James

    My test cases automated with ALM with BPT and QTP 11.

    The test data was mapped to test resource folder in the form of excel ( Dynamic data in BPT)

    when run the test cases from test lab manually means select test cases and click run that moment, while execution it is
    picking dynamic data as expected and execution working fine

    when run the same test cases through OTA code, while execution it is taking static data instead of dynamic data, but execution working fine.

    pl provide solution.

    I am using the below code:
    set tdc = createobject(“TDApiOle80.TDConnection”)
    tdc.InitConnectionEx “http://qcURL/qcbin/”
    tdc.login “yourUserName”,”yourPassword”
    tdc.Connect “yourDomain”,”yourProject”

    Set objShell = CreateObject(“WScript.Shell”)
    Set TSetFact = tdc.TestSetFactory
    Set tsTreeMgr = tdc.TestSetTreeManager
    Set tsFolder = tsTreeMgr.NodeByPath(“Root\Formal Tests\YourTestDirectory”)
    Set tsList = tsFolder.FindTestSets(“Your TestSet name. This is case sensitive!”)

    Set theTestSet = tsList.Item(1)
    Set Scheduler = theTestSet.StartExecution(“”)
    Scheduler.RunAllLocally = True
    Scheduler.run

Leave a Comment

css.php