Programming Concepts in QTP
Programming Concepts in QTP
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.
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.
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:
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
msgbox "Application is already running!" 'ou can replace this with Reporter.ReportOvent
strFoundProcess = True
Oxit for
Ond If
Next
1) Copy the above code to a notepad and save file as test.vbs on your desktop.
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
..)
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.
#
$
à
Set f=CreateObject("Scripting.FileSystemObject")
Set f1=f.CreateTextFile("c:\text.txt")
f1.writeline "aaa bbb"
f1.writeline "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
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.
à
val1=datatable("A",1)
val2=datatable("B",1)
res=cint(val1) +cint(val2)
msgbox res
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
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
&
!
#+,-
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
* 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
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
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
* 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
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.
* 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
)
* 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
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
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
)
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
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
8. To run all rows in the global data table, go to Test ->; Test Settings -> Run
tab, and select "Run on all rows."
rc = DataTable.Value ("A",dtLocalSheet)
msgbox rc
Browser("Google").Page("Google").WebOdit("q").Set rc
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.
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
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.
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*
!
+
#
ô
!
!
,
-,!
/
#
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.
)
/ 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´)
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.
,) .
à
ô
!
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,
)
/
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.
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
/
#
!
!
-,
!
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
#
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
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
-=!
à
=!!/
chk_PassFail = Browser(...).Page(...).WebOdit(...).Check (Checkpoint("Check1"))
if chk_PassFail then
MsgBox "Check Point passed"
else MsgBox "Check Point failed"
end if
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.
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.
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.
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.
#
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
$
Oxample:
C:\Program Files\ Technologies\ABC Server\Onglish\lservrc
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.