QC & QTP – How to schedule a recurring test set

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

Succeeding with Automation Awesomeness. I’ll show you how!

Test automation, like all development efforts, is difficult. Most projects don't succeed. You can do better! Sign up and receive exclusive content like my free 10 Proven Actionable Steps for Automation Awesomeness from some of the biggest testing leaders in the industry. Let me help YOU succeed with Test Automation! Sign up now:

Leave a comment:

72 comments
byzoor - December 2, 2011

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.

Reply
    Joe Colantonio - December 5, 2011

    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

    Reply
Rob - January 6, 2012

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

Reply
    Joe Colantonio - January 6, 2012

    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

    Reply
      Andrei - January 13, 2012

      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

      Reply
        Benoit - February 6, 2012

        Hello,

        Thx Joe ;)

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

        … :S

        Benoit.

        Reply
          Joe Colantonio - February 9, 2012

          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

          Reply
          Benoit - February 10, 2012

          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.

          Reply
Rob - January 9, 2012

Hey Joe,

Thank you so much its working :)

Appreciate your effort and support.

Regards,
Rob

Reply
    Joe Colantonio - January 9, 2012

    Rob » Excellent news Rob!

    Reply
    rishim - February 7, 2012

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

    Reply
Ben - February 8, 2012

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.

Reply
    Ben - February 15, 2012

    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.

    Reply
shar - February 19, 2012

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

Reply
    Joe Colantonio - February 20, 2012

    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?

    Reply
      shar - February 21, 2012

      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.

      Reply
Changa - February 24, 2012

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

Reply
    Changa - February 24, 2012

    Environment: Windows7 OS

    Reply
Changa - March 5, 2012

Hi Joe,

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

Thank you

Reply
Lorena - March 8, 2012

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?

Reply
Lor - March 14, 2012

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?

Reply
    Joe Colantonio - March 15, 2012

    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

    Reply
      Johan - March 22, 2012

      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

      Reply
Lor - March 15, 2012

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

Reply
aditya - July 5, 2012

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

Reply
    Joe Colantonio - July 27, 2012

    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

    Reply
Tony - August 17, 2012

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.

Reply
    Tony - August 17, 2012

    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.

    Reply
      Joe Colantonio - August 17, 2012

      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.

      Reply
Manish - August 21, 2012

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

Reply
    Joe Colantonio - August 30, 2012

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

    set tdc = createobject("TDApiOle80.TDConnection")
    tdc.SendMail "listOfEmailAddress","","Subject","Message"
    Reply
      Anca - November 12, 2012

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

      Reply
Vikas Gholap - September 3, 2012

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

Reply
    Vikas Gholap - September 5, 2012

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

    Reply
      Viki - September 5, 2012

      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.

      Reply
        Joe Colantonio - September 11, 2012

        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

        Reply
Pradeesh - September 6, 2012

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.

Reply
Vincent - September 18, 2012

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?

Reply
    Joe Colantonio - September 19, 2012

    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?

    Reply
Rohith - October 10, 2012

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

Reply
    Joe Colantonio - October 11, 2012

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

    Reply
Madhu Suthanan - October 17, 2012

@ 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.

Reply
Saro - November 19, 2012

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

Reply
DM - December 12, 2012

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

Reply
Jez - December 20, 2012

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.

Reply
Priyank - December 27, 2012

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

Reply
    Joe Colantonio - December 28, 2012

    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?

    Reply
Sam - January 7, 2013

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

Reply
Jürgen P. - February 19, 2013

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!

Reply
    Jürgen P. - February 21, 2013

    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!

    Reply
      Joe Colantonio - February 21, 2013

      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!

      Reply
      bchan - February 25, 2014

      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!!

      Reply
Pradeep - March 26, 2013

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,

Reply
Gaurav - April 17, 2013

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?

Reply
Nagaraj N - October 7, 2013

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

Reply
Nagaraja N - October 9, 2013

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 ….:)

Reply
Jai - January 8, 2014

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*********************

Reply
James - March 8, 2014

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

Reply
Alien - July 23, 2014

Hi,
I have qc 8.2 test cases data, now I want to export all test cases from QC 8.2 to an excel sheet.
Can you please provide me the solution.
createobject(“TDApiOle80.TDConnection”) is giving run time error for me.

Reply
    Joe Colantonio - July 23, 2014

    Does this sample code work or do you get same error?

    QCURL = “http://192.6.38.117:8080/qcbin/”
    QCUser = “demo_admin”
    QCPass = “hphphp”
    QCDomain = “DEFAULT”
    QCProject = “QualityCenter_Demo”

    Set TDConnection = CreateObject(“TDApiOle80.TDConnection.1″)
    TDConnection.InitConnectionEx QCURL
    TDConnection.Login QCUser, QCPass
    TDConnection.Connect QCDomain,QCProject

    If TDConnection.ProjectConnected Then
    Set TestFact = TDconnection.TestFactory
    Set tests = TestFact.NewList(“”)
    For Each test In tests
    msgbox “[QualityCenter] ” & test.Field(“TS_SUBJECT”).Path & “\” & test.Name
    Next
    TDConnection.Disconnect
    TDConnection.Logout
    End If
    TDConnection.ReleaseConnection
    Set TDConnection = Nothing

    Reply
jay - September 4, 2014

Hi Joe,

After manually opening remote machine if I execute RunTestSet its working, but when I have closed my remote machine how to execute scripts using RunTestSet. Its not working.

Reply
    Joe Colantonio - September 16, 2014

    What are you using to connect to the remote machine Remote Desktop Connection? If its RDP I think its the way RDP works that is causing the issue. I use VNC to connect to my remote machines to get around this behavior

    Reply
Greg Paskal - January 19, 2015

Joe,
As always, you have such great content online for the automation folks. Thanks for publishing this article, I look forward to our next chat.

Greg

Reply
    Joe Colantonio - January 20, 2015

    Thanks Greg – I’m waiting for you to post another article so I can have you back on TestTalks :)

    Reply
Suryapratap - February 5, 2015

In your code above, you have run all tests locally. I do remember that for ALM to run a test locally, the UFT/QTP should have the option” Allow other tools to access UFT” selected. Can we set this option without actually opening UFT, like through a code or something??

Reply
    Joe Colantonio - February 11, 2015

    I don’t think you can set this programmatically – maybe there is a registry setting that you can update? Anyone else know?

    Reply
Ram - April 10, 2015

After run the testset form QC , UFT 12.02 is automatically closed.
Is there a option to keep open UFT even after stopped/run the testtset from QC ??

Reply
Click here to add a comment

Leave a comment: