Professional Documents
Culture Documents
com
1.Activate: Activates the current Dialog Box.
Syntax: object.Activate [BUTTON]
Example:
Sub Activate_Example()
‘The following example uses the Activate method to activate the
‘Internet Options dialog box.
Browser(”Mercury Tours”).Dialog(”Internet Options”).Activate
End Sub2. CaptureBitmap: Saves the screen capture of the object as a .png or .bmp image using the
specified file name.
Syntax: object.CaptureBitmap FullFileName, [OverrideExisting]
Example:
Sub CaptureBitmap_Example1()
‘The following example uses the CaptureBitmap method to capture a
’screen shot of the Internet Options dialog box. The file is
‘automatically saved to a different folder (the test run results
‘folder) in each run.
Browser(”Mercury Tours”).Dialog(”Internet Options”).CaptureBitmap “internet_options.bmp”
End Sub
3. ChildObjects: Returns the collection of child objects contained within the object.
Syntax: object.ChildObjects (pDescription)
Example:
‘The following example uses the ChildObjects method to retrieve a
’set of child objects matching the description listed in the function
‘call and uses the method to display a message indicating how many
‘objects are found with the specified description: none, one (unique),
‘or several (not unique).
Public Function CheckObjectDesription(parent, descr)
Dim oDesc
‘ Create description object
Set oDesc = Description.Create()
arProps = Split(descr, “,”)
For i = 0 To UBound(arProps)
arProp = Split(arProps(i), “:=”)
If UBound(arProp) = 1 Then
PropName = Trim(arProp(0))
PropValue = arProp(1)
oDesc(PropName).Value = PropValue
End If
Next
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
‘ Get all child objects with the given description
Set children = parent.ChildObjects(oDesc)
If children.Count = 1 Then
CheckObjectDesription = “Object Unique”
ElseIf children.Count = 0 Then
CheckObjectDesription = “Object Not Found”
Else
CheckObjectDesription = “Object Not Unique”
End If
End Function
End Sub
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
‘The following example uses the Drag and Drop methods to drag the object from
‘coordinates 10, 20 within the Test window and drop the object at
‘coordinates 30, 40 within the same window.
Window(”Test”).Drag 10, 20
Window(”Test”).Drop 30, 40
End Sub
10. GetRoProperty: Returns the current value of the test object property from the object in the
application.
Syntax: object.GetROProperty (Property, [PropData])
Example:
Sub GetROProperty_Example()
‘The following example uses the GetROProperty method to retrieve the
‘x coordinate of the Test window.
x = Window(”Test”).GetROProperty(”x”)
y = Window(”Test”).GetROProperty(”y”)
End Sub
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
11. GetTextLocation: Checks whether the specified text string is contained in the specified window area.
Syntax: object.GetTextLocation (TextToFind, Left, Top, Right, Bottom, [MatchWholeWordOnly])
Example:
Sub GetTextLocation_Example()
‘The following example uses the GetTextLocation method to retrieve
‘all of the text within the object.
l = -1
t = -1
r = -1
b = -1
result = Dialog(”Dialog”).WinObject(”Date”).GetTextLocation(”2002″, l, t, r, b)
If result Then
MsgBox “Text found. Coordinates:” & l & “,” & t & “,” & r & “,” & b
End If
End Sub
12. GetToProperties: Returns the collection of properties and values used to identify the object.
Syntax: object.GetTOProperties
Example:
Sub GetTOProperties_Example1()
‘The following example uses the GetTOProperties method to retrieve the
‘list of properties and values used to identify the Internet Options
‘dialog box.
IEOptsDialog = Browser(”Mercury Tours”).Dialog(”Internet Options”).GetTOProperties()
End Sub
13. GetToProperty: Returns the value of a specified property from the test object description.
Syntax: object.GetTOProperty (Property)
Example:
Sub GetTOProperty_Example()
‘The following example uses the GetTOProperty method to retrieve the
‘RegExpWndClass property from the Object Repository.
Dim ObjectName
RegExpWndClass = Window(”Test”).GetTOProperty(”RegExpWndClass”)
End Sub
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
’sub-string, the Type method is used to type the guest string in the
‘window.
TelnetText = Window(”Telnet”).GetVisibleText
If InStr(1, TelnetText, “login:”, 1) > 0 Then
Window(”Telnet”).Type “guest”
End If
End Sub
15. MouseMove: Moves the mouse pointer to the designated position inside the activeXobject.
Syntax: object.MouseMove X, Y
Example:
Sub MouseMove_Example()
‘The following example uses the MouseMove method to move the mouse
‘pointer to the position (20, 30) inside the Advanced object.
Browser(”MyPage”).Dialog(”Settings”).WinObject(”Advanced”).MouseMove 20, 30
End Sub
16. Move: Moves the dialog box to the specified absolute location on the screen.
Syntax: object.Move X, Y
Example:
Sub Move_Example()
‘The following example uses the Move method to move the Internet
‘Options dialog box to the specified location.
Browser(”Mercury Tours”).Dialog(”Internet Options”).Move 659, 35
End Sub
17. Maximize: Maximize the dialog box to fill the entire screen.
Syntax: object.Maximize
Example:
Sub Maximize_Example()
‘The following example uses the Maximize method to maximize the
‘Internet Options dialog box.
Browser(”Mercury Tours”).Dialog(”Internet Options”).Maximize
End Sub
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
19. Resize: Resize the dialog box to the specified dimensions.
Syntax: object.Resize Width, Height
Example:
Sub Resize_Example()
‘The following example uses the Resize method to resize the Internet
‘Options dialog box.
Browser(”Mercury Tours”).Dialog(”Internet Options”).Resize 296, 348
End Sub
21. SetToProperty: Sets the value of the specified property in its test object description.
Syntax: object.SetTOProperty Property, Val
Example:
Sub SetTOProperty_Example()
23. WaitProperty: Waits until the specified object property achieves the specified value or exceeds the specified
timeout before continuing to the next step.
Syntax: object.WaitProperty (PropertyName, PropertyValue, [lTimeOut])
Example:
Sub WaitProperty_Example()
‘The following example uses the WaitProperty method to make the
‘program wait for the “Test” window to become active or for 3 seconds
‘(3 milliseconds) to pass, whichever comes first.
y = Window(”Test”).WaitProperty(”focused”, True, 3000)
End Sub
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
24. Output: Retrieves the current value of an item and stores it in a specified location.
Syntax: object.Output pVerify
Example:
Sub Output_Example()
‘The following example uses the Output method to output text into the
‘”You can change” Data Table column.
Browser(”index”).Dialog(”Internet Options”).Static(”You can change”).Output CheckPoint(”You can change”)
End Sub
1. GetContent: Returns a string containing the names of all of the items in the combo box.
Syntax: object.GetContent
Example:
Sub GetContent_Example ()
We can view the Properties and Methods of any object in an open application with the help of Object Spy pointing hand
mechanism. As we move the pointing hand over the objects in the application, िर details get displayed in the Object
Spy.
These details displayed in the Object Spy are the hierarchy tree of the test object, its properties and values, and the
methods associated with the object. For methods, the syntax is also displayed.
Step-1: Open the application to the page containing the object on which we want to spy say google.com.
Step-2: Choose Tools > Object Spy or click the Object Spy toolbar button to open the Object Spy dialog box and display
Or click the Object Spy button from the Object Repository dialog box.
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
To view the object’s available methods and syntax, click the Methods tab. Properties tab is displayed by
Step-4: In the Object Spy dialog box, click the pointing hand which is displayed on top. QuickTest
remains hidden. As
we move the pointing hand over the test objects in our application, the test objects get highlighted, and
we can view their test object properties or methods in the Object Spy dialog box. We can also view their
parent objects in the object hierarchy tree area of the Object Spy dialog box.
Step-5: Highlight or click the object whose properties or methods we want to view। The Object Spy
displays the object
hierarchy tree and the properties or methods of the object that is selected within the tree.
Step-6: Click the object whose associated methods we want to view. The Object Spy displays the object
hierarchy tree
Step-7: To view the properties or methods of the test object, click the Test Object Properties radio
button. To view the
properties or methods of the run-time object, click the Run-time Object Properties radio button.
Step-8: If we want to view properties, values, or methods for another object within the displayed tree,
highlight or
click the object in the tree and select the relevant options, as described in step 3 above.
Step-9: If we want to copy an object property or value, or a method’s syntax to the Clipboard, click the
property, value,
or method to highlight it. The value gets displayed in the selected property / value or method syntax box
which is
located above the Description box. Highlight the text in the box and use CTRL + C to copy the text to the
Clipboard or
right-click the highlighted text and choose Copy from the menu.
Checkpoints cannot be added manually, they are inserted using QTP's interface. Results of the
checkpoint can be
Checkpoint information is stored in the Local Object Repository. It is in the Resource.mtr file which is in
the action
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
folder (if you created checkpoint in action1 then it will be action 1 folder under the folder in which you
are saving the
test/script, if you created checkpoint in action 2 then it will be action 2 folder and so on) .
In the expert view, on any blank line type Checkpoint and put "(". As soon as you put the starting bracket
it will show
combo boxes etc. Standard checkpoints are supported for all add-in environments
(Now only QTP with blank test and Flight application should be open).
3. Click on Record. When we click on Record, "Record and Run Settings" window opens up. Go to
"Windows
Applications" tab and choose first option "Record and run test on any open Windows based application."
and
click ok.
4. Go to Insert (menu)->Checkpoint->Standard Checkpoint (or press F12).The mouse pointer will become
hand
5. Click on the "Flights..." button which is on the Right Hand Side of the "Fly To" combo box in the Flight
application.
6. It will open "Object Selection - Checkpoint Properties" window (with WinButton:FLIGHT highlighted).
Click
ok.
7. It will open checkpoint properties window. (only one property will be checked in it i.e. 'enabled' with
a value
of False.)
8. Click ok. Click on Stop in order to stop the Recording.
9. Save the test.
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
This is a small test in which we have used standard checkpoint and captured the disabled button on the
Flight
application. Now we can run the test in two ways to see how it fails and passes the results of the
checkpoint.
Make sure that this test and Flight application is open. Click on run.
It will Run the test and show you the result as pass.
In the Flight application enter the Date of Flight, Fly From and Fly To fields and nothing else. (The reason
for doing
which it recorded the information at the record time, but now since the button was enabled at run time,
so it failed.
This will help you in understanding the standard checkpoint in QTP more deeply.
Labels: Automated testing,Checkpoint,QTP
and choose first option "Record and run test on any open browser." and click ok.
4. Go to Insert (menu)->Checkpoint->Standard Checkpoint (or press F12).
5. The mouse pointer will become hand and QTP will be minimized.
6. Click anywhere on the white space on the Google.co.in page.
7. It will Open "Object Selection - Checkpoint Properties" window. Click on 'Page : Google' option which has a
page icon on left of it with right corner of the page slightly folded.
8. Click ok.
9. A 'Page Checkpoint Properties' window opens up. Let all the options be default. Click ok.
10. Click on Stop in order to stop the Recording.
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
Browser("Google").Page("Google").Check CheckPoint("Google")
I ran this test by opening www.google.co.in in offline mode (not on internet). It recorded the following properties:
Property Name
Property Value
load time
"0"
number of images
"2"
number of links
"20"
Here it shows the load time as 0 because I did not open Google at the time of running the test, it was already open.
When you run it, in the results window, on left hand side, it will show (when every option is expanded):
Test Checkpoint-page Summary (where Checkpoint-page is the name with which I saved the test
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
alertBox 48 -> “!” icon… if you use 64 u will see X icon instead BTW… since u need the message to be
displayed
Usage:
If we change any thing in the Data Table at Run-Time the data is changed only in the run-time data table.
The run-time
data table is accessible onlythrough then test result. The run-time data table can also be exported using
DataTable.Export or DataTable.ExportSheet
Well QTP does not allow anything for saving the run time changes to the actual data sheet. The only
work
around is to share thespreadsheet and then access it using the Excel COM Api’s.
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
How can i make some rows colored in the data table?
Well you can’t do it normally but you can use Excel COM API’s do the same. Below code will explain
some
code:
SMART IdentificationSmart Identification is nothing but an algorithm used by QTP when it is not able to
recognize
one of the object. A very generic example as per the QTP manual would be, A photograph of a 8 year old
girl and boy
and QTP records identification properties of that girl when she was 8, now when both are 10 years old
then QTP
would not be able to recognize the girl. But there is something that is still the same, that is there is only
one girl in the
photograph. So it kind of PI (Programmed intelligence) not AI.
Something that people don’t think about too much. But the thing is that you should disable SI while
creating your test
cases. So that youare able to recognize the objects that are dynamic or inconsistent in their properties.
When the script
has been created, the SI should be enabled,so that the script does not fail in case of small changes. But
the developer of
the script should always check for the test results to verify if the SIfeature was used to identify a object
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
or not.
Sometimes SI needs to be disabled for particular objects in the OR, this is advisable when you use
SetTOProperty to change any of the TO properties of an object and especially ordinal identifiers like
index, location
and creationtime.
Descriptive Programming
Descriptive programming is nothing but a technique using which operations can be performed on the
AUT
Recovery scenario gives you an option to take some action for recovering from a fatal error in the test.
The error could range in fromoccasional to typical errors. Occasional error would be like “Out of paper”
popup error while printing something and typical errors would be like”object is disabled” or “object not
found”. A test case have more then one scenario associated with it and also have the priority or order in
which itshould be checked.
Trigger: Trigger is nothing but the cause for initiating the recovery scenario. It could be any popup
window,
Action: Action defines what needs to be done if scenario has been triggered. It can consist of a
mouse/keyboard event, close application, call arecovery function defined in library file or restart
windows.
You can have a series of all the specified actions.
Post-recovery operation: Basically defined what need to be done after the recovery action has been
taken. It
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
could be to repeat the step, moveto next step etc….
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 yourQTP 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. “Onerror 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
actionsdepending
upon the error that occurred. Use err.number & err.description to get more details about the error.
Library files are files containing normal VBScript code. The file can contain function, sub procedure,
classes etc…. You can also use executefilefunction to include a file at run-time also. To associate a library
file with your script go to Test->Settings… and add your library file to resourcestab.
When to associate a library file with a test and when to use execute file?
When we associate a library file with the test, then all the functions within that library are available to all
the
actions present in the test. Butwhen we use Executefile function to load a library file, then the function
are
available in the action that called executefile. By associated a library toa test we share variables across
action
(global variables basically), using association also makes it possible to execute code as soon as the
scriptruns
because while loading the script on startup QTP executes all the code on the global scope. We can use
executefile in a library file associated
with the test to load dynamic files and they will be available to all the actions in the test.
What is the difference between Test Objects and Run Time Objects ?
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
•
Test objects are basic and generic objects that QTP recognize. Run time object means the actual object
to which
Yes. You can use SetTOProperty to change the test object properties. It is recommended that you switch
off the
No (but Yes also). You can use GetROProperty(”outerText”) to get the outerText of a object but there is
no
function like SetROProperty tochange this property. But you can use
WebElement().object.outerText=”Something” to change the property.
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 repositoryassociated 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 canhave 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 anyautomation 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 onpure 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.
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
Decision
ofusing function/action depends on what any one would be comfortable using in a given situation.
What is checkpoint?
Checkpoint is basically a point in the test which validates for truthfulness of a specific things in the AUT.
There are different types ofcheckpoints depending on the type of data that needs to be tested in the
AUT. It
can be text, image/bitmap, attributes, XML etc….
Environment
How can i import environment from a file on disk
•
Environment.LoadFromFile “C:\Env.xml”
How can i check if a environment variable exist or not?
•
When we use Environment(”Param1″).value then QTP expects the environment variable to be already defined.
But when we useEnvironment.value(”Param1″) then QTP will create a new internal environment variable if it
does not exists already. So to be sure that variable existin the environment try using
Environment(”Param1″).value.
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
Field1 = ObjRecordset(”Field1″).Value
Field2 =
bjRecordset(”Field2″).Value End if
How to do the backward compatability in QTP
How to run the scripts in 8.2
those are recorded in 9.0 or higher
Sol:
Step 1: Delete the object repository of 9.0
Step 2: open a Blank test in 8.2
Step 3: Create the shared object repository in 8.2 that should contain all the objects in 9.0 and save.
Step 4: create the action structure in 8.2 should contain the same num of actions, same names and
structure as the
script of 9.0.
Step 5: save the test. (From now we call this as 8.2 scripts)
Step 6: from 8.2 script copy Test.tsp file to the 9.0 script.
Step 7: copy all Resource.MTR file found in Action0, Action 1, etc to 9.0 scripts
Step 8: now u can run the scripts with little modifications if require
1 INTRODUCTION
Mercury Quick Test Professional 8.0 provides the industry’s best solution for functional test and
regression test
automation - addressing every major software application and environment. This next-generation
automated
testing solution deploys the concept of Keyword-driven testing to radically simplify test creation and
maintenance. Unique to Quick Test Professional’s Keyword-driven approach, test automation experts
have full
access to the underlying test and object properties, via an integrated scripting and debugging
environment that is
round-trip synchronized with the Keyword View.
Quick Test Professional 8.0 satisfies the needs of both technical and non-technical users. It enables you
to deploy
higher-quality applications faster, cheaper, and with less risk. It empowers the entire testing team to
create
sophisticated test suites with minimal training.
Advantages:
• Empower the entire team to create sophisticated test suites with minimal training
• Ensure correct functionality across all environments, data sets, and business processes
• Fully document and replicate defects for developers, enabling them to fix defects faster and meet
production
deadlines
• Easily regression-test ever-changing applications and environments
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
• Become a key player in enabling the organization to deliver quality products and services, and improve
revenues and profitability
FEATURE USE
Keyword View Lets you easily build and maintain tests without writing VBScripts
Auto-Documentation Provides improved test clarity and the ability to view test steps in plain English
Step Generator Allows you to quickly insert custom-built functions into your tests
Enhanced Expert View Provides greater efficiency when generalizing test components
Action Parameters Allows you to generalize testing actions for greater reusability
Custom Reports Enables you to create custom reports for your unique needs
Unicode Support Lets you test global deployments of your enterprise applications
QuickTest records the operations we perform, displays them as steps in the Keyword View, and
generates scripts
in the expert view. Each test in Quick test includes a single action. Multiple actions can be included when
needed.
• Before recording a test see to that all other browsers are closed. Choose how to open the application.
This can be
done as follows:
Go to Test->Record & Run Settings->web.
If the page is already open select the ‘Record and run on any open web browser’ option. If you want to
open the
page automatically select the ‘Open the following browser when record and run session begins’ option and set the
Url of the page you want to record.
• Click the Record button or choose Test > Record.
• Navigate through the application or Web site. QuickTest records each step performed and displays it in the
Keyword View and Expert View.
• When you complete your recording, click the Stop button or choose Test > Stop.
• Click the Save button to save the test.
Example:
While recording the home page of Google the following code is
generated.
Browser("Google").Page("Google").WebEdit("Search").Set "QTP "
Browser("Google ").Page("Google").WebEdit("Search").Submit
Browser("Google").Page("GoogleSearch: QTP").Link("QTP").Click
Browser("Google ").Page("QTP").Sync
RECORDING MODES
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
When you run a test, QuickTest performs the steps you recorded on the application.
• The Run option can be used to run the test from start to end.
• The Run from Step option in the Test menu is used to run the test from a selected step to the end of the current
action, if running from the Expert View, or to the end of the test , if running from the Keyword View. Thus it
enables us to check a specific part of the application or to confirm that a certain part of the test runs correctly.
• The Update Run option in the Test menu is used to update the Active screens, Checkpoints and the test object
descriptions. While recording, Quick Test saves the snapshots of the application as Active screens which can be used later
to set Checkpoints and output values.
• The Pause option in the Debug menu is used to temporarily suspend the run. To resume running a paused test,
click the Run button.
• The StepInto(F11) option in the Debug menu is used to run the current line of the test.
• The Insert\Remove Breakpoint(F9) option in the Debug menu is used to stop a test run at a pre-determined
place in a test. A breakpoint is indicated by a red-colored hand in the left margin of the test window. The test run
is paused when it reaches the breakpoint, before executing the step. You can examine the effects of the test run up
to the breakpoint, make any necessary changes, and then continue running the test from the breakpoint.
• The DebugViewer option in the View menu is used to view, set, or modify the current value of objects or
variables in the test,when a test stops at a breakpoint.
After a test run, the results are displayed in the Test Results window.If the window is not already open choose
Test->Results.The Test result tree can be collapsed and expanded. Iterations, actions, and steps that contain
checkpoints are marked Passed or Failed in the bottom right part of the Test Results window and are identified by
the icon or in the tree pane.
To add details in the Test results window Reporter event is used. The following line of code can be used.
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
The first argument (0 or 1) represents the Event status.0 and 1 represent pass and fail respectively. The
second
argument indicates the step name and the third gives details about the executed test.
4.0 ACTIONS
A test is composed of actions or logical sections. The steps we add to the test are added within the test’s
actions. By
default, each test begins with a single action. Dividing a test into actions helps us to streamline the
testing process.
When we run a test with multiple actions, the Test Results are divided by actions so that we can view
the detailed
results for each action individually. Each action has its own sheet in the Data Table so that we can insert
data that
applies only to that action.
Actions Tool Bar contains buttons and a list of actions, enabling us to view the details of an individual
action or
the entire test flow. The test flow displays the overall flow of the test with all the actions in the test.
There are two buttons on the Actions Tool Bar, i.e. BACK and SHOW, as shown below.
Actions List Back Show
The Action Tool Bar will be visible, only when, we have one or more external/reusable actions in our
Action to
1) Click the step after which you want to insert the new action.
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
button. The Insert New Action dialog box opens. (In QTP 8.0, Insert Call to New Action)
3) Type a new action name or accept the default name.
4) Add a description of the action.
5) Select Reusable Action to make it reusable. This can be
6) To insert a new action at the end of the test, check the At the end of the test checkbox. To insert the
new action
within the action of the currently selected step, select After the current step.
7) Click OK.
b) When we insert a copy of an action into a test, the action is copied in its entirety, including
checkpoints,
parameterization, and the corresponding action tab in the Data Table. The action is inserted into the test
as an
independent, non-reusable action (even if the original action was reusable). Once the action is copied
into the test,
we can add to, delete from, or modify the action. Any changes we make to this action after inserting it
affect only
this action, and changes to the original action do not affect the inserted action. We can insert copies of
both
reusable and non-reusable actions.
Running an Action within an action is nesting. The following are the uses of nesting actions.
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
current step
as 6th step.
• ExitActionIteration - Exits the current iteration of the action. • ExitRun - Exits the test, regardless of its
iteration attributes. • ExitGlobalIteration - Exits the current global iteration.
maintained by QTP.
• Run Time Objects: Objects in the application that are created and maintained by the Browser.
Three object management tools are available to maintain both the test and runtime objects in the test.
are used to identify them. For example, from the figure below, the mandatory properties used to
identify an
ActiveX button object are caption and progid. Thus an ActiveX button is always identified using these
two
properties. In case these properties are not enough for identifying the object Quick Test uses the
assistive
properties to do the same. We can modify these properties using the Add\Remove button. Smart
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
Identification is
used to identify the object if the learned properties are not sufficient.
Set the object repository path from Test->Settings->Resource Tab. Select the repository file with the
extension .tsr.
If the repository file is not available create a file with extension .tsr. The repository path must be set
before starting
recording.
The Object Repository can be Per Action or Shared.
• The shared repository can be used by multiple actions of the same test or by actions from different
tests. Test
object properties are prone to frequent updation. While adding existing actions, we can copy an action
using the
same Object Repository and Call actions using the same Object Repository, or Object Repository per
action mode
• Per Action object repository is used by one or very few tests.Test object properties are modified less
frequently.While adding existing actions, if we are using different object repositories for different
actions (One
repository per action) then we can copy or call actions from tests using Object Repository per Action
mode.
5.3 Object Spy
It can be used to view the properties and values of an object in any open application. Click the pointing
hand to
select the object in the application. The object’s properties (Test object properties and Run-Time object
properties)
and methods can be identified. The object’s hierarchy tree is also displayed. To perform other events
such as
mouse clicks or window focus hold the CTRL key.
6.0 CHECKPOINTS
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
A checkpoint is a verification point that compares a current value for a specified property with the
expected value for that property. Thus it ensures proper functionality of the objects in the application.
When you add a checkpoint for an object a statement containing Check Checkpoint is added in the
Expert view. Checkpoints can be added in the following ways.
->Checkpoint option to select a type of checkpoint and select the object for which the checkpoint is to
be added.
• During Editing: Right click the object in the Active screen and select the type of checkpoint to be
added.
After selecting the object, add the property that is to be checked. For example, for a standard
checkpoint on a radio
button for the property ‘selected’ checks whether the radio button is selected or not. Checkpoints can
also be
placed in the Keyword view. Right click the object in the keyword view and insert the required
checkpoint.
Example:
Consider inserting a checkpoint for the Search textbox in the Home page of Google. The following code
is
generated.
Browser ("Google").Page ("Google").WebEdit ("Search").Check CheckPoint ("Search")
If you want to retrieve value from the checkpoint, use parenthesis around the checkpoint argument.
TYPES OF CHECKPOINT
2TYPES DESCRIPTION
Standard CheckPoint
It checks the property value of an object in your application or Web page. It checks a variety of objects
such as
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
It checks an area of the application as a bitmap.To create a bitmap checkpoint of multiple objects, select
the highest
level object that includes all the objects to include in the bitmap checkpoint.
Text CheckPoint
It checks whether the text string is displayed in the appropriate place in your application or on a Web
page
Text Area CheckPoint
It checks whether the text string is displayed within the defined area in the application. If the area
defined is
associated with more than one object, the Object Selection-Text Area Checkpoint Properties dialog box
opens.
Table CheckPoint
It checks the information within a table or the table itself. The row or column values can also be
checked.
Accessibility CheckPoint
It identifies areas of the Web site that do not conform to the World Wide Web Consortium (W3C) Web
Content
Accessibility Guidelines.
Page CheckPoint
It checks whether the page is displayed correctly and gives information like number of links, number of
images
and load time of the page
Database CheckPoint
Output Value is used to retrieve the current value of any object in the application and stores it in a
specified
• During Recording: In the Keyword View or Expert View, choose Insert -> Output Value and select the
type of
output value and the object for which the value is to be outputted.
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
• During Editing: Right click the object in the Active screen and select the type of output value to be
added.If the location clicked is associated with more than one object, then the Object Selection - Output
Value Properties dialog box opens. From here select the required object.
Example
Browser("Google").Page("Google").WebEdit("Search").Set "QTP"
Browser("Google").Page("Google").WebEdit("Search").Output CheckPoint("Search")
Browser("Google").Page("Google").WebEdit("Search").Submit
Browser("Google ").Page("Google Search: QTP").Link("QTP").Click
Browser("Google ").Page("QTP").Sync
8.0 PARAMETERIZATION
A parameter is a variable that is assigned a value from an external data source at run time. We use
parameterization when we want to change the value of properties at run time. Parameterization can be
done in
three ways using Quick Test.
• Datatable
• Environment variables
• Random numbers
A property of an object can be parameterised from the object repository.Select the property to be
parameterised
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
and check the Parameter option from the configure vlue frame and enter the value in the datatable
column.
Example
Consider parameterising the search string in the home page of Google.Each time you want to search for
a different
string. Enter the search string in the datatable and change the code as follows
Browser("Google").Page("Google").WebEdit("Search").Set
Datatable.Value("SearchString")
Browser("Google").Page("Google").WebEdit("Search").Submit
The datatable contains the searchstrings for search. The datatable has two rows and thus the test runs
for two iterations.We can import data for the datatable from an external source such as Excel. Choose
the resources tab from Test->Settings and select Other location in the Datatable frame and specify the
path of the Excel file.
===================================================================================
Synchronization is a property that enables to instruct QTP to wait for a state of a property on a
particular object to
change before preoceeding to the next step in the test case. It also enables a test to pause when the
application process
completes before moving to the next step. QTP displays an error message if it proceeds to the next step
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
before
completing the previous step.
Parameterisation facilitates reusabillity of an action or a test. By using parameters, you can record a test
once and use it
Addin envvironment enables to recognize objects in the development environment of Application Under
Test(AUT).
The Default Add ins that come along with QTP are Web, Acttivex and Visual Basic.
types:
1. wait()
2. Synchronization point
wait statement.
2.bitmap checkpoints
3.text checkpoints
4.textarea checkpoints
5.database checkpoints
6.xml checkpoints
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
7.page checkpoints
8.table checkpoints
9.image checkpoints
10.accessability checkpoints
7,8,9 are hidden checkpoints.
7-10 are web related checkpoints.
www.ramupalanki.com