Sie sind auf Seite 1von 118

QTP Training

Internal
On Premise Suite Test Center
TIP CORE ECF India
Agenda

Introduction Internal

Modes of Recording
Object Repository
Actions, Parameterizations, Paths & Conditions
Function Library
CheckPoints
Descriptive Programming
Glossary
Agenda for the Day 1

Agenda Time
Expectation Setting 8:30 A.M – 9:00 A.M

Introduction 9:00 A.M – 9:45 A.M

Modes of recording 9:45 A.M – 10:45 A.M

Break 10:45 A.M – 11:00 A.M

Exercise 11:00 A.M – 12:00 P.M

Lunch 12:00 P.M – 12:45 P.M

Object Repository 12:45 P.M – 01:30 P.M

Exercise 01:30 P.M –02:30 P.M

Break 02:30 P.M –02:45 P.M

Actions, Parameterizations, Paths & Conditions 02:45 P.M –03:45 P.M

Exercise 03:45 P.M – 5:00 P.M

© SAP AG 2009. All rights reserved. / Page 3 Internal


Agenda for the Day 2

Agenda Time
Function Library 8:30 A.M – 10:30 A.M

Break 10:30 A.M – 10:45 A.M

Exercise 10:45 A.M – 12:00 P.M

Lunch 12:00 P.M – 12:45 P.M

Check Points 12:45 P.M – 1:45 P.M

Exercise 1:45 P.M – 2:45 P.M

Break 2:45 P.M – 3:00 P.M

Descriptive Programming 3:00 P.M – 3:45 P.M

Exercise 3:45 P.M – 4:45 P.M

Glossary 4:45 P.M – 5:00 P.M

© SAP AG 2009. All rights reserved. / Page 4 Internal


Agenda

Introduction Internal

Modes of Recording
Object Repository
Actions, Parameterizations, Paths & Conditions
Function Library
CheckPoints
Descriptive Programming
Glossary
HP Quick Test Professional

To reduce the time and costs associated with application testing, you need a solution
that offers functionality across most of the environments and business processes….

© SAP AG 2009. All rights reserved. / Page 6 Internal


QTP Environment and Add Ins

Windows
 C++, Visual Basic, Java, .NET, Power Builder

Web
 Web Applications, Web services, Flash

Browsers
 Netscape, IE, AOL, Firefox

Other technologies
 SAP, Siebel, Oracle, Peoplesoft, ActiveX

We have different sets of add ins for all the


above mentioned technologies to support
object manipulation in QTP

© SAP AG 2009. All rights reserved. / Page 7 Internal


Key Features and Benefits

 QTP provides record and playback of events

 Uses VBScript as the scripting Language

 Provides Keyword View and Expert View to view test cases

 Previous version of QTP: 6.5, 8.0, 8.1, 8.2, 9.0, 9.1,9.2,9.5

 Enables collaboration among workgroups with shared function libraries and robust
object management

 Manages multiple object repositories with ease to facilitate building automated


frameworks and libraries

 Point-and-check interface for accessing & interacting with the components of the
application under test

© SAP AG 2009. All rights reserved. / Page 8 Internal


Key Features and Benefits

 Has an Icon-Based test tree in which each branch represents a step in the
business process

 QTP implements the following Checkpoints in the Scripts:


 Standard Checkpoint
 Text Checkpoint
 Text Area Checkpoint
 Bitmap Checkpoint
 Database Checkpoint
 XML Checkpoint

 Provides three modes of Recording depending on the types of UI Screens


and objects:
 Normal
 Analog
 Low level

© SAP AG 2009. All rights reserved. / Page 9 Internal


Toolbars

Test toolbar
 contains buttons to assist you in the testing process (e.g. record, run..)

Debug toolbar
 contains buttons to assist you in debugging your test

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 two tabs to view your test—the Keyword View and the Expert View

Information
 contains the syntax errors or any other relevant information about the Test

Data Table
 contains two or more tabs to assist you in parameterizing your test—Global and
one tab for each Action
© SAP AG 2009. All rights reserved. / Page 10 Internal
QTP Screen (Expert View)…

Toolbars

DataTable and Resources

Active Screen

Information Pane

© SAP AG 2009. All rights reserved. / Page 11 Internal


QTP Screen (Keyword View)

The Icon Based Tree in the Expert view


provides modularity to the script.

© SAP AG 2009. All rights reserved. / Page 12 Internal


Object Repository…

List Of Objects

© SAP AG 2009. All rights reserved. / Page 13 Internal


Agenda

Introduction Internal

Modes of Recording
Object Repository
Actions, Parameterizations, Paths & Conditions
Function Library
CheckPoints
Descriptive Programming
Glossary
Why Normal Recording ?

 Normal recording mode records the objects in an application and the operations
performed on them.

 This mode is the default and takes full advantage of the QuickTest test object
model, recognizing the objects in your application regardless of their location on
the screen.

© SAP AG 2009. All rights reserved. / Page 15 Internal


Normal Recording

Record

© SAP AG 2009. All rights reserved. / Page 16 Internal


Why Analog Recording ?

 Actual movement of the mouse or keyboard is needed e.g drawing a mouse


signature, paint etc.

 This mode is useful for the operation which you can record at Object Level, such
as drawing a picture, recording signature.

© SAP AG 2009. All rights reserved. / Page 17 Internal


Analog Recording

 In this recording mode, Quick Test records and tracks every movement of the
mouse as it is dragged around a screen or window.

 User cannot edit the analog recording steps from within Quick Test. The step is
added after the recording stops.

Example of Signature Capture

© SAP AG 2009. All rights reserved. / Page 18 Internal


Why Low level Recording ?

 Recording on environments or objects not supported by QuickTest.


 The exact location of an object is necessary (x or y coordinates).
 Low-level recording supports the following methods for each test object:
 WinObject test objects: Click, DblClick, Drag, Drop, Type
 Window test objects: Click, DblClick, Drag, Drop, Type, Activate, Minimize,
Restore, Maximize

© SAP AG 2009. All rights reserved. / Page 19 Internal


Low Level Recording

 This enables us to record on any object in the application, whether or not


Quick Test recognizes the specific object or the specific operation.
 This mode records at the object level and records all run-time objects as
Window or Win Object test objects.

© SAP AG 2009. All rights reserved. / Page 20 Internal


Where is show…

Demonstration

© SAP AG 2009. All rights reserved. / Page 21 Internal


Break

© SAP AG 2009. All rights reserved. / Page 22 Internal


Exercise for Automation Modes…

Motive: Write a script to log on to the EPOS Manager Application using the three
types of automation modes

Applications Which can be used:

ePOS : Link to be provided during the training

Exercise:

Create a Script with :


 Create a script named as ―AutomationExercise‖
 Make three actions which use the three ways of automation modes
respectively to log on to the Store Manager.
 Record the steps for the three modes separately in the three actions.
 Please make sure to log off from Store Manager before exiting an action.
 Analyze the code generated during the recording.

© SAP AG 2009. All rights reserved. / Page 23 Internal


Lunch

© SAP AG 2009. All rights reserved. / Page 24 Internal


Agenda

Introduction Internal

Modes of Recording
Object Repository
Actions, Parameterizations, Paths & Conditions
Function Library
CheckPoints
Descriptive Programming
Glossary
What is an Object Repository

 An Object Repository is a place where QTP stores learned Objects.


 It displays a tree of all objects in the current component or in the current action or entire test(
depending on the object repository mode we selected).

© SAP AG 2009. All rights reserved. / Page 26 Internal


Understanding the Object 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.

© SAP AG 2009. All rights reserved. / Page 27 Internal


Object Repository Types

Local Repository: Shared Repository: (Recommended)


Local repository stores objects in a file Shared repository stores objects in a file
that is associated to specific action, so that can be accessed by multiple test
that only that action can access the (in read-only mode).
stored objects.
Action maintenance will be high. Action maintenance will low.
Local Repository are modifiable from Shared repository are modifiable only
specific action. via object repository manager.

© SAP AG 2009. All rights reserved. / Page 28 Internal


Deciding Whether to Use Local or Shared Object
Repositories

In general, the local object repository is easiest to use when you are creating simple record and
run tests, especially under the following conditions:
 You have only one, or very few, tests that correspond to a given application, interface, or
set of objects.
 You do not expect to frequently modify test object properties.
 You generally create single-action tests.

Conversely, the shared object repository is generally the preferred option when:
 You are creating tests using keyword-driven methodologies (not using record).
 You have several tests that test elements of the same application, interface, or set of
objects.
 You expect the object properties in your application to change from time to time and/or you
regularly need to update or modify test object properties.
 You often work with multi-action tests and regularly use the Insert Copy of Action and Insert
Call to Action options.

© SAP AG 2009. All rights reserved. / Page 29 Internal


How to add objects to the Object Repository

We can add objects to the Object Repository either during Recording or through the Object
Repository Manager
How to add objects while Recording?
Record the steps that you want to perform.
Navigate to the object repository and perform add objects operation and click particular object.
(local repository)
Navigate to the object repository and perform add object operation and click on top most part
of window which you are trying to automate (shared repository)

© SAP AG 2009. All rights reserved. / Page 30 Internal


Object Repository Manager

What is an Object Repository Manager?

The Object Repository Manager enables you to manage all of the shared object repositories
used in your organization from a single, central location

© SAP AG 2009. All rights reserved. / Page 31 Internal


Creation of a Shared Object Repository

 Navigate to object Repository manager

 Click on File ->New to create a new object Repository

© SAP AG 2009. All rights reserved. / Page 32 Internal


Creation of a Shared Object Repository –
Adding a single object at a time

Click on the button to add objects to the repository

Place the object spy on the User id field to display the object hierarchy

Select the object to be added. Click on the OK button.

© SAP AG 2009. All rights reserved. / Page 33 Internal


Creation of a Shared Object Repository –
Adding multiple objects at a time
Select the option -> default object types
Click on the OK Button
The hierarchy is displayed with the default objects present on the browser
Highlight the objects to see that they are identified correctly

© SAP AG 2009. All rights reserved. / Page 34 Internal


Creation of a Shared Object Repository

Login to the application and add the objects referring to the next screen
We can find the links being added under the frame called menu

© SAP AG 2009. All rights reserved. / Page 35 Internal


Saving the Repository

Click on the link Employees and navigate to the screen where we can create a new employee

Similarly add objects present in all the screens which we would use.

Save the Object Repository (folder present in a shared network drive)

© SAP AG 2009. All rights reserved. / Page 36 Internal


Associating the repository with the test

Associate the repository with the Test by navigating to Resources-> Associate


Repositories
Click on the button and select the path where the repository is present.
Click on the Open button. Click on the OK Button

© SAP AG 2009. All rights reserved. / Page 37 Internal


Associating the repository with the test

Associate the Actions with the repository


Save the test

© SAP AG 2009. All rights reserved. / Page 38 Internal


Scripting using the shared Object Repository

Start the scripting by as shown below.


The options would appear and actions need to be performed as shown

© SAP AG 2009. All rights reserved. / Page 39 Internal


Tool Exercise / Demo

Motive:

Using the given application create the following 2 types of repositories and
associate them with your test

 Local Repository

 Shared Repository

 URL – The application to be used would be provided during the training session

© SAP AG 2009. All rights reserved. / Page 40 Internal


Break

© SAP AG 2009. All rights reserved. / Page 41 Internal


Agenda

Introduction Internal

Modes of Recording
Object Repository
Actions, Parameterizations, Paths & Conditions
Function Library
CheckPoints
Descriptive Programming
Glossary
Actions :

Actions are the logical units of test, basically a set of meaningful activity/clicks on UI
(like Login, Logoff…)

A test comprises calls to actions. By default, each test begins with a single action.

Dividinga test into actions helps us to streamline the testing process, the tests will
be more modular and efficient with less maintains effort.

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 is stored together with the test.

Logical Sequencing

© SAP AG 2009. All rights reserved. / Page 43 QTP Script Test Result Internal
Types of Actions :

There are three kinds of actions:

Non-re-usable: Action can be used in the local test, only once.

Re-usable: Action can be used in the local test, multiple times.

External: These are reusable actions created in another test. This can be of two types.
1) Call to Existing Action : (Insert -> Call to Existing Action) External actions are
read-only in the calling test

2) Call to Copy of Action : (Insert -> Call to Copy of Action) Local, editable copy of
external action.

© SAP AG 2009. All rights reserved. / Page 44 Internal


Create a New Action :

Steps to create a New Action (or Reusable Action) :

1)Click the step after which you want to insert the new action.

2)Choose Insert > Call to New Action or click the on Call to New Action button . The Insert
New Action dialog box opens.

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 modified at a later time in the Action
properties dialog box.

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.

© SAP AG 2009. All rights reserved. / Page 45 Internal


External Action : Call to Existing Action

1. Call to Existing Action : (Insert -> Call to Existing Action)

External actions are read-only in the calling test.

Inserting calls to an action makes it easier to maintain tests, because when an object
or procedure in the application changes, it needs to be updated only once, in the
original action

© SAP AG 2009. All rights reserved. / Page 46 Internal


External Action : Call to Copy of Action

2. Call to Copy of Action : (Insert -> Call to Copy of Action)

 Local, editable copy of external action.

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

© SAP AG 2009. All rights reserved. / Page 47 Internal


Steps - Call to Copy of Action

Call to Copy of Action : Insert -> Call to Copy of Action

Call to Copy of Action


Call to Existing Action

Difference

© SAP AG 2009. All rights reserved. / Page 48 Internal


Example :

 Suppose we want to create the following three tests for ePOS application —
 Add a new employee
 Edit an employee
 Delete an employee.

login and logOff to the ePOS application is common for all the three test so we need to create
a total of five actions for all three tests.

Test 1 would contain two reusable actions (Login and LogOff). These actions can later be
called by Test 2 and Test 3.

We would then finish creating Test 2 and Test 3 by inserting calls to the reusable actions which
we created in Test 1.

© SAP AG 2009. All rights reserved. / Page 49 Internal


Action Parameters :

There are two Action Parameters :

Input Parameter : Specifies the parameters that an action can receive values from the source that runs or
calls it.

Output Parameter : Specifies the parameters that an actions can pass to the source that runs or calls it

We can define, modify, and delete input and output parameters in the Parameters tab of the Action
Properties dialog box (Edit > Action > Action Properties or right-click an action and choose Action Properties).

For each input or output action parameter, we need to define a name (case sensitive), a type, and optionally,
a description.

We can also specify a default value for each action input parameter. the default value is saved with the
action and is used by the action if a value is not defined for a parameter in the action call.

Example : Creation of an Employee in ePOS application requires below details


 First Name
 Last Name

And then application generates an Employee Number.

So we can define FirstName & LastName as input parameters


EmployeeNumber as Output parameter.

Out parameter can be consumed in other test


(like – Search For Employee)

© SAP AG 2009. All rights reserved. / Page 50 Internal


Exercise for Action :

Motive: Create a script to describe creation of new action & re-usable action and calling these
reusable action to another script.

Applications Which can be used:

ePOS Application : To be given during training

Exercise:

1.Create a script named as ―GenericScript‖ with two reusable action ―Login‖ & ―LogOff‖

2.Create another script named as ―DemoScript‖ and call action ―Login‖ from ―GenericScript‖

3.Create an action ―Add a New Employee‖


3.1- Create input parameters as ―FirstName‖ & ―LastName‖ and an out put parameter ―EmployeeNumber‖

4.Create an action ―Search For Employee‖


4.1 - Create an input parameter ―EmployeeNumber‖ and consume the Out put parameter from the previous action i.e. ―Add
a New Employee‖.

5. Call ―LogOff‖ Reusable action from ―GenericScript‖.

© SAP AG 2009. All rights reserved. / Page 51 Internal


End of Day 1

© SAP AG 2009. All rights reserved. / Page 52 Internal


Parameterization :

When we test our applications, we may want to check how the application performs the same
operations with multiple sets of data. For example,

Suppose we want to check how our Web site responds to ten separate sets of data.

We could record ten separate tests, each with its own set of data.

Alternatively, we can create Data Table parameters so that our test runs ten times, each time
using a different set of data. this way of setting parameters is called …..

Parameterization

© SAP AG 2009. All rights reserved. / Page 53 Internal


Parameterization :

Parameterization can be done in four ways using Quick Test.

Test/action parameters : Test parameters enable us to use values passed from test. Action
parameters enable us to pass values from other actions in the test.

Datatable : Data Table parameters enable us to create a data-driven test, or action that runs
several times using the data we supply. The test runs once for each line of data in the DataTable.
Each iteration takes a different value from the datatable.

Environment variable Parameters : The Environment variables can have Quick Test
generated values or values supplied from external files.

 Random numbers : It enables us to use random numbers as values in the test. We can
specify the range from which the random number is generated. By default, the random number
range is between 0 and 100.

© SAP AG 2009. All rights reserved. / Page 54 Internal


Data Table : Global and Action Sheets

The Data Table has two types of data sheets—Global and Action.

GlobalData Sheet : We store data in the Global tab when we want it to be available to all actions in our test
and we want the data to control the number of test iterations. Global sheet enables us to pass information
between actions.

Action Data Sheet : We store data in the action's tab when we want to use the data in Data Table parameters
for that action only and we want the data to control the number of action iterations.

Example : Suppose we are creating a test for ePOS application - ―Add And Search New Employee‖.
 This requires one action for Login, one for Add a New Employee, one to search created employee and a forth for LogOff.
 We may want to create a test in which the user logs onto the application once, and then adds five new Employee.
 The data about the employee is relevant only to the second action, so it should be stored in the action tab corresponding to
that action.

© SAP AG 2009. All rights reserved. / Page 55 Internal


Environment variable Parameters :

The Environment variables can have Quick Test generated values or values supplied from external files.

We can add environment variables from Test->Settings->Environment tab. Choose User-defined from the
variable type.

Click to create our own internal variables

Click to Export user-defined environment variables to an XML file

External XML File : QTP supports uploading an external xml file with parameters.

The Structure of the xml File should as per the screenshot below

To upload an external XML file :

Select Check Box – ―Load variables and values from external file‖ and Provide the XML path.
© SAP AG 2009. All rights reserved. / Page 56 Internal
QTP : Methods

Test parameters : Test Parameter can be set/retrieved via below command


 X = TestArgs(―InputParameter‖) -- X will hold the test Input Parameter value
 TestArgs(―OutParameter‖) = Y -- Test OutPut parameter will hold the value of Y

Action parameters : Action Parameter can be set/retrieved via below command


 X = Parameter(―InputParameter‖) -- X will hold the action Input Parameter value
 Parameter(―OutParameter‖) = Y -- Action OutPut parameter will hold the value of Y

Data Table : Data Table values can be set/retrieved via below command
 X = DataTable.Value(ParameterID [, SheetID]) -- X will hold the data table ParameterID‘s value
 DataTable.Value(ParameterID [, SheetID]) = Y -- ParameterID will hold the value of Y
 ParameterID = Column name in data table
 SheetID = Global or Action sheet name

Environment Variable : Environment variable can be set/retrieved via below command


 X = Environment.value("VariableName") -- X will hold the environment variable value
 Environment.value("VariableName") = Y -- Environment variable will hold the value of Y

Random numbers : Generates a value for the specified RandomNumber parameter


To generate any random number:
 RandomNumber.Value(StartNumber,EndNumber)
 Example : X = RandomNumber.Value(0,100) -- QTP will generate a random number between 0 to 100

© SAP AG 2009. All rights reserved. / Page 57 Internal


Exercise for Parameterization :

Motive: Create a script to describe different ways of Parameterization.

Applications Which can be used:

ePOS Application : Link will be provided during training

Exercise:

1. Create a Script to ―Add a New Employee‖


2. Provide the data for First Name & Last Name via
 Test/action parameters
 Data Table
 Environment variable Parameters
 Random numbers

© SAP AG 2009. All rights reserved. / Page 58 Internal


Absolute and Relative Paths :

QuickTest enables us to define the path to a resource that we are adding to the file system, as a relative or
an absolute path

Absolute Path : An absolute path describes the full path to a specific file starting from a fixed location such
as the root directory, or the drive on which the file is located, and contains all the other sub-directories in the
path. An absolute path always points to the specified file, regardless of the current directory.

Relative Path : A relative path describes the path to a specific file starting from a given directory, and is
generally only a portion of the absolute path. A relative path therefore specifies the location of the file relative
to the given location in the file system.

Example : Consider a QuickTest resource file named ―FunctionLib.vbs‖ located in ―C:\Documents and
Settings\I043155\Desktop\Lib‖. Absolute & Relative path to the file are as below :

Absolute path : ―C:\Documents and Settings\I043155\Desktop\Lib\FunctionLib.vbs‖

Relative path :

[A]. Relative Path = ―FunctionLib.vbs‖

if Reference/Folder Path = ―C:\Documents and Settings\I043155\Desktop\Lib‖

[B]. Relative Path = ―Lib\FunctionLib.vbs‖

if Reference/Folder Path = ―C:\Documents and Settings\I043155\Desktop‖

Absolute Path = [Reference/Folder Path ] + [ Relative Path ]


© SAP AG 2009. All rights reserved. / Page 59 Internal
Advantage of Relative Path :

Using relative paths means that the paths remain valid when files or folders containing files are
moved or copied to other locations or computers, provided that they are moved within the same
folder structure. For this reason, as best practice we should use relative paths when saving
resources in QuickTest.

Maintain relative paths for below QTP resources :


 Library
 Reusable Actions
 Repository
 Environment Parameters

Example : Suppose we have scripts for 701 code line and there is new code line released i.e. 702 and 701
functionality remains same in 702 as well then we can port 701 script to 702.

Tools -> Options ->


Folders
© SAP AG 2009. All rights reserved. / Page 60 Internal
Control Statements and Important Methods…

Control Statements:
 Do…Loop Statement
 For….Next Statement
 If…Then…Else Statement
 Select Case Statement
 While…Wend Statement

Important Methods:
 GetROProperty
 WaitProperty
 GetCellText
 ChildObjects

© SAP AG 2009. All rights reserved. / Page 61 Internal


Control Statements…

•Do…Loop Statement:
• Repeats a block of statements while a condition is True or until a condition becomes True.
• Syntax:
Do [{While | Until} condition]
[statements]
[Exit Do]
[statements]
Loop
• Arguments:
condition: Numeric or string expression that is True or False. If condition is Null,
condition is treated as False
statements: One or more statements that are repeated while or until condition is True

© SAP AG 2009. All rights reserved. / Page 62 Internal


Control Statements…

•For…Next Statement:
• Repeats a group of statements a specified number of times.
• Syntax:
For counter = start To end [Step step]
[statements]
[Exit For]
[statements]
Next
• Arguments:
counter : Numeric variable used as a loop counter. The variable can't be an array element
or an element of a user-defined type.
start: Initial value of counter.
end: Final value of counter.
step: Amount counter is changed each time through the loop. If not specified, step defaults
to one.
statements: One or more statements between For and Next that are executed the
specified number of times.

© SAP AG 2009. All rights reserved. / Page 63 Internal


Control Statements…

•If…Then…Else Statement:
• Conditionally executes a group of statements, depending on the value of an expression.
• Syntax:
If condition Then
[statements]
[ElseIf condition-n Then
[elseifstatements]] . . .
[Else [
elsestatements]]
End If
• Arguments:
condition: One or more of the following two types of expressions: A numeric or string
expression that evaluates to True or False. If condition is Null, condition is treated as False.
statements: One or more statements separated by colons; executed if condition is True.
condition-n: Same as condition.
elseifstatements: One or more statements executed if the associated condition-n is True.
elsestatements: One or more statements executed if no previous condition or condition-n
expression is True.

© SAP AG 2009. All rights reserved. / Page 64 Internal


Control Statements…

•Select Case Statement:


• Executes one of several groups of statements, depending on the value of an expression.
Syntax:
Select Case testexpression
[Case expressionlist-n
[statements-n]] . . .
[Case Else expressionlist-n
[elsestatements-n]]
End Select
Arguments:
testexpression: Any numeric or string expression
expressionlist-n: Required if Case appears. Delimited list of one or more expressions.
statements-n: One or more statements executed if testexpression matches any part of
expressionlist-n.
elsestatements-n: One or more statements executed if testexpression doesn't match any
of the Case clauses

© SAP AG 2009. All rights reserved. / Page 65 Internal


Control Statements…

•While…Wend Statement:
• Executes a series of statements as long as a given condition is True.
• Syntax:
While condition
Version [statements]
Wend
Arguments:
condition: Numeric or string expression that evaluates to True or False. If condition is Null,
condition is treated as False.
statements: One or more statements executed while condition is True

© SAP AG 2009. All rights reserved. / Page 66 Internal


Important Methods…

•GetROProperty:
• Returns the current value of the test object property from the object in the application
Syntax:
object.GetROProperty (Property, [PropertyData])
Arguments:
object: A test object
Property: Required. A String value. The property to retrieve from the object.
PropertyData: Optional. A Variant value. Not in use.

•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, [TimeOut])

© SAP AG 2009. All rights reserved. / Page 67 Internal


Important Methods…

Arguments:
object: A test object
PropertyName: Required. A String value. The name of the property whose value is
checked.
PropertyValue: Required. A Variant value. The value to be achieved before continuing to
the next step. Specify the value as a string.
TimeOut: Optional. A Long value. The time, in milliseconds, after which QuickTest
continues to the next step if the specified value is not achieved. If no value is specified,
QuickTest uses the time set in the Object Synchronization Timeout option in the Run pane
of the Test Settings dialog box.

•GetCellData:
• Retrieves the contents of the specified cell from the table.
Syntax:
object.GetCellData (Row, Column)

© SAP AG 2009. All rights reserved. / Page 68 Internal


Important Methods…

Arguments:
object: A test object
Row: Required. A Variant value. The 0-based index of the row containing the cell whose
data you want to retrieve.
Column: Required. A Variant. The name or 0-based index of the column containing the
cell whose data you want to retrieve.

•ChildObjects:
• Returns the collection of child objects contained within the object.
Syntax:
object.ChildObjects ([Description])
Arguments:
Description: Optional. An Object object. A Properties (collection) object.
Tip: You can retrieve a Properties collection using the GetTOProperties method or you can
build a Properties collection object using the Description object. For more information on the
Description object, refer to the Utility section of the QuickTest Professional Object Model
Reference.

© SAP AG 2009. All rights reserved. / Page 69 Internal


Break

© SAP AG 2009. All rights reserved. / Page 70 Internal


Agenda

Introduction Internal

Modes of Recording
Object Repository
Actions, Parameterizations, Paths & Conditions
Function Library
CheckPoints
Descriptive Programming
Glossary
Introduction

In addition to the test objects, methods, and built-in functions supported by the
QuickTest Test Object Model, we can define our own function libraries containing
VBScript functions, subroutines, modules, and so forth, and then call their functions
from our test.

© SAP AG 2009. All rights reserved. / Page 72 Internal


At a Glance…

 User-defined Functions make our tests look shorter, easier to maintain read and
design. They can be called from within an action.

© SAP AG 2009. All rights reserved. / Page 73 Internal


How to Add Resource to a Test

 Go to File -> Settings -> Resources.

 Click on the ―+‖ icon to add the library file (*.qfl) to the test.

© SAP AG 2009. All rights reserved. / Page 74 Internal


An Example….

The method referred into an action from a Library……

© SAP AG 2009. All rights reserved. / Page 75 Internal


Advantages

 Time and Resources are saved by implementing and using user-defined


reusable functions.

 Easy to create and define a Function Library.

 All the users can choose functions that perform complex operations without
adding the code directly to the test.

 Any changes are implemented immediately, as these files are accessed directly
and are not saved as local copies when the test is opened.

© SAP AG 2009. All rights reserved. / Page 76 Internal


Key Notes

 The file extension of a library file is *.qfl.

 Functions in an associated function library are accessible


 From Step Generator
 From the Operation column in the Keyword View, or
 Can be entered manually in the Expert View.

 Steps using user-defined functions are not displayed in the test results tree of the
Test Results window by default; use Reporter.Event.

© SAP AG 2009. All rights reserved. / Page 77 Internal


Where is show…

Demonstration

© SAP AG 2009. All rights reserved. / Page 78 Internal


Exercise for Function Library…

Motive: Make a function library which contains the method to click on a link on a
web page.

Applications Which can be used:

ePOS : Link to be provided during the training

Exercise:

Create a Script with :


 Create a script named as ―FunctionLibExercise‖
 Create a function library which contains the method to click on a Link on the main page of a
Web Page
 Associate the library to the test ―FunctionLibExercise‖
 Call the method into the script and Execute

© SAP AG 2009. All rights reserved. / Page 79 Internal


Lunch Break

© SAP AG 2009. All rights reserved. / Page 80 Internal


Agenda

Introduction Internal

Modes of Recording
Object Repository
Actions, Parameterizations, Paths & Conditions
Function Library
CheckPoints
Descriptive Programming
Glossary
What is a Checkpoint

A checkpoint is a step in the test, that compares the actual value of a specified object property to
an expected value of the same property

Example:

- Verify text in status bar

- Verify value in a grid

- Verify bitmaps

The status of a checkpoint (passed or failed) is located in the Test Results Summary

© SAP AG 2009. All rights reserved. / Page 82 Internal


Types of Checkpoints

Text Checkpoint - checks that a single line text string is displayed in the
appropriate place in the application

Text Area Checkpoint - checks that a multi line text string is displayed
in the appropriate place in the application

Bitmap Checkpoint - checks an area of an application as a bitmap

Database Checkpoint - checks the contents of a database accessed by


the application

XML Checkpoint - checks the data content of XML documents in XML


files or XML documents in Web pages and frames

© SAP AG 2009. All rights reserved. / Page 83 Internal


Types of Checkpoints

Standard Checkpoint - checks the property value of an object in the


application

Accessibility Checkpoint - identifies areas of a Web site that may not


conform to the World Wide Web Consortium

© SAP AG 2009. All rights reserved. / Page 84 Internal


Text Checkpoint

When do we use a Text Checkpoint?


 A text checkpoint is used when we need to check that a single line text string is displayed
in the appropriate place in the application

How do we add a Text Checkpoint?


Navigate to the screen where you would like to capture the object to be checked
Navigate to Insert->Checkpoint->Text Checkpoint
Select the option ‗Checked Text‘ which can be a constant or parameterized from the data
table.
‗Checked before‘ and ‗Checked After‘ option can also be used.

© SAP AG 2009. All rights reserved. / Page 85 Internal


Text Checkpoint

After running the script, a result window will pop up showing the success or failure of the run.
When you expand the nodes, you can see the result of the checkpoint.
Result – The text ‗Manage Tills ‗ appears between ‗Management‘ and ‗Create‘

© SAP AG 2009. All rights reserved. / Page 86 Internal


Standard Checkpoint

When do we use a standard checkpoint?

A standard checkpoint is used when we need to checks the property value of an object in the
application
How do we add a standard checkpoint?
Select Insert -> Checkpoint -> Standard Checkpoint Value button.
The Quick Test window is minimized, and the pointer turns into a pointing hand

 Select the object you need to check and select the properties with which you would like to
check the result. Click on the OK button

© SAP AG 2009. All rights reserved. / Page 87 Internal


Standard Checkpoint

After running the script, a result window will pop up showing the success or failure of the run.
When you expand the nodes, you can see the result of the checkpoint.
Result – The ‗Manager Functions‘ Web Element exists with the below properties:
Html tag ; value= ‗FONT‘ & innertext ; value = ‗Manager Functions‘

© SAP AG 2009. All rights reserved. / Page 88 Internal


Standard Checkpoint for Tables

When do we use a standard checkpoint for Tables?


A standard checkpoint is used when we need to check any value within a table
How do we add a standard checkpoint for tables?
Navigate to Insert->Checkpoint->Standard Checkpoint
Select the table area->Select the Webtable from the hierarchy as shown below. Click on OK
button

© SAP AG 2009. All rights reserved. / Page 89 Internal


Standard Checkpoint for Tables

How do we add a standard checkpoint for tables?


Select the cell content which needs to be checked.
Parameterize the value if required as shown below (user id field). Click on OK button

© SAP AG 2009. All rights reserved. / Page 90 Internal


Standard Checkpoint for Tables

After running the script, a result window will pop up showing the success or failure of the run.
When you expand the nodes, you can see the result of the checkpoint.
Result – The value in the User ID field is correctly displayed in the table

© SAP AG 2009. All rights reserved. / Page 91 Internal


Bitmap Checkpoint

When do we use a Bitmap checkpoint?


A Bitmap checkpoint is used when we need to check an area of an application as a bitmap
How do we add a Bitmap checkpoint?
Consider the bitmap image as shown below which needs to be checked
Navigate to Insert->Checkpoint->Bitmap checkpoint.
Select the bitmap and click on Select area button.
Select the area which needs to be checked and click on ‗OK‘ button.

© SAP AG 2009. All rights reserved. / Page 92 Internal


Bitmap Checkpoint

After running the script, a result window will pop up showing the success or failure of the run.
When you expand the nodes, you can see the result of the checkpoint.
Result – The bitmap exists in the application

© SAP AG 2009. All rights reserved. / Page 93 Internal


Database Checkpoint

When do we use a Database checkpoint?


A database checkpoint is used when we need to check the contents of a database accessed
by the application
How do we add a Database checkpoint? .
Define a query on your database and then create a database checkpoint that checks the
results of the query.
You can define a database query in the following ways
Using Microsoft Query. You can install Microsoft Query from the custom installation of
Microsoft Office.
By manually defining an SQL statement.
Choose Insert -> Checkpoint -> Database. The Database Query Wizard opens.

© SAP AG 2009. All rights reserved. / Page 94 Internal


Database Checkpoint

How do we add a Database checkpoint? .


Define a query on your database and then create a database checkpoint that checks the
results of the query.
Select your database selection preferences. You can choose from the following options:
Create query using Microsoft Query. Microsoft Query is opened, enabling you to create
a new query. This option is available only if you have Microsoft Query installed on
your computer.
Specify SQL statement manually. The Specify SQL statement screen in the wizard,
enables you to specify the connection string and an SQL statement.
Maximum number of rows checkbox should be selected if you would like to limit the
number of rows and enter the maximum number of database rows to check or
output. You can specify a maximum of 32,000 rows.
Click Next. The screen that opens depends on the option you selected in the previous
step
If you chose Create query using Microsoft Query in the previous step, Microsoft
Query opens. Choose a data source and define a query
If you chose Specify SQL statement manually in the previous step, the Specify
SQL statement screen opens. Specify the connection string and the SQL
statement, and click Finish
.
© SAP AG 2009. All rights reserved. / Page 95 Internal
Database Checkpoint

Specifying SQL Statements


Choose Specify SQL statement in the Database Query Wizard. The following screen
opens

Specify the connection string and the SQL statement, and click Finish.
Enter the connection string, or click Create to open the ODBC Select Data Source dialog
box. You can select a .dsn file in the ODBC Select Data Source dialog box or create a
new .dsn file to have the Database Query Wizard insert the connection string in the
box
Enter the SQL statement

© SAP AG 2009. All rights reserved. / Page 96 Internal


Database Checkpoint

Database Checkpoint Properties Dialog Box


Select the checks or outputs to perform on the result set
The Database Checkpoint Properties dialog box enables you to specify which cell contents of
your database to check and which verification method and type to use. You can also edit or
parameterize the expected data for the cells included in the check.

Click OK to close the dialog box. A checkpoint or output value statement is added for the
selected object in the Keyword View and Expert View.
© SAP AG 2009. All rights reserved. / Page 97 Internal
XML Checkpoint

When do we use an XML checkpoint?


AnXML checkpoint is used when we need to check the data content of XML documents in
XML files or XML documents in Web pages and frames
How do we add an XML checkpoint? .
Navigate to Insert->Checkpoint->XML Checkpoint(Resource)
The XML Source Selection - Checkpoint Properties dialog box opens

Select Create new checkpoint from file. Enter the file path or Internet address of the XML
file.
Click OK in the XML Source Selection. The XML Checkpoint Properties dialog box opens.

© SAP AG 2009. All rights reserved. / Page 98 Internal


XML Checkpoint

The XML Checkpoint Properties dialog box displays the element hierarchy and values of the
selected child. Click on the OK button
The XML Checkpoint gets generated as shown in the next slide

© SAP AG 2009. All rights reserved. / Page 99 Internal


XML Checkpoint

After running the script, a result window will pop up showing the success or failure of the run.
When you expand the nodes, you can see the result of the checkpoint.
Result – The value ‗123‘ (expected value) exists in the xml.

© SAP AG 2009. All rights reserved. / Page 100 Internal


XML Checkpoint

In case the checkpoint fails the result appears as below


Here the expected value and actual value differ

© SAP AG 2009. All rights reserved. / Page 101 Internal


Tool Demo / Exercise

Motive:
Use the given application create a new employee and add the following checkpoints:

Standard Checkpoint

Standard Table Checkpoint

Bitmap Checkpoint

Text Checkpoint

Database Checkpoint

XML Checkpoint

URL :
The application URL would be provided during the training

© SAP AG 2009. All rights reserved. / Page 102 Internal


Break

© SAP AG 2009. All rights reserved. / Page 103 Internal


Agenda

Introduction Internal

Modes of Recording
Object Repository
Actions, Parameterizations, Paths & Conditions
Function Library
CheckPoints
Descriptive Programming
Glossary
What is Descriptive Programming?

 An approach through which the objects under test are recognized dynamically.

 It is a programming technique which describes an object through specific properties


of the object into consideration.

 This technique of scripting does not use QTP‘s Object Repository (OR) in which we
specify properties and values of the object.

© SAP AG 2009. All rights reserved. / Page 105 Internal


Why and When to use Descriptive
Programming

 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
leading to decreased performance of Object Identification.

 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 we have to work with different methods and the different actions have
different ORs.

 When we are not able record certain specific object e.g. hidden panels, Objects
with changing hierarchies, Nested inner-object, Sub Menus etc.

© SAP AG 2009. All rights reserved. / Page 106 Internal


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.

© SAP AG 2009. All rights reserved. / Page 107 Internal


Properties collection object for the
description.

To use this method we first create an empty description:

The description of the Object is created as follows:

We use the Object in the following manner:

When we say .ChildObjects(Desc), it finds the collection of all the Images on the
page having the properties defined previously.

© SAP AG 2009. All rights reserved. / Page 108 Internal


Giving the description in form of the string
arguments.

 Object properties specified in a statement by specifying property:=value pairs


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.

© SAP AG 2009. All rights reserved. / Page 109 Internal


Code Example

 By creating properties collection object for the description.

The following code assigns the value to the first object out of the object collection of
WebEdit class defined by the properties:

Set Obj_oDesc = Description.Create()

Obj_oDesc("micclass").Value = “WebEdit”

Obj_oDesc(“name”).Value = “user_name”

Set Lists = Browser("name:=SAP Enterprise POS.*”).Page("title:=SAP Enterprise


POS.*”).ChildObjects(Obj_oDesc)

Lists(0).Set “posManager”

© SAP AG 2009. All rights reserved. / Page 110 Internal


Code Example Continued…

 By giving the description in form of the string arguments.

The following line of code sets the value of the username edit box:

Browser("name:=SAP Enterprise POS.*”).Page("title:=SAP Enterprise


POS.*”).WebEdit(“name:=user_name”).Set “posManager”

© SAP AG 2009. All rights reserved. / Page 111 Internal


Where is show…

Demonstration

© SAP AG 2009. All rights reserved. / Page 112 Internal


Exercise for Descriptive Programming…

Motive: Write a script to log on to the EPOS Manager Application using the two
methods of descriptive programming

Applications Which can be used:

ePOS : Link to be provided during the training

Exercise:

Create a Script with :


 Create a script named as ―DPExercise‖
 Make two actions which use the two ways of Descriptive Programming to log on to the
Store Manager.
 Please make sure to log off from Store Manager before running the second action.

© SAP AG 2009. All rights reserved. / Page 113 Internal


Agenda

Introduction Internal

Modes of Recording
Object Repository
Actions, Parameterizations, Paths & Conditions
Function Library
CheckPoints
Descriptive Programming
Glossary
Glossary : Msgbox & Print

 Msgbox : Displays a message in a dialog box, waits for the user to click a button.

 Print : Displays information in the QuickTest Print Log window during the run session. The QuickTest Print
Log window remains open while the run session continues, until we close it.

© SAP AG 2009. All rights reserved. / Page 115 Internal


Glossary : Reporter.ReporterEvent

Reporter.ReporterEvent : Reports an event to the test results

© SAP AG 2009. All rights reserved. / Page 116 Internal


Glossary : System time & Date & Locale Check

System time & date

Locale check – GetLocale & SetLocale

© SAP AG 2009. All rights reserved. / Page 117 Internal


Thank you!

© SAP AG 2009. All rights reserved. / Page 118 Internal

Das könnte Ihnen auch gefallen