Sei sulla pagina 1di 17

What are the key elements of a QTP window?

The QuickTest window contains the following key elements: ? QuickTest title bar—Displays the
name of the currently open test or component. ? Menu bar—Displays menus of QuickTest
commands. ? File toolbar—Contains buttons to assist you in managing your test or component. ?
Testing toolbar—Contains buttons to assist you in the testing process. ? Debug toolbar—Contains
buttons to assist you in debugging your test or component (not displayed by default). ? Action
toolbar—Contains buttons and a list of actions, enabling you to view the details of an individual
action or the entire test flow. ? Test pane—Contains the Keyword View and Expert View tabs. ?
Active Screen—Provides a snapshot of your application as it appeared when you performed a
certain step during the recording session. ? Data Table—Assists you in parameterizing your test
or component. For a test, the Data Table contains the Global tab and a tab for each action. For
a component, the Data Table contains single tab. ? Debug Viewer pane—Assists you in
debugging your test or component. The Debug Viewer pane contains the Watch Expressions,
Variables, and Command tabs (not displayed by default). ? Status bar—Displays the status of the
QuickTest application.

How many tabs are available in Debug Viewer Pane?

The Debug Viewer pane contains three tabs to assist you in debugging your test or component—
Watch Expressions, Variables, and Command. Watch Expressions The Watch Expressions tab
enables you to view the current value of any variable or other VBScript expression. Variables
The Variables tab enables you to view the current value of all variables that have been
recognized up to the last step performed in the run session. Command The Command tab
enables you to execute a line of script in order to set or modify the current value of a variable
or VBScript object in your test or component. When you continue the run session, QuickTest
uses the new value that was set in the command.

How many toolbars QTP has?

QuickTest has 4 built-in toolbars: 1. The File toolbar 2. The Testing toolbar 3. The Debug
toolbar 4. Action toolbar The Action toolbar is available in the Keyword View and contains
options that enable you to view all actions in the test flow or to view the details of a selected
action. The Action toolbar is not available for components.

Explain the terms Password Encoder, Remote Agent, Test Batch Runner, Test Results
Deletion tool? Password Encoder—enables you to encode passwords. You can use the resulting
strings as method arguments or Data Table parameter values. Remote Agent—determines how
QuickTest behaves when a test or component is run by a remote application such as Quality
Center. Test Batch Runner—enables you to set up QuickTest to run several tests in succession.
Test Results Deletion Tool—enables you to delete unwanted or obsolete results from your
system according to specific criteria that you define.

Explain the terms Test Object Model, Test Object & Run-Time object?

The test object model is a large set of object types or classes that QuickTest uses to represent
the objects in your application. Each test object class has a list of properties that can uniquely
identify objects of that class and a set of relevant methods that QuickTest can record for it. A
test object is an object that QuickTest creates in the test or component to represent the
actual object in your application. QuickTest stores information about the object that will help
it identify and check the object during the run session. A run-time object is the actual object
in your Web site or application on which methods are performed during the run session.

What are assistive properties or an ordinal identifier?

When mandatory property values are not sufficient to uniquely identify the object within its
parent object, QuickTest adds some assistive properties and/or an ordinal identifier to create a
unique description. Note: You can retrieve or modify property values of the test object during
the run session by adding GetTOProperty and SetTOProperty statements in the Keyword View or
Expert View. You can retrieve property values of the runtime object during the run session by
adding GetROProperty statements. If the available test object methods or properties for an
object do not provide the functionality you need, you can access the internal methods and
properties of any run-time object using the Object property. You can also use the attribute
object property to identify Web objects in your application according to user-defined
properties.

What is object Repository ?Explain different types of Object Repositories?

QuickTest identifies objects in your application based on a set of test object properties. It
stores the object data it learns in the object repository. You can save your objects either in a
shared object repository or in action object repository. In shared object repository mode, you
can use one object repository file for multiple tests or components. In object repository
peraction mode, QuickTest automatically creates an object repository file for each action in
your test. Object repository per-action mode is not available for components.

How you can enhance your test?

There are variety of options to enhance your test: (1) You can add checkpoints to your test. A
checkpoint is a step in your test that compares the values of the specified property during a
test run with the values stored for the same test object property within the test. This enables
you to identify whether or not your Web site or application is functioning correctly. (2) You can
parameterize your test to replace fixed values with values from an external source during your
test run. The values can come from a Data Table, environment variables you define, or values
that QuickTest generates during the test run. (3)You can retrieve values from your test and
store them in the Data Table as output values. You can subsequently use these values as an
input parameter in your test. This enables you to use data retrieved during a test in other parts
of the test. (4) You can divide your test into actions to streamline the testing process of your
Web site or application. (5)You can use special QuickTest options to enhance your test with
programming statements. The Step Generator guides you step-by-step through the process of
adding recordable and non-recordable methods to your test. You can also synchronize your test
to ensure that your application is ready for QuickTest to perform the next step in your test,
and you can measure the amount of time it takes for your application to perform steps in a test
by defining and measuring transactions. (6)You can also manually enter standard VBScript
statements, as well as statements using QuickTest test objects and methods, in the Expert
View.

Explain different recording modes ?

QuickTest’s normal recording mode records the objects in your application and the operations
performed on them. This mode is the default and takes full advantage of QuickTest’s test
object model, recognizing the objects in your application regardless of their location on the
screen. Analog Recording - enables you to record the exact mouse and keyboard operations you
perform in relation to either the screen or the application window. In this recording mode,
QuickTest records and tracks every movement of the mouse as you drag the mouse around a
screen or window. This mode is useful for recording operations that cannot be recorded at the
level of an object, for example, recording a signature produced by dragging the mouse. Note:
You cannot edit analog recording steps from within QuickTest. ? Low-Level Recording - enables
you to record on any object in your application, whether or not QuickTest recognizes the
specific object or the specific operation. This mode records at the object level and records all
run-time objects as Window or WinObject test objects. Use low-level recording for recording
tests in an environment or on an object not recognized by QuickTest. You can also use low-
level recording if the exact coordinates of the object are important for your test. Note: Steps
recorded using low-level mode may not run correctly on all objects.

Explain different types of checkpoints?

There are 10 types of checkpoints you can insert: Standard Checkpoint checks the property
value of an object in your application or Web page. The standard checkpoint checks a variety
of objects such as buttons, radio buttons, combo boxes, lists, etc. Image Checkpoint checks the
value of an image in your application or Web page. For example, you can check that a selected
image’s source file is correct. Bitmap Checkpoint checks an area of your Web page or
application as a bitmap. Table Checkpoint checks information within a table. For example,
suppose your application or Web site contains a table listing all available flights from New York
to San Francisco. You can add a table checkpoint to check that the time of the first flight in
the table is correct. Text Checkpoint checks that a text string is displayed in the appropriate
place in your application or on a Web page. Text Area Checkpoint checks that a text string is
displayed within a defined area in a Windows application, according to specified criteria.
Accessibility Checkpoint identifies areas of your Web site that may not conform to the World
Wide Web Consortium (W3C) Web Content Accessibility Guidelines. Page Checkpoint checks the
characteristics of a Web page. For example, you can check how long a Web page takes to load
or whether a Web page contains broken links. Database Checkpoint checks the contents of a
database accessed by your application. XML Checkpoint checks the data content of XML
documents in XML files or XML documents in Web pages and frames.

What is parameter?

A parameter is a variable that is assigned a value from an external data source or generator. If
you wish to parameterize the same value in several steps in your test or component, you may
want to consider using the Data Driver rather than adding parameters manually

How many types of parameters are there?

There are four types of parameters: 1. Test, action or component parameters 2. Data Table
parameters 3. Environment variable parameters 4. Random number parameters Test, action or
component parameters enable you to use values passed from your test or component, or values
from other actions in your test.0 Data Table parameters enable you to create a data-driven
test (or action) that runs several times using the data you supply. In each repetition, or
iteration, QuickTest uses a different value from the Data Table. Environment variable
parameters enable you to use variable values from other sources during the run session. These
may be values you supply, or values that QuickTest generates for you based on conditions and
options you choose. Random number parameters enable you to insert random numbers as
values in your test or component.

How Does Run time data (Parameterization) is handled in QTP?

You can then enter test data into the Data Table, an integrated spreadsheet with the full
functionality of Excel, to manipulate data sets and create multiple test iterations, without
programming, to expand test case coverage. Data can be typed in or imported from databases,
spreadsheets, or text files.

Explain about the Test Fusion Report of QTP ?


Once a tester has run a test, a TestFusion report displays all aspects of the test run: a high-
level results overview, an expandable Tree View of the test specifying exactly where
application failures occurred, the test data used, application screen shots for every step that
highlight any discrepancies, and detailed explanations of each checkpoint pass and failure. By
combining TestFusion reports with QuickTest Professional, you can share reports across an
entire QA and development team.

How QTP recognizes Objects in AUT?

QuickTest stores the definitions for application objects in a file called the Object Repository.
As you record your test, QuickTest will add an entry for each item you interact with. Each
Object Repository entry will be identified by a logical name (determined automatically by
QuickTest), and will contain a set of properties (type, name, etc) that uniquely identify each
object. Each line in the QuickTest script will contain a reference to the object that you
interacted with, a call to the appropriate method (set, click, check) and any parameters for
that method (such as the value for a call to the set method). The references to objects in the
script will all be identified by the logical name, rather than any physical, descriptive
properties.

In how many ways we can add check points to an application using QTP.

We can add checkpoints while recording the application or we can add after recording is
completed using Active screen (Note : To perform the second one The Active screen must be
enabled while recording).

What is the file extension of the code file & object repository file in QTP?

(1)For code file the extension is .vbs (2)For object repository file the extension is .tsr File
extension for per action is (.mtr)

How to Merge Object repositories?

With QTP 8.2 ,there is QTP Plus setup.It provides Repositories Merge Utility.The Object
Repository Merge Utility enables user to merge Object repository files into a single Object
repository file.

What are the different scripting languages you could use when working with QTP ?

Visual Basic (VB), XML, JavaScript, Java, HTML

Can you do more than just capture and playback?


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.

How many types of Actions are there in QTP?

There are three kinds of actions: (1)non-reusable action—an action that can be called only in
the test with which it is stored, and can be called only once. (2)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. (3)external action—a reusable action stored with another test. External 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

How can we write scripts without having GUI(means u dont have any GUI and u want to
write a script in QTP)?

By descriptive programming

What is the descrirptive progrmaing?.what is the use of descriptive programing?

QTP uses its object repository to refer to objects present in your test and which have been
recorded, if you wish to use objects that were not recorded and are not present in your object
repository then we use descriptive programming, where QTP does not refer to object
repository but the property name and value are mentioned in the code itself for QTP to use it
for e.g this is not Desc. prog. Browser("Mercury Tours").Page("Mercury
Tours").WebEdit("username") This is desc prog. Browser("Title:=Mercury
Tours").Page("Title:=Mercury Tours").WebEdit("Name:=Author", "Index:=3").Set "Mark Twain"

Explain the need to use analog recording in qtp?

This mode records exact mouse and Key Board operations you perform in relation to the
screen /Application Window. This mode is useful for the operation which you can record at
Object Level, such as drawing a picture, recording signature. The steps recorded using Analog
Mode is saved in separated data file, Quick Tests add to your Test a Run Analog File statement
that calls the recorded analog File. This file is stored with your action in which these Analog
Steps are created. The Step recorded in Analog mode can not be edited within Q

Descriptive programming in QTP

Whenever QTP records any action on any object of an application, it adds some description on
how to recognize that object to a repository of objects called object repository. QTP cannot
take action on an object until unless its object description is in the Object Repository. But
descriptive programming provides a way to perform action on objects which are not in Object
repository
Object Identification:
To identify an object during the play back of the scripts QTP stores some properties which
helps QTP to uniquely identify the object on a page. Below screen shots shows an example
Object repository:
Now to recognize a radio button on a page QTP had added 2 properties the name of the radio
button and the html tag for it. The name the left tree view is the logical name given by QTP
for the object. This can be changed as per the convenience of the person writing the test case.
QTP only allows UNIQUE logical name under same level of hierarchy. As we see in the snapshot
the two objects in Browser->Page node are “WebTable” and “testPath”, they cannot have the
same logical name. But an object under some other node can have the same name. Now with
the current repository that we have, we can only write operation on objects which are in the
repository. Some of the example operations are given below
Browser("Browser").Page("Page").WebRadioGroup ("testPath").Select "2"
cellData = Browser("Browser").Page("Page").WebTable ("WebTable").GetCellData (1,1)
Browser("Example2").Page("Page").WebEdit("testPath").Set "Test text"

When and Why to use Descriptive programming?

Below are some of the situations when Descriptive Programming can be considered useful:
The objects in the application are dynamic in nature and need special handling to identify the
object. The best example would be of clicking a link which changes according to the user of
the application, Ex. “Logout <<UserName>>”.
When object repository is getting huge due to the no. of objects being added. If the size of
Object repository increases too much then it decreases the performance of QTP while
recognizing a object.
When you don’t want to use object repository at all. Well the first question would be why not
Object repository? Consider the following scenario which would help understand why not
Object repository
Scenario 1: Suppose we have a web application that has not been developed yet. Now QTP for
recording the script and adding the objects to repository needs the application to be up, that
would mean waiting for the application to be deployed before we can start of with making QTP
scripts. But if we know the descriptions of the objects that will be created then we can still
start off with the script writing for testing
Scenario 2: Suppose an application has 3 navigation buttons on each and every page. Let the
buttons be “Cancel”, “Back” and “Next”. Now recording action on these buttons would add 3
objects per page in the repository. For a 10 page flow this would mean 30 objects which could
have been represented just by using 3 objects. So instead of adding these 30 objects to the
repository we can just write 3 descriptions for the object and use it on any page.
Modification to a test case is needed but the Object repository for the same is Read only or in
shared mode i.e. changes may affect other scripts as well.
When you want to take action on similar type of object i.e. suppose we have 20 textboxes on
the page and there names are in the form txt_1, txt_2, txt_3 and so on. Now adding all 20 the
Object repository would not be a good programming approach.

How to use Descriptive programming?

There are two ways in which descriptive programming can be used


By creating properties collection object for the description.
By giving the description in form of the string arguments.
By creating properties collection object for the description.
To use this method you need first to create an empty description
Dim obj_Desc ‘Not necessary to declare
Set obj_Desc = Description.Create
Now we have a blank description in “obj_Desc”. Each description has 3 properties “Name”,
“Value” and “Regular Expression”.
obj_Desc(“html tag”).value= “INPUT”
When you use a property name for the first time the property is added to the collection and
when you use it again the property is modified. By default each property that is defined is a
regular expression. Suppose if we have the following description
obj_Desc(“html tag”).value= “INPUT
” obj_Desc(“name”).value= “txt.*”
This would mean an object with html tag as INPUT and name starting with txt. Now actually
that “.*” was considered as regular expression. So, if you want the property “name” not to be
recognized as a regular expression then you need to set the “regularexpression” property as
FALSE
obj_Desc(“html tag”).value= “INPUT”
obj_Desc(“name”).value= “txt.*”
obj_Desc(“name”).regularexpression= “txt.*”
This is how of we create a description. Now below is the way we can use it
Browser(“Browser”).Page(“Page”).WebEdit(obj_Desc).set “Test”
When we say .WebEdit(obj_Desc) we define one more property for our description that was not
earlier defined that is it’s a text box (because QTPs WebEdit boxes map to text boxes in a web
page).
If we know that we have more than 1 element with same description on the page then we must
define “index” property for the that description
Consider the HTML code given below
<INPUT type=”textbox” name=”txt_Name”>
<INPUT type=”textbox” name=”txt_Name”>
Now the html code has two objects with same description. So distinguish between these 2
objects we will use the “index” property. Here is the description for both the object
For 1st textbox:
obj_Desc(“html tag”).value= “INPUT”
obj_Desc(“name”).value= “txt_Name
” obj_Desc(“index”).value= “0”
For 2nd textbox:
obj_Desc(“html tag”).value= “INPUT”
obj_Desc(“name”).value= “txt_Name”
obj_Desc(“index”).value= “1”
Consider the HTML Code given below:
<INPUT type=”textbox” name=”txt_Name”>
<INPUT type=”radio” name=”txt_Name”>
We can use the same description for both the objects and still distinguish between both of
them
obj_Desc(“html tag”).value= “INPUT”
obj_Desc(“name”).value= “txt_Name”
When I want to refer to the textbox then I will use the inside a WebEdit object and to refer to
the radio button I will use the description object with the WebRadioGroup object.
Browser(“Browser”).Page(“Page”).WebEdit(obj_Desc).set “Test” ‘Refers to the text box
Browser(“Browser”).Page(“Page”).WebRadioGroup(obj_Desc).set “Test” ‘Refers to the radio
button
But if we use WebElement object for the description then we must define the “index” property
because for a webelement the current description would return two objects.
Hierarchy of test description:
When using programmatic descriptions from a specific point within a test object hierarchy, you
must continue to use programmatic descriptions from that point onward within the same
statement. If you specify a test object by its object repository name after other objects in the
hierarchy have been described using programmatic descriptions, QuickTest cannot identify the
object.
For example, you can use Browser(Desc1).Page(Desc1).Link(desc3), since it uses programmatic
descriptions throughout the entire test object hierarchy. You can also use
Browser("Index").Page(Desc1).Link(desc3), since it uses programmatic descriptions from a
certain point in the description (starting from the Page object description).
However, you cannot use Browser(Desc1).Page(Desc1).Link("Example1"), since it uses
programmatic descriptions for the Browser and Page objects but then attempts to use an
object repository name for the Link test object (QuickTest tries to locate the Link object based
on its name, but cannot locate it in the repository because the parent objects were specified
using programmatic descriptions).
Getting Child Object:
We can use description object to get all the objects on the page that matches that specific
description. Suppose we have to check all the checkboxes present on a web page. So we will
first create an object description for a checkboxe and then get all the checkboxes from the
page
Dim obj_ChkDesc
Set obj_ChkDesc=Description.Create
obj_ChkDesc(“html tag”).value = “INPUT”
obj_ChkDesc(“type”).value = “checkbox”
Dim allCheckboxes, singleCheckBox
Set allCheckboxes = Browse(“Browser”).Page(“Page”).ChildObjects(obj_ChkDesc)
For each singleCheckBox in allCheckboxes
singleCheckBox.Set “ON”
Next
The above code will check all the check boxes present on the page. To get all the child objects
we need to specify an object description i.e. we can’t use the string arguments that will be
discussed later in the 2nd way of using the programming description.
Possible Operation on Description Object
Consider the below code for all the solutions
Dim obj_ChkDesc
Set obj_ChkDesc=Description.Create
obj_ChkDesc(“html tag”).value = “INPUT”
obj_ChkDesc(“type”).value = “checkbox”

How to get the no. of description defined in a collection

obj_ChkDesc.Count ‘Will return 2 in our case

How to remove a description from the collection

obj_ChkDesc.remove “html tag” ‘would delete the html tag property from the collection

How do I check if property exists or not in the collection?


The answer is that it’s not possible. Because whenever we try to access a property which is not
defined its automatically added to the collection. The only way to determine is to check its
value that is use a if statement “if obj_ChkDesc(“html tag”).value = empty then”.

How to browse through all the properties of a properties collection?

Two ways
1st:
For each desc in obj_ChkDesc
Name=desc.Name
Value=desc.Value
RE = desc.regularexpression
Next
2nd:
For i=0 to obj_ChkDesc.count - 1
Name= obj_ChkDesc(i).Name
Value= obj_ChkDesc(i).Value
RE = obj_ChkDesc(i).regularexpression
Next
By giving the description in form of the string arguments.

You can describe an object directly in a statement by specifying property:=value pairs


describing the object instead of specifying an object’s name. The general syntax is:
TestObject("PropertyName1:=PropertyValue1", "..." , "PropertyNameX:=PropertyValueX")
TestObject—the test object class could be WebEdit, WebRadioGroup etc….
PropertyName:=PropertyValue—the test object property and its value. Each property:=value
pair should be separated by commas and quotation marks. Note that you can enter a variable
name as the property value if you want to find an object based on property values you retrieve
during a run session.
Consider the HTML Code given below:
<INPUT type=”textbox” name=”txt_Name”>
<INPUT type=”radio” name=”txt_Name”>
Now to refer to the textbox the statement would be as given below
Browser(“Browser”).Page(“Page”).WebEdit(“Name:=txt_Name”,”html tag:=INPUT”).set “Test”
And to refer to the radio button the statement would be as given below
Browser(“Browser”).Page(“Page”).WebRadioGroup(“Name:=txt_Name”,”html tag:=INPUT”).set
“Test”
If we refer to them as a web element then we will have to distinguish between the 2 using the
index property
Browser(“Browser”).Page(“Page”).WebElement(“Name:=txt_Name”,”html
tag:=INPUT”,”Index:=0”).set “Test” ‘ Refers to the textbox
Browser(“Browser”).Page(“Page”).WebElement(“Name:=txt_Name”,”html
tag:=INPUT”,”Index:=1”).set “Test” ‘ Refers to the radio button

QuickTest Professional (QTP) 8.2 Tips and Tricks (1)

Data Table
Two Types of data tables
Global data sheet: Accessible to all the actions
Local data sheet: Accessible to the associated action only
Usage:
DataTable("Column Name",dtGlobalSheet) for Global data sheet
DataTable("Column Name",dtLocalSheet) for Local data sheet
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 only through then test result. The
run-time data table can also be exported using DataTable.Export or DataTable.ExportSheet
How can I save the changes to my DataTable in the test itself?

Well QTP does not allow anything for saving the run time changes to the actual data sheet. The
only work around is to share the
spreadsheet and then access it using the Excel COM Api's.

How can I check if a parameter exists in DataTable or not?

The best way would be to use the below code:


code:
on error resume next
val=DataTable("ParamName",dtGlobalSheet)
if err.number<> 0 then
'Parameter does not exist
else
'Parameter exists
end if

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 expects of Excel COM APIs
code:
Set xlApp=Createobject("Excel.Application")
set xlWorkBook=xlApp.workbooks.add
set xlWorkSheet=xlWorkbook.worksheet.add
xlWorkSheet.Range("A1:B10").interior.colorindex = 34 'Change the color of the cells
xlWorkSheet.Range("A1:A10").value="text" 'Will set values of all 10 rows to "text"
xlWorkSheet.Cells(1,1).value="Text" 'Will set the value of first row and first col
rowsCount=xlWorkSheet.Evaluate("COUNTA(A:A)") 'Will count the # of rows which have non
blank value in the column A
colsCount=xlWorkSheet.Evaluate("COUNTA(1:1)") 'Will count the # of non blank columns in 1st
row
xlWorkbook.SaveAs "C:\Test.xls"
xlWorkBook.Close
Set xlWorkSheet=Nothing
Set xlWorkBook=Nothing
set xlApp=Nothing

SMART Identification
Smart 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.
When should I use SMART Identification?

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 you are 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 SI feature was used to identify a
object 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 object which are not present in the OR. For more details refer to
http://bondofus.tripod.com/QTP/DP_in_QTP.doc (right click and use save as...)
What is a Recovery Scenario?

Recovery scenario gives you an option to take some action for recovering from a fatal error in
the test. The error could range in from occasional 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 it should be checked.

What does a Recovery Scenario consists of?

Trigger: Trigger is nothing but the cause for initiating the recovery scenario. It could be any
popup window, any test error, particular state of an object or any application error. Action:
Action defines what needs to be done if scenario has been triggered. It can consist of a
mouse/keyboard event, close application, call a recovery 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 could be to repeat the step, move to next step etc....

When to use a Recovery Scenario and when to us on error resume next?

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.

Library Files or VBScript Files


How do we associate a library file with a test ?

Library files are files containing normal VBScript code. The file can contain function, sub
procedure, classes etc.... You can also use executefile function 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 resources tab.

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. But when we use Executefile function to load a
library file, then the function are available in the action that called executefile. By associated
a library to a test we share variables across action (global variables basically), using association
also makes it possible to execute code as soon as the script runs 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 ?

Test objects are basic and generic objects that QTP recognize. Run time object means the
actual object to which a test object maps

QuickTest Professional (QTP) 8.2 Tips and Tricks (2)

Can I change properties of a test object?

Yes. You can use SetTOProperty to change the test object properties. It is recommended that
you switch off the Smart Identification for the object on which you use SetTOProperty
function.

Can I change properties of a run time object?

No (but Yes also). You can use GetROProperty("outerText") to get the outerText of a object but
there is no function like SetROProperty to change this property. But you can use
WebElement().object.outerText="Something" to change the property.

What is the difference between an Action and a function?

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.

Where to use function or action?

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.

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 of checkpoints depending on the type of data that needs to
be tested in the AUT. It can be text, image/bitmap, attributes, XML etc....

What's the difference between a checkpoint and output value?

Checkpoint only checks for the specific attribute of an object in AUT while Output value can
output those attributes value to a column in data table.

How can I check if a checkpoint passes or not?

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

My test fails due to checkpoint failing, Can I validate a checkpoint without my test failing
due to checpoint failure?

code:
Reporter.Filter = rfDisableAll 'Disables all the reporting stuff
chk_PassFail = Browser(...).Page(...).WebEdit(...).Check (Checkpoint("Check1"))
Reporter.Filter = rfEnableAll 'Enable all the reporting stuff
if chk_PassFail then
MsgBox "Check Point passed"
else
MsgBox "Check Point failed"
end if

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 use Environment.value("Param1") then QTP will create a new
internal environment variable if it does not exists already. So to be sure that variable exist in
the environment try using Environment("Param1").value.
How to connect to a database?

code:
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")
objConnection.Open "DRIVER={Microsoft ODBC for Oracle};UID=;PWD=
"
objRecordset.CursorLocation = adUseClient
objRecordset.CursorType = adopenstatic
objRecordset.LockType = adlockoptimistic
ObjRecordset.Source="select field1,field2 from testTable"
ObjRecordset.ActiveConnection=ObjConnection ObjRecordset.Open 'This will execute your
Query
If ObjRecordset.recordcount>0 then
Field1 = ObjRecordset("Field1").Value
Field2 = ObjRecordset("Field2").Value
End if

Potrebbero piacerti anche