You are on page 1of 76

c  

c
  
   

m  



m  
 
Just as you use QuickTest to automate the testing of your applications, you can use the
QuickTest Professional automation object model to automate your QuickTest
operations. Using the objects, methods, and properties exposed by the QuickTest
automation object model, you can write programs that configure QuickTest options and
run tests or components instead of performing these operations manually using the
QuickTest interface.

Automation programs are especially useful for performing the same tasks multiple times
or on multiple tests or components, or quickly configuring QuickTest according to your
needs for a particular environment or application.
m m  
 
ou can use the QuickTest Professional automation object model to write programs that
automate your QuickTest operations. The QuickTest automation object model provides
objects, methods, and properties that enable you to control QuickTest from another
application.

m 
Automation is a Microsoft technology that makes it possible to access software objects
inside one application from other applications. These objects can be easily created and
manipulated using a scripting or programming language such as VBScript or VC++.
Automation enables you to control the functionality of an application programmatically.

An object model is a structural representation of software objects (classes) that


comprise the implementation of a system or application. An object model defines a set
of classes and interfaces, together with their properties, methods and events, and their
relationships
  
m 
 
Ossentially all configuration and run functionality provided via the QuickTest interface is in
some way represented in the QuickTest automation object model via objects, methods, and
properties. Although a one-on-one comparison cannot always be made, most dialog boxes in
QuickTest have a corresponding automation object, most options in dialog boxes can be set
and/or retrieved using the corresponding object property, and most menu commands and
other operations have corresponding automation methods.

ou can use the objects, methods, and properties exposed by the QuickTest automation
object model, along with standard programming elements such as loops and conditional
statements to design your program.

Automation programs are especially useful for performing the same tasks multiple times or
on multiple tests or components, or quickly configuring QuickTest according to your needs
for a particular environment or application.

For example, you can create and run an automation program from Microsoft Visual Basic
that loads the required add-ins for a test or component, starts QuickTest in visible mode,
opens the test or component, configures settings that correspond to those in the Options,
Test or Business Component Settings, and Record and Run Settings dialog boxes, runs the
test or component, and saves the test or component.
É



m  

¯ Ô  


  

Ý 
 
     
 


Ý  
 

   
   


Ý 
   

 
 
    
! 
"  


Ý     


#

ou can then add a simple loop to your program so that your single program can perform the
operations described above for multiple tests or components.

ou can also create an initialization program that opens QuickTest with specific configuration
settings. ou can then instruct all of your testers to open QuickTest using this automation
program to ensure that all of your testers are always working with the same configuration.

Deciding When to Use QuickTest Automation Programs


Like the tests or components you design using QuickTest, creating a useful QuickTest
automation program requires planning, design time, and testing. ou must always weigh the
initial investment with the time and human-resource savings you gain from automating
potentially long or tedious tasks.

Any QuickTest operation that you must perform many times in a row or must perform on a
regular basis is a good candidate for a QuickTest automation program.

The following are just a few examples of useful QuickTest automation programs:

ô² ou can write a program that


automatically starts QuickTest and configures the options and the settings required for
recording on a specific environment.
Maintaining your tests or components ² ou can write a program that iterates
over your collection of tests and components to accomplish a certain goal. For example:

Y Updating values²opening each test or component with the proper add-ins, running it in
update run mode against an updated application, and saving it in order to update the values
in all of your tests and components to match the updated values in your application.
Y Applying new options to existing tests or components²When you upgrade to a new
version of QuickTest, you may find that the new version offers certain options that you want
to apply to your existing tests and components. ou can write a program that opens each
existing test and component, sets values for the new options, then saves and closes it.

V 
 
ou can design your own
applications with options or controls that run QuickTest automation programs. For example,
you could create a Web form or simple Windows interface from which a product manager
could schedule QuickTest runs, even if the manager is not familiar with QuickTest.
 
   c 
 
 
 
We can do this job with a simple VBScript code. This will reduce the duration of work flow to
less than 2 seconds and you get the result instantly at the click of a button

V 

Dim AllProcess
Dim Process
Dim strFoundProcess
strFoundProcess = False
Set AllProcess = GetObject("winmgmts:") 'create object
For Oach Process In AllProcess.InstancesOf("Win32_process") 'Get all the processes running in
your PC

If (Instr (Ucase(Process.Name),"TASKMGR.O O") = 1) Then 'Made all uppercase to remove


ambiguity. Replace TASKMGR.O O with your application name in CAPS.

msgbox "Application is already running!" 'ou can replace this with Reporter.ReportOvent

strFoundProcess = True
Oxit for
Ond If
Next

If strFoundProcess = False Then


msgbox "Go ahead!Application is not running" 'ou can replace this with
Reporter.ReportOvent
Ond If

Set AllProcess = nothing

To check whether this is working:

1) Copy the above code to a notepad and save file as test.vbs on your desktop.

2) Open the Windows Task Manager[Ctrl-Shift-Osc].

3) Double click on file created above(test.vbs)

4) ou should get a message "Application is already running!"

5) Done...Onjoy!
× É c  

  

 

 c
   
 


There can be situations when you need to schedule your QTP scripts so that they can run
when you are not present in front of your PC. I will show you a demo below.

1) Create a .vbs file to launch QTP with required settings, add-ins etc. This code will open
your QTP and run your script froma specified location when it is actually closed (Pretty cool
..)

Here is a sample vbs code


Set App = CreateObject("QuickTest.Application")
App.Launch
App.Visible = True
App.WindowState = "Maximized" 'Maximize QTP window
App.ActivateView "ExpertView" 'Display Expert View
App.open "C:\Test1", False 'Opens test in editable mode
App.Test.Run 'Runs the test
App.Quit 'Close QTP
2) ok, for the newbies. Create a sample QTP test and save it as  at the location above.
Copy the code into notepad and name the file as testing.vbs

3) Now we will automate the opening of vbs file through Windows Scheduler. Go To Start
> Control Panel > Schedule Tasks > Click Add Schedule Tasks Click Next on the screen.
4) Click Browse and and select the .vbs file you just created.ou will get this screen
5) Give a name to the task and select the frequency for performing the given tasks. For
this demo we will select "One time only"
À) Select Start Time and Start Date. For this demo, select Start Time as current time+5 mins
and Start date as todays date.

7) Next Screen Onter "UserName", "Password" and "Confirm Password" Click Next and
you should get this screen.

8) Click on Finish and yo Man, you're done.


à
à !

" 
 

#
$
à  

àà    

Set f=CreateObject("Scripting.FileSystemObject")
Set f1=f.CreateTextFile("c:\text.txt")
f1.writeline "aaa bbb"
f1.writeline "ccc ddd"

The above script creates a notepad in C: drive with following contents:


aaa bbb
ccc ddd

Set f2=f.OpenTextFile("c:\text.txt")
While f2.AtOndOfStream <>true
f3=f2.readline
x=Split(f3, "")
msgbox x(0)
msgbox x(1)
WOnd
The above script is used for data driven using notepad directly. Here we are not importing
data to excel sheet. Directly values are retreived from notepad. We are using while loop and
reading each line till the end. Split function splits the line where space(" ")occurs. Line is
divided to 2 parts.one before space and other after space. For example we have 1st line in
notepad as aaa bbb

here aaa is 1st part and bbb is 2nd part

x(0)=aaa
x(1)=bbb

all values are read this way using while loop. One point to note here is if any line is empty in
notepad datadriven testing is stopped before that line. It will not proceed further.so we have to
give values without any empty lines in notepad. To make things more clear,

Suppose u have

aaa bbb
ccc ddd

Datadriven is stopped at aaa and bbb only because next line is empty. Datadriven is stopped
after 1st line.
à   

This Script gives result by retrieving values from datatable.


AB
55
ÀÀ
77
88
99
In datatable enter test data as shown above. Fill values below "A" and "B"script required for
DDT(data driven testing)is

val1=datatable("A",1)
val2=datatable("B",1)
res=cint(val1) +cint(val2)
msgbox res

Result will be 10,12,14,1À,18.

datatable("column name",sheetname/id)
cint is a function which converts string to integer.

check what will happen if u are not using cint in third step.
just replace this res=val1+val2 in place of res=cint(val1) +cint(val2)


É


%


% 

 m  
Oventually, in any software system, users may defects or we can say bugs in the
developed program. Normally, these bugs are fixed, the fixes are then tested, and the updated
software is released back to the users . However, since the software is so tightly coupled or we
can due to the interconnected nature of software, even the smallest change can wreak
unpredictable havoc when the implications of that change are not properly understood.

Any software change, even one that corrects a known defect, can affect
a system in an unforeseen manner and potentially cause problems that are worse
than those that the change was originally trying to address.

Regression testing is the practice of retesting of a software system that has been
modified to ensure that no previously-working functions have failed as a result of
defect reparations or newly added functionality.

Comprehensive regression testing fully ensures that a software system is functioning as designed.
Comprehensive regression testing, however, is rarely feasible, given the time and resource
constraints placed on the typical software development team.
As a software system expands and evolves, it becomes more and more difficult to test every
piece of functionality. This problem is compounded by the frequency of software builds. In an
environment where software builds are done on a nightly basis, comprehensive
regression testing of every build is essentially impossible. Typically, in these
environments, the testing of previous functionality is foregone to allow for testing of
new fixes and new functionality. This leaves open the possibility that the software
team will release software with undiscovered defects.

Hence we go for an Automation tool that helps us in addressing these challenges. Through an
Automation tool, we create scripts and which are quite helpful in retesting the original
system's functionality. Overy time we get a new build, we execute the created automation
scripts to check the previous working functionality. And the most important benefit of
automation is that we can execute scripts in an unattended mode means it frees QA persons to
do other important tasks while the scripts are running automatically.
à
 !
c  

O  V V   ! 


Script to get count,names of all open browsers and to close them.

Set b=Description.Create
b("micclass").value="Browser"
Set obj=Desktop.ChildObjects(b)
msgbox obj.count
For i=0 to obj.count-1
c=obj(i).getroproperty("name")
msgbox(c)
obj(i).Close
Next
O  "  

SystemUtil.run "iexplore.exe","http://www.google.com"
Browser("name:=Google.*").Page("title:=Google.*").WebOdit("name:=q")
.set"Testing"
Browser("name:=Google.*").Page("title:=Google.*").
WebButton("name:=Google Search").Click

O  

V
   #
Usage of Description Object is shown below

Creates a new, empty description object in which you can add collection of
properties and values in order to specify the description object in place of a test
object name in a step.

Set Button=Description.Create()

Button("type").Value="submit"
Button("name").Value="Google Search"
Button("html tag").Value="INPUT"

Browser("Google").Page("Google").WebButton(Button).Click
VOVm$$ OVOV %O&m#m"O'ô&"
Vô$à (OV #)#O) *
Dim obj_check

Set obj_check=Description.Create

obj_Check("html tag").value="INPUT"
obj_Check("type").value="checkbox"

Dim allcheckboxes
Set allcheckboxes=Browser("Browser").Page("orkut - home").ChildObjects(obj_check)
a= allcheckboxes.count()
msgbox a

For i=0 to (a-1)


allcheckboxes(i).Set "ON"
Next
²

c&'(

& ! 
 #+,-
Are you new to HP Quick Test Pro 9.2 (QTP)? Say yes and you are at the right place, at the
right time. This article is for newbie¶s who want to start their carrier with QTP or have just
started with QTP. The article will give you a brief overview of various features of QTP, and
since it is for newbie¶s we won¶t be going into too much details of every feature.

 #+,-
* HP Quick Test Pro 9.2 is a functional automation and regression testing tool
* QTP provides record and playback of events
* Uses VBScript as the scripting Language
* Provides keyword view and expert view to view test cases.
* Latest versions of QTP is 9.5 (launched in mid Jan 2008)
* Previous version of QTP: À.5, 8.0, 8.1, 8.2, 9.0, 9.1
* QTP was previously owned by Mercury Interactive®
$ 
 #
When you launch QTP for the first time, Add-in manager window is displayed

m.
* QTP requires Add-in for recognizing object of a specific environment
* By default QTP 9.2 comes with 3 Add-ins: Web, Active and VB
* Some of the Add-ins available for QTP 9.2 are

1. Terminal Omulator (TO)


2. .NOT
3. Java
4. SAP
5. Siebel
À. Stingray
7. VisualAge
8. Web Services

* QTP does not require any Add-in to work on Standard windows application
* Add-ins can only be loaded when starting QTP
Once the selected Add-ins are loaded, QTP window will show up

Hit the record button to start recording. If you are recording for the first time, the Record and
Run Settings dialog box opens.

What all tabs are shown in above dialog would depend on Add-ins that is loaded. Using above
dialog we can set on what all application should QTP record on.

Note: If QTP does not record anything on your application then make sure you have the correct
settings specified in Record and Run Settings«

 /! !
The Keyword View enables you to create and view the steps of your test in a keyword-driven,
modular, table format. This is the only view where complete Test flow can be viewed.

O  0 !
In Oxpert View, QTP displays each operation performed on the application in the form of a
script, comprised of VBScript statements. Complete test flow is not available/visible in this
view.
) . 

* QTP works on objects in Application Under Test (AUT) by storing object description
* This object description is known as a Test Object
* Oach Test Object supports predefined sets of Methods and properties
* The actual object in the AUT which is identified for a Test Object is called the Run-time
object.
* A Test Object can always be present without the AUT
* Run-time object can only be present when AUT is up and running


/
Object Spy is a tool that can be used to spy Test and run time object for looking at properties
and methods supported by object being spied

ô 

* QTP uses three types of properties when identifying a object

1. Mandatory ± Always learn these properties for the object


2. Assistive ± Learn in case Mandatory properties are not enough to identify the object
uniquely
3. Ordinal identifiers ± Learn in case both mandatory and assistive properties are not able to
recognize the objects correctly

* Ordinal identifiers are of three types:


1. Index ± index of object (0, 1, 2 «)
2. Location ± Location of the object on the screen (0, 1, 2 «)
3. CreationTime ± Used only for Browser. Launchtime of browser (0, 1, 2 «)

ô 
 
Launch from menu Tools->Object Identification«

Here we can Add/Remove properties from/to Mandatory and Assistive properties. Objects in
application represent certain special characteristics which allow QTP to map them QTP Test
object. For window objects this characteristic is mostly define by ´regexpwndclass³. In case
application developers don¶t use standard class names while creating object QTP won¶t be able
to identify the object correctly. Below is a checkbox in Search window recognized by QTP as
WinObject

By clicking on the ´User Defined«³ button on Object identification settings window, we can
add such objects and map. Once added QTP will now be able to recognize the object correctly.


 
/
* QTP uses object hierarchy to identify object inside a AUT
* QTP only adds those objects from hierarchy which are necessary for it to identify the object
later.
* In this case QTP will add
Browser(´Google³).Page(´Google³).WebOdit(´q³).Set ´test³ (WebTable object ignored)
* QTP cannot be configured to record such objects automatically.

) /1))
* QTP works on object in application by storing information about the object in Object
repository
* All objects on which user takes an action while recording are automatically added to
object repository
* ´Browser³, ´Google³, ´q³ are three different objects that would be present in OR for
the below generated statement

Browser("Browser").Page("Google").WebOdit("q").set ´Test³

* Copying and pasting code from one script to another script does not work in QTP as
the OR does not get copied to the new script
* There are two types of Object Repositories in QTP:
1. Shared OR: Can be used by multiple scripts. A central location to store all objects
2. Per-Action OR: Overy action has its individual object repository

Per-Action Object Repository


* Default repository
* Specific to actions (Will be used only for a particular action)
* Preferable when application is not dynamic with respect to time
* Cannot be reused
 m
 /
* Can be updated by all actions accessing it
* Preferable when application is dynamic with respect to time
* Used in most automation projects
* Needs maintenance and administration

m

* Provides way of grouping code into business logic
* Are pretty similar to Functions in VBScript
* Have their own Data Table and Object Repository (in case of per-action object
repository)
* Supports input and output parameters
* Actions are of two types: normal and re-usable
* Re-usable actions can be called in other Test.
* QTP does not allow calling another test within a test
* TestFlow represent the top level action. Complete test flow can only be viewed in
Keyword views
ô m


* There are three ways to insert a Action in a test


1. Insert Call to New«
2. Insert Call to Copy«
3. Insert Call to Oxisting«

* Insert Call to New« - Creates a new action and adds a call to the same. Pfrovide the name
"Cancel Ticket" in the "Name" field and click on OK button.
* Adds below line to the code

RunAction "Cancel Ticket", oneIteration

m
. ô VO 2

* Insert Call to Oxisting ± User to insert call to a re-usable action located within the same test or
some other test
* This inserts the call to the existing action. In case the action in present in some other test case
then a read only copy of action is inserted
m
3 ô VV/2

* Insert Call to Copy - Inserts call to an existing re-usable action and creates an editable
copy of that action
* Actions cannot be deleted from a Test from Oxpert view. To delete a action one must go to
the keyword view and delete the action
* An action call cannot be inserted directly by writing code in Oxpert View, it has to be
added through the GUI first.

m
ô 

An action can be run for 1 or more rows from its Local Data Table.

* QTP supports there types of iteration modes:


1. Run one iteration only
2. Run on all rows
3. Run from Row to Row

* Similar to Action, a test can also be run for multiple iterations from Global Data Table
/#  
* Parameterization allows us to pick different values at run time.
* Reduces Time and Offort.
* Usage of data drivers allows us to use the same data for various input boxes.
* Parameterization can also be done for checkpoints.

à 
* Data Table is excel like spreadsheet which can be user for parameterizing a test case
* DataTable are of two types:
1. Global Data Table ± Data table for Test flow
2. Local data table ± Data table for every action

* Data table value can be accessed using the below method


a) DataTable("",dtGlobalSheet)
b) DataTable("",dtLocalSheet)
c)DataTable("","")
) . à
* Any changes made to Data table during run-time is stored in run-time data table.
* Run-time data table is available in the test results summary of a test
* DataTable values can be changed at run-time by using below mentioned code:

DataTable(´OrderConf³, dtGlobalSheet) = ´ABCD1234³

)  

* Scripts written in VBScript language can be add as a Resource to the test
* All code written in the script is available across all Actions
* A VBScript can also be loaded in an Action by using OxecuteFile function. Ox ±
OxecuteFile ´C:\Init.vbs³
* In case of multiple files QTP combines all the files into a single one and executes the
code. The files are combine in bottom to top order
O 0 
* Onvironment variables are global variables available to all Actions
* They can be used to run a test case on different environment
* To add a new Onvironment variable go to Test -> Settings«->Onvironment (Tab)
* Onvironment variables are of two types

, .
-,' .à  

* Built in environment variables give information about the system and the current test
* User-defined Onvironment variables added in the Onvironment tab of Test Settings are
Read-only during the test run
* Onvironment variables can be added during runtime also using code
Onvironment.Value(´OrderNumber³) = ´ABCDOF³
* Onvironment variables can be loaded at run-time from a ML file using the below code
Onvironment.LoadFromFile "C:\TestOnvironment.xml"
* The Onvironment ML file has to be in below format:

APP_URL
http://test1.appserver.com
#  
* Parameters provide another way of parameterizing the test cases
* There are two types of parameters:
1. Test parameters
2. Action parameters

* Test parameters can be set in Test->Settings«->Parameters (Tab)


* Test parameters value can be provided when replaying the test
* Test arguments can be accessed in the test using TestArgs(´³)

m
#  
* Used to pass parameters to Action
* Output parameters can only be used when Action is being called for a single iteration
* Ox ± RunAction "Login", oneIteration, "TestUser", "TestPass", out
* A parameter can be accessed using
Parameter("ParamName")
V

* Checkpoints are verification points in a test
* Test without checkpoint would never have a pass status
* Checkpoints can be of types
± Built-in checkpoints
± Custom checkpoints
* Types of Built-in checkpoints available are

1. Standard checkpoints: Verify properties of an object


2. Text checkpoints: Verify text presence between two strings
3. Text Area checkpoint
4. Bitmap checkpoint
5. Accessibility checkpoint
À. Database checkpoint
7. ML Checkpoint

* Only Database and ML checkpoints can be inserted in idle mode.


* Rest all checkpoints can only be added during Recording or through Active screens.
* Checkpoint code

Browser("Google").Page("Google").WebOdit("q").Check CheckPoint("Verify
TextBox_Standard")
V V

* Custom checkpoints can be created using Code

loginOxist = Browser().Page().Link(´text:=Login³).Oxist(0)
If loginOxist then
Reporter.ReportOvent micPass, ´Check Login³, ´Login link exists³
Olse
Reporter.ReportOvent micFail, ´Check Login³, ´Login link does not exists³
Ond if

* Custom checkpoint can be made flexible based on implementation and are


preferred over Built-in checkpoints

)  
Test results provide a execution summary of the complete test case
* There are different types of status in test results summary:
1. Passed
2. Failed
3. Done
4. Warning
5. Information
à 
 #
* Alternate way of writing test cases without having objects in object repository
* Descriptive programming can be done in two ways

1. Using object description


2. Using string description

* In DP objects are identified by describing all the identification properties


* String description DP
Browser(´title:=Google³).Page(´title:=Google³).WebButton(´name:=Search³).Click
* Object Based DP
Set btnSearch = Description.Create : btnSearch(´name³).Value = ´Search³
Set brwGoogle = Description.Create : brwGoogle(´title³).value = ´Google³
Set pgGoogle = Description.Create : pgGoogle(´title³).value = ´Google³
Browser(brwGoogle).Page(pgGoogle).WebButton(btnSearch).Click
Description objects can also be used to get all child objects matching a criterion. Ox ±

Set oDesc = Description.Create


oDesc(´name´).Value = ´txt_.*³
oDesc(´name´).RegularOxpression = True
Set allMatchingObjects = Browser().Page().ChildObjects(oDesc)
Msgbox allMatchingObjects.Count
Msgbox allMatchingObjects(0).GetROProperty(´name³)

* By default all property values are considered as regular expression patterns


* When using string description all regular expression must be used with escape character for
literal meaning. Ox - «Link(´text:=Logout \(Piyush\)³).Click

* DP based Object repository can be created in any file


* Code can be copied from one script to another without copying the object repository
* Custom implementation of object is easier. Ox ±

objStrDesc = ´Browser(´³title:=Test³³).Page(´³title:=Test³³).Link(´³text:=Login³³)³
Oxecute ´Set obj = ´ & objStrDesc
obj.Click
#

* QTP and the AUT has to be on the same machine
* QTP can be controlled remotely from another machine
* QTP scripts cannot be run without QTP
c
%
c
% c )

!
!       

Use the à  ,0 method to access data from the data table and input it into the
application

For data in the Global datasheet


1. Open a new script.
2. In column A of the Global datasheet, enter the data in three rows.
3. Go to www.google.com.
4. Begin recording.
5. Type a value into the Google search field.
À. Stop recording.
7. Go to the Oxpert view. Modify the script so it look like this:

rc = DataTable.Value ("A", dtGlobalSheet)


msgbox rc
Browser("Google").Page("Google").WebOdit("q").Set rc

8. To run all rows in the global data table, go to Test ->; Test Settings -> Run
tab, and select "Run on all rows."

For data in the Local datasheet:


1. Start a new script.
2. In column A of the Action1 datasheet, enter the data in three rows:
3. Go to www.google.com.
4. Begin recording.
5. Type a value into the Google search field.
À. Stop recording.
7. Go to the Oxpert view. Modify the script so it look like this:

rc = DataTable.Value ("A",dtLocalSheet)
msgbox rc
Browser("Google").Page("Google").WebOdit("q").Set rc

8. To run all rows:

Right-click on the Action name in the Tree View.

Go to Action Properites -> Run tab, and select "Run all rows."
/4!
!        


Create an Output Value. The text will be placed in the datatable and can be accessed as
needed.

1. Once you see the text you want to retrieve, start recording.
2. From the Insert menu, select Output Value, then Text Output Value.
3. Click on the desired text. The "Text Output Value Properties" window will appear.
4. In the window you can verify or set the Before and After text settings.
5. By default the retrieved value will be added to the Global sheet. ou can modify the
settings by selecting 6   in the combo box, then clicking Modify.
À. Once satisfied, click OK.
An Output statement will be entered into the script.

O  
Browser("Browser").Page("Page").Output CheckPoint("Text")
msgbox DataTable.Value("PageOutput_Text_out", dtGlobalSheet)

In addition, a column (in the example, PageOutput_Text_out) will be inserted into the
datatable(Remember in the runtime datatable), with the output text.

) Another method to retrieve data during run time is to do just the opposite of what we
did above in the first question above.

DataTable.Value(ParameterID [, SheetID])=NewValue
& 

The value property is the default property for the DataTable object. As the default
property you do not need to explicitly use .Value.

DataTable(ParameterID [, SheetID]) = NewValue

O  
' Add data to the current row of the Global sheet
DataTable("VarName", dtGlobalSheet) = "new value" ' Using DataTable by itself
DataTable.Value("VarName2", dtGlobalSheet) = "new value2" ' Using .Value

' Add data to the current row of the Local sheet


DataTable("VarName", dtLocalSheet) = "new value" ' Using DataTable by itself
DataTable.Value("VarName2", dtLocalSheet) = "new value2" ' Using .Value
c
%
c
% c (
ô
O  à 
In QTP, we have an option for Data Table which comes very useful when the user wants to
parameterize his/her test. The parameters set by user appear by default in the Columns of the
sheet. Not only is this helpful for parameterized operation of your test also when you want to
work with the Output function of QTP you can use this table since the corresponding outputs
can be viewed over here.

This option can be as per the user requirement and in this the user can make an Oxcel sheet
with the required parameters in it. Also one can import and export the contents to his test
while running it.

ôO  à5
The user shall perform the following operations:

In this once the user has created the Oxcel sheet and has recorded the test, (s)he shall right click
on any of the cells in the Data Table and select the File>Import, user will get a window where
(s)he will have to select the exact location of the excel sheet.
On Clicking the option, user will get a window pop-up box asking whether you will want to
replace the contents of the current data table with the ones in the excel sheet. Click OK and
proceed.

Select the exact location of the excel file on your PC which you want to import.

The contents of the excel sheet shall appear in the Data Table of QTP once you selected the
required excel sheet.

Remember to use the same naming convention through-out the script, you have used in the
file. Oach of the column name in your excel file will become one parameter.

Secondly the actions for which the user shall be setting parameters need to be given the same
name as in the imported excel file. As shown below, while recording the file the user has
selected a particular value for the Action which he wants to parameterize which will appear in
the constant option.
The user has to choose the Parameter option and then type the exact name as in the Data
table for e.g.: ³No_Pass´, here we are parameterizing the no of passengers for whom the
tickets have to be booked and will re-run the script for that much time.
Points to note regarding which location to select OR whether to make a sheet global or
local.

1. Globally implies the user has the Global sheet of the data table filled up with certain
data. Now when he runs the test it will operate for the amount of rows that are filled in
this sheet.

2. If you want a condition that for single row run of the global sheet there should be run of
another sheet namely the ³Action 1´ of the data table we call the operation as Local.

3. In this it is important that the user selects the Parameter option as local and not global
as in the above condition and the required contents will come in Action 1 sheet.

4. Now initially if while you are importing if there were two sheets created by you then by
default the contents of the second sheet will be Action 1. It is only that the corresponding
Action be parameterized properly.
Now, In the keyword view, Right click on the Action 1 and select Action Call Properties
and then in the Run Tab select the no of rows for which you want to run the Local sheet.

When the user runs this script, for every single row of the Global sheet, the Action 1
sheet will run for all of its respective columns.

A similar method can be used to import a single sheet or a database file.

m! 
/ 
  à ,ô16 67?
O O  à5

Like importing data sheet we can also export the entire data table into an external
excel file. This is basically useful if one wants to use the required parameters in
some different test run within QTP.

Similar to the exporting of complete file we can also export an single sheet from
the data table

m! 
/ 
  à ,O 16 67?
c*
!
+
 

 # ô  ! ! ,

,        


 #1 #7

1. Key word driven testing


2. Suitable for both client server and web based application
3. VB script as the script language
4. Better error handling mechanism
5. Oxcellent data driven testing features

-,!  
 
 /
  #

ou can instruct QTP to recover unexpected events or errors that occurred in your testing
environment during test run. Recovery scenario manager provides a wizard that guides you
through the defining recovery scenario. Recovery scenario has three steps
1. Triggered Ovents
2. Recovery steps
3. Post Recovery Test-Run
,        #

Output values enable to view the values that the application talks during run time. When
parameterized, the values change for each iteration. Thus by creating output values, we can
capture the values that the application takes for each run and output them to the data table.

8,!   


/ #9,: 

There are two ways to Spy the objects in QTP


1) Thru file toolbar: In the File ToolBar click on the last toolbar button (an icon showing a
person with hat).
2) Thru Object repository Dialog: In Object repository dialog click on the button ³object
spy«´ In the Object spy Dialog click on the button showing hand symbol. The pointer now
changes in to a hand symbol and we have to point out the object to spy the state of the
object. If at all the object is not visible or window is minimized then hold the Ctrl button
and activate the required window to and release the Ctrl button.

;,     


  
 /  #
File extension of
Per test object rep: filename.mtr
Shared Object rep: filename.tsr
Code file extension id: script.mts
À,O  


 /! #
 



) / displays a tree of all objects in the current component or in the current
action or entire test( depending on the object repository mode you selected).
we can view or modify the test object description of any test object in the repository or to
add new objects to the repository.
Quicktest learns the default property values and determines in which test object class it fits.
If it is not enough it adds assistive properties, one by one to the description until it has
compiled the unique description. If no assistive properties are available, then it adds a
special Ordinal identifier such as objects location on the page or in the source code.

<,    / !    /!  ! 
 
 

³name´ would be another property apart from ³title´ that we can use. OR
We can also use the property ³micClass´.
ex: Browser(´micClass:=browser´).page(´micClass:=page´)

9,    


  / 
   ! ! ! #

ou can write scripts using following languages:


Visual Basic (VB), ML, JavaScript, Java, HTML
+,  
/  O
0 m 
,

Common functions are:


Coloring the cell, Auto fit cell, setting navigation from link in one cell to other saving

:,O   /!


  
!  ,

Creates and returns a reference to an Automation object


syntax: CreateObject(servername.typename [, location])
Arguments
servername:Required. The name of the application providing the object.
typename : Required. The type or class of the object to create.
location : Optional. The name of the network server where the object is to be created.

,O     #m 


 ,

Ossentially all configuration and run functionality provided via the QuickTest interface is in
some way represented in the QuickTest automation object model via objects, methods, and
properties. Although a one-on-one comparison cannot always be made, most dialog boxes
in QuickTest have a corresponding automation object, most options in dialog boxes can be
set and/or retrieved using the corresponding object property, and most menu commands and
other operations have corresponding automation methods. ou can use the objects,
methods, and properties exposed by the QuickTest automation object model, along with
standard programming elements such as loops and conditional statements to design your
program.
-,! /

 #

QTP has a unique feature called Smart Object Identification/recognition. QTP generally
identifies an object by matching its test object and run time object properties. QTP may fail to
recognize the dynamic objects whose properties change during run time. Hence it has an
option of enabling Smart Identification, wherein it can identify the objects even if their
properties changes during run time.
V
 
If QuickTest is unable to find any object that matches the recorded object description, or if it
finds more than one object that fits the description, then QuickTest ignores the recorded
description, and uses the Smart Identification mechanism to try to identify the object.
While the Smart Identification mechanism is more complex, it is more flexible, and thus, if
configured logically, a Smart Identification definition can probably help QuickTest identify an
object, if it is present, even when the recorded description fails.

 ô 

  !/   
Base filter properties - The most fundamental properties of a particular test object class; those
whose values cannot be changed without changing the essence of the original object. For
example, if a Web link¶s tag was changed from to any other value, you could no longer call it
the same object. Optional filter properties - Other properties that can help identify objects of a
particular class as they are unlikely to change on a regular basis, but which can be ignored if
they are no longer applicable.
,) .  à    
ô ! 

In QTP, there is data table used, which is used at runtime.


-In QTP, select the option View->Data table.
-This is basically an excel file, which is stored in the folder of the test created, its name is
Default.xls by default.

8,! #  à.à   


  #

To data driven we have to parameterize. i.e. we have to make the constant value as
parameter, so that in each interaction(cycle) it takes a value that is supplied in run-time data
table. Through parameterization only we can drive a transaction (action) with different sets
of data. ou know running the script with the same set of data several times is not suggested,
and it¶s also of no use.

;,   
 ! Vm
V/m
,

Call to Action: The changes made in Call to Action, will be reflected in the original action
(from where the script is called). But where as in Copy Action , the changes made in the
script ,will not effect the original script(Action)
À,O  

! #  
,

During recording qtp looks at the object and stores it as test object. For each test object QT
learns a set of default properties called mandatory properties, and look at the rest of the
objects to check whether this properties are enough to uniquely identify the object. During
test run, QTP searches for the run time objects that matches with the test object it learned
while recording.

<,à    !


) / /  #,

Object repository is used to store all the objects in the application being tested.
Types of object repository: Per action and shared repository.
In shared repository only one centralized repository for all the tests. where as in per action
for each test a separate per action repository is created.

9,   
  



) /

Per Action: For Oach Action, one Object Repository is created.


Shared: One Object Repository is used by entire application
+,O !   
 !  ) /# m
) /

Shared Repository: Ontire application uses one Object Repository , that similar to Global
GUI Map file in WinRunner
Per Action: For each Action, one Object Repository is created, like GUI map file per test in
WinRunner

-:, /   ! 


   ô/       

/ ! ,

Sample answer (ou can tell about modules you worked on. If your answer is es then ou
should expect more questions and should be able to explain those modules in later
questions): I Used the functions for Capturing the dynamic data during runtime. Function
used for Capturing Desktop, browser and pages.

-,V/   


  /


Sample answer (Say es only if you worked on): I have done Dynamically capturing the
objects during runtime in which no recording, no playback and no use of repository is done
AT ALL.
-It was done by the windows scripting using the DOM(Document Object Model) of the
windows.
--,! 
,m   /  
 # 
  
 !  ! 
 

es, there¶s an in-built functionality called ³Step Generator´ in Insert->Step->Step Generator


-F7, which will generate the scripts as you enter the appropriate steps.

-,   
 ! 

   

An output value is a value captured during the test run and entered in the run-time but to a
specified location.
O :-Location in Data Table[Global sheet / local sheet]

-8,!// m
    #

There are three kinds of actions:


Non-reusable action - An action that can be called only in the test with which it is stored, and
can be called only once.
Reusable action - An action that can be called multiple times by the test with which it is stored
(the local test) as well as by other tests.
Oxternal action - A reusable action stored with another test. Oxternal actions are read-only in
the calling test, but you can choose to use a local, editable copy of the Data Table information
for the external action.
-;,ô! & !!! 
 ô!  
/  /) 
! ,!ô

ou can still make the notepad open without using the record or System utility script, just by
mentioning the path of the notepad ³( i.e. where the notepad.exe is stored in the system) in the
³Windows Applications Tab´ of the ³Record and Run Settings window.
   c

=!  m


 ! 

We can do this with the following code

Set objIO = CreateObject("InternetOxplorer.Application")


objIO.visible = True
objIO.Navigate environment("URL_ONV")

Here the URL specified in the Onviroment file will be navigated. But if we want to directly
place the URL in the above mentioned code, replace the third line with the below mentioned
line:

ôO,& 6!!!, ,
6
-=!

     à  

Use the following code:

On Orror Resume Next


val=DataTable("ParamName",dtGlobalSheet)
if Orr.number<> 0 then
'Parameter does not exist
else
'Parameter exists
end if

If no error is there, then Orr.number = 0

=! !/

 
chk_PassFail = Browser(...).Page(...).WebOdit(...).Check (Checkpoint("Check1"))
if chk_PassFail then
MsgBox "Check Point passed"
else MsgBox "Check Point failed"
end if

"if chk_PassFail" means if chk_PassFail="True". In the above mentioned code, a


boolean value is returned to the variable chk_PassFail.
4# How can I generate a random number?

The below mentioned code generates a randomnumber in the range of 100-999


:RandomNumber (100,999)

;=/  



4!
ô    /


! 
/ 
 

  

Reporter.Filter = rfDisableAll 'Disables all the reporting events like Pass or even Fail
chk_PassFail = Browser(...).Page(...).WebOdit(...).Check (Checkpoint("Check1"))
Reporter.Filter = rfOnableAll 'Onable all the reporting events like Pass or even Fail
if chk_PassFail then
MsgBox "Check Point passed"
else
MsgBox "Check Point failed"
end if

À=   
 ! m
 

Action is a thing specific to QTP while functions are a generic thing which is a feature of
VB Scripting. Action can have a object repository associated with it while a function
can't. A function is just lines of code with some/none parameters and a single return value
while an action can have more than one output parameters.
<=     


Well answer depends on the scenario. If you want to use the OR feature then you have to
go for Action only. If the functionality is not about any automation script i.e. a function
like getting a string between to specific characters, now this is something not specific to
QTP and can be done on pure VB Script, so this should be done in a function and not an
action. Code specific to QTP can also be put into an function using DP. Decision of using
function/action depends on what any one would be comfortable using in a given situation.

9=   )


 /
!  O)   & 
Recovery scenarios are used when you cannot predict at what step the error can occur or
when you know that error won't occur in your QTP script but could occur in the world
outside QTP, again the example would be "out of paper", as this error is caused by printer
device driver. "On error resume next" should be used when you know if an error is
expected and dont want to raise it, you may want to have different actions depending upon
the error that occurred. Use err.number & err.description to get more details about the
error.
+=!     
A simple definition could be... it is a variable which can be used across the reusable actions
and is not limited to one reusable action. We can use Onvironment variables like a global
variables.
There are two types of environment variables:

1. User-defined
2. Built-in
We can retrieve the value of any environment variable. But we can set the value of only 

 
environment variables.

To set the value of a user-defined environment variable:


Onvironment (VariableName) = NewValue

To retrieve the value of a loaded environment variable:


CurrValue = Onvironment (VariableName)

O 
The following example creates a new internal user-defined variable named MyVariable with a
value of 10, and then retrieves the variable value and stores it in the MyValue variable.

Onvironment.Value("/0 ")=10
MyValue=Onvironment.Value("/0 ")
:=! ô  /

  #+,:
Oxample:
Browser("Google").Page("Google").WebOdit("Search").Check CheckPoint("Search")
In the above example, the user would like to change the name of the CheckPoint object
from "Search" to something which is of our convinience
Note:

 
/ ! 
# +,:,   #
9,- !,

1. Right-click on the Checkpoint step in the Keyword View or on the Checkpoint object in
Oxpert View.
2. Select "Checkpoint Properties" from the pop-up menu.
3. In the Name field, enter the new checkpoint name.
4. Click . The name of the checkpoint object will be updated within the script.
Oxample:
Browser("Google").Page("Google").WebOdit("Search").Check CheckPoint("Search")
& 
ou must use the QuickTest Professional user interface to change the name of the
checkpoint. If you manually change the name of the checkpoint in the script, QuickTest
Professional will generate an error during replay. The error message will be similar to the
following:

"The "" CheckPoint object was not found in the Object Repository. Check the Object
Repository to confirm that the object exists or to find the correct name for the object."

The CheckPoint object is not a visible object within the object repository, so if you
manually modify the name, you may need to recreate the checkpoint to resolve the error.
=à  
#  ô  O  <,:

# +,
QuickTest Professional 9.1 supports Microsoft Internet Oxplorer 7.0 Beta 3. Internet Oxplorer
version 7.0 is now certified to work and to be tested with QuickTest Professional version 9.1.

# +,:
QuickTest Professional 9.0 supports Internet Oxplorer 7.0 Beta 2.

# 9,- !
QuickTest Professional 8.2 and below do not include support for Internet Oxplorer 7.0.

à  
#  5  

# +,+,-
QuickTest Professional 9.1 provides replay support for Mozilla Firefox 1.5 and Mozilla
Firefox 2.0 Alpha 3 (Alpha-level support for Bon Ocho 2.0a3).
Notes:

QuickTest Professional 9.1 will not record on FireFox. ou can record a test on Microsoft
Internet Oxplorer and run it on any other supported browser, such as FireFox.

The .Object property for web objects is not supported in FireFox.



# +,:
QuickTest Professional 9.0 provides replay support for Mozilla FireFox 1.5.
Notes:

QuickTest Professional 9.0 will not record on FireFox. ou can record a test on Microsoft
Internet Oxplorer and run it on any other supported browser, such as FireFox.

The .Object property for web objects is not supported in FireFox.


# 9,- !

QuickTest Professional 8.2 and below do not have support for Firefox.
-=!

! 
  

Here we have a dropdown list named Items which contains 3 items :Item1, Item2 and Item3. We
want to check if Item3 is there in the dropdown or not.

str_ItemType=Browser("..").Page("..").WebList("lst_itemType").
GetROProperty("all items") str_ItemType1=Instr(str_ItemType,"Item4")

If str_ItemType1=0 Then

Reporter.ReportOvent 0,"Item Type","Verify that Items dropdown list does not contains Item4"

Olse

Reporter.ReportOvent 1,"Item Type","Verify that Items dropdown list does not contains Item4"
=  
  #

  
 
 
 
    

The lservrc file contains the license codes that have been installed. Whenever a new
license is created, the license code is automatically added to this file. The lservrc file is a
text file, with no extension.

5 $


1) For a Concurrent (Floating) license installation:

"#server installation directory#\#language#"

Oxample:
C:\Program Files\  Technologies\ABC Server\Onglish\lservrc

2) For a Seat (Stand-alone) license installation:

#AQT/QTP installation directory#\bin"

Oxample:
C:\Program Files\Mercury Interactive\QuickTest Professional\Bin\lservrc
14# What to do if you are not able to run QTP from quality center?
This is for especially for newbies with QTP.
Check that you have selected Allow other mercury products to run tests and
components from Tools--> Options--> Run Tab.

15# Does QuickTest Professional support Macintosh operating systems?


No, QTP is not expected to run on this OS.

You might also like