How to execute QuickTestPro (QTP) tests automatically unattended...

3,508 views
Skip to first unread message

Dmitry Motevich

unread,
Nov 2, 2006, 6:53:37 AM11/2/06
to QTP - Mercury QuickTest Priofessional - Automated Testing
I need to run QTP tests without a human in the loop - that is
automatically and unattended. If QTP needs to be driven by an external
script (shell, Perl, Windows's CScript,...) that's fine.

The requirement is that I can issue a single command ( or have a
scheduler do it) and walk away. When I come back, I want to see if all
the tests passed or if any failed (thumbs up/thumbs down).

I've seen mention of a unsupported tool from the QTP folks that does
this but I've not been able to find it (One chap I found who had it
doesn't have it any more.)

I'd appreaciate any help or pointers you might have.

Dmitry Motevich

unread,
Nov 2, 2006, 6:55:47 AM11/2/06
to QTP - Mercury QuickTest Priofessional - Automated Testing
I think, my answer will help you...
 
I created several scheduled tasks - they send special messages to some sites (it's a not a spam :) ).
 
Let's see the one scheduled tasks.
It runs every 3 days the file:
"D:\Program Files\Mercury Interactive\QuickTest Professional\Tests\AllenCarr\aldebaran_ru\_bat\start_test.cmd"
 
This cmd-file contains:
echo ========================================== >> test_results.txt
date /T >> test_results.txt
time /T >> test_results.txt

cscript //nologo .\test.vbs >> test_results.txt 2>&1


Next, file test.vbs contains:
Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
Dim qtTest 'As QuickTest.Test ' Declare a Test object variable
Dim qtResultsOpt 'As QuickTest.RunResultsOptions ' Declare a Run Results Options object variable

Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
qtApp.Launch ' Start QuickTest
qtApp.Visible = True ' Make the QuickTest application visible

qtApp.Open "D:\Program Files\Mercury Interactive\QuickTest Professional\Tests\AllenCarr\aldebaran_ru", True ' Open the test in read-only mode

' set run settings for the test
Set qtTest = qtApp.Test
qtTest.Run

WScript.StdOut.Write "Test status: " + qtTest.LastRunResults.Status + vbCr ' Check the results of the test run

qtTest.Close ' Close the test

qtApp.Quit ' Close the QTP'

And, last note... "D:\Program Files\Mercury Interactive\QuickTest Professional\Tests\AllenCarr\aldebaran_ru" is my script which sends special messages to site.

That's all.
So, what I have is the following... Every 3 days scheduler executes this script. Result of test execution is written to file ("test_results.txt" in this case).
Pay attention, I use file logging for results ( WScript.StdOut.Write "Test status: " + qtTest.LastRunResults.Status + vbCr). But you can send messages via Win-messenger service or send emails (I can provide such scripts for additional reward :) ).

If you have some questions, please feel free to contact me if you need. I will answer...
 
--
Dmitry Motevich
 

MC

unread,
Nov 23, 2006, 9:14:04 AM11/23/06
to QTP - Mercury QuickTest Professional - Automated Testing

Hi
This is a very useful script for running QTP tests automatically.
Thanks.

Is there a way to also pass input parameters to the test and read the
output parameters?

-----
M.

> --

vadim.feelsgood

unread,
Nov 23, 2006, 9:43:44 AM11/23/06
to QTP - Mercury QuickTest Professional - Automated Testing
Hi Dmitry,

Try to use Quality Center (former TestDirector).
It has a cool scheduler for QTP.

Dmitry Motevich

unread,
Nov 24, 2006, 10:22:50 AM11/24/06
to Mercu...@googlegroups.com
Hello,

Sure! There are 2 ways to pass/retrieve parameters from test:

1. Manually:
  Open menu item: "Test\Settings\Parameters". You can specify here heeded parameters.
  I've attached the screenshot.See it, please.

2. Via start-script. (It is more flexible and convenient way for me.):

Dim qtApp 'As QuickTest.Application ' Declare the Application object variable


Dim pDefColl 'As QuickTest.ParameterDefinitions ' Declare a Parameter Definitions collection
Dim pDef ' As QuickTest.ParameterDefinition ' Declare a ParameterDefinition object
Dim rtParams 'As QuickTest.Parameters ' Declare a Parameters collection
Dim rtParam ' As QuickTest.Parameter ' Declare a Parameter object
'Dim cnt, Indx As Integer



Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
qtApp.Launch ' Start QuickTest
qtApp.Visible = True ' Make the QuickTest application visible

qtApp.Open "D:\Tests\MyTest"

' Retrieve the parameters collection defined for the test.
Set pDefColl = qtApp.Test.ParameterDefinitions

cnt = pDefColl.Count
Indx = 1

' Display the names and values of each of the parameters in the collection.
While Indx <= cnt
    Set pDef = pDefColl.Item(Indx)
    MsgBox "Param name: " & pDef.Name & "; Type: " & pDef.Type & "; InOut: " & pDef.InOut & "; Description: " _
        & pDef.Description & "Default value: " & pDef.DefaultValue
    Indx = Indx + 1
Wend

Set rtParams = pDefColl.GetParameters() ' Retrieve the Parameters collection defined for the test.

Set rtParam = rtParams.Item("InParam1") ' Retrieve a specific parameter.
rtParam.Value = "Hello" ' Change the parameter value.

qtApp.Test.Run , True, rtParams ' Run the test with changed parameters.

MsgBox rtParams.Item("OutParam1").Value ' Display the value of an output parameter after the test runs.

--
Dmitry Motevich
parameters.jpg

Dmitry Motevich

unread,
Nov 24, 2006, 10:25:44 AM11/24/06
to Mercu...@googlegroups.com
Yes,

QC using is a good solution... But I have not currently Quality Center :(
Thank you for your advise!

--
Dmitry Motevich

MC

unread,
Nov 26, 2006, 4:51:05 AM11/26/06
to QTP - Mercury QuickTest Professional - Automated Testing

Hi Dimitry,

Thank you very much for your detailed answer. I was looking for the
second way to do it - scripting - and your sample gave me exactly what
I needed.

For others who are interested in running tests from external scripts,
take a look at the QuikTest Automation Reference documentation that
comes with QTP installation. I just discovered it.

-----
M.

> > > On 11/2/06, Dmitry Motevich <manga...@gmail.com> wrote:
>
> > > > I need to run QTP tests without a human in the loop - that is
> > > > automatically and unattended. If QTP needs to be driven by an
> > external
> > > > script (shell, Perl, Windows's CScript,...) that's fine.
>
> > > > The requirement is that I can issue a single command ( or have a
> > > > scheduler do it) and walk away. When I come back, I want to see if
> > all
> > > > the tests passed or if any failed (thumbs up/thumbs down).
>
> > > > I've seen mention of a unsupported tool from the QTP folks that does
> > > > this but I've not been able to find it (One chap I found who had it
> > > > doesn't have it any more.)
>
> > > > I'd appreaciate any help or pointers you might have.
>
> > > --
>

> parameters.jpg
> 33KViewDownload

Tanu Malik

unread,
May 8, 2015, 9:10:13 AM5/8/15
to mercu...@googlegroups.com, Mercu...@googlegroups.com
hi Dmitry ,
 
Can you please send me the script on how can i send emails in outlook through QTP. Actually i am using UFT, windows7, so can you please let me know how can i auto tiigger the autiomation script.
Appreciate your help.

amit rathi

unread,
May 11, 2015, 3:29:31 AM5/11/15
to mercu...@googlegroups.com, tanvim...@gmail.com
Hi tanu,
script can be like that.

Sub SendMail (strTextBody)
    Set objEmail = CreateObject("CDO.Message")
    objEmail.From = "UFT...@int.xxxx.com"
    objEmail.To = "amit....@xxxxx.com"
    objEmail.Subject = "UFT Regression Test results for IE10 "
    objEmail.Textbody = strTextBody
    objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.xxxxx.com"
    objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    objEmail.Configuration.Fields.Update
    objEmail.Send
End Sub

Thanks
Amit Rathi

--
--
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to Mercu...@googlegroups.com
To unsubscribe from this group, send email to
MercuryQTP+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en

---
You received this message because you are subscribed to the Google Groups "QTP - HP Quick Test Professional - Automated Software Testing" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mercuryqtp+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tanu Malik

unread,
May 12, 2015, 9:27:34 AM5/12/15
to amit rathi, mercu...@googlegroups.com
hi Amit,
 
Below is the script and now i am getting different type of error.
Set oMessage = CreateObject("CDO.Message")

oMessage.Configuration.Fields.Item _
'SMTP Server
oMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="nasa2smtp.mmc.com"

oMessage.Configuration.Fields.Item _
oMessage.Configuration.Fields.Update
oMessage.Subject = "Test"
oMessage.Sender = "tanvi.m...@xxxmail.com" 'any non-existing mail id will also work.
oMessage.To = "tanvi.malik@xxxx.com"
'oMessage.CC = "arpit....@qwqsh.com"
'oMessage.BCC = ""

oMessage.AddAttachment "C:\Sanity_Automation1\Result\Result.xls"
oMessage.TextBody = "Hi" & vbcrLf & vbCrlf & "PFA the Smoke Test Automation Results" & vbCrlf & vbCrlf & "Thanks" & vbcrlf & "Tanvi Malik"
oMessage.Send

Set oMessage = Nothing
 
 

Regards,
Tanvi Malik
Error QTP.png

Richard Johnson

unread,
Oct 16, 2015, 7:30:21 AM10/16/15
to QTP - HP Quick Test Professional - Automated Software Testing, Mercu...@googlegroups.com
Hi Dmitry Motevich,


Thanks so much for this automation topic :)


thanks,
Richard
Reply all
Reply to author
Forward
0 new messages