Вы находитесь на странице: 1из 21

DATA DRIVEN FRAMEWORK

In this Framework the Test case logic resides in Test Scripts. The Test Data is separated and kept
outside the Test Scripts. The script is just a “Driver” or delivery mechanism for the Data.

In this framework test input and output values are read from external data files (ODBC sources, CVS
files, Excel files, DAO objects, ADO objects, and such) and are loaded into variables in captured or
manually coded scripts.

Test Scripts themselves are prepared either using Linear Scripting or Test Library Framework.

Advantages

 Scripts may be developed while application development is still in progress.

 Utilizing a modular design, and using files or records to both input and verify data, reduces
redundancy and duplication of effort in creating automated test scripts.

 A Variety of Test Scenarios can be executed by just varying the Test Data in the External Data
File.

 If functionality changes, only the specific "Business Function" script needs to be updated.

Disadvantages

 More time is needed to plan and prepare both Test Scripts and Test Data.

 Requires proficiency in the Scripting language used by the tool (technical personnel).

 Multiple data-files are required for each Test Case. There may be any number of data-inputs
and verifications required, depending on how many different screens are accessed. This
usually requires data-files to be kept in separate directories by Test Case.

1
STC Technologies Pvt. Ltd.
 Tester must not only maintain the Detail Test Plan with specific data, but must also re-enter
this data in the various required data-files.

Parameterization

Parameterization in QTP is a process of replacing all the constants within the test script into variables
(parameters) so that we can reuse the same script with different sets of data.

There are four types of parameters available in QTP. Those are

 Test and Action Parameter Options


 Data Table Parameter Options
 Environment Variable Parameter Options
 Random Number Parameters

Test/action parameters -Test parameters enable you to use values passed from your test. Action
parameters enable you to pass values from other actions in your test.

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 - 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 New to create your own
internal variables or Click Export to retrieve values from external sources.

Environment variables in QTP are of three types

 Built-in (Read only)


 User-defined Internal (Read only)
 User-defined External (Read/Write)

Random number Parameters -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.

2
STC Technologies Pvt. Ltd.
Data Table

Parameterization is used to test an application with different data from a single action (or multiple
actions) through multiple iterations.

The data changes for each iteration, it must be stored in a data-pool

This data-pool can be QTP’s Data Table, an Excel Spreadsheet or any database

Syntax

'If retrieving data from Local DataTable (Action1, Action2,…ActionN)

DataTable ("ColumnName", dtLocalSheet)

'If retrieving data from Global DataTable (dtGlobalSheet)

DataTable ("ColumnName", dtGlobalSheet)

Example

The syntax above to retrieve our user name and password:

DataTable ("Username", dtLocalSheet)

Dialog ("Login").WinEdit ("Agent Name :") .Set DataTable ("ant", dtLocalSheet)

DataTable ("Password", dtLocalSheet)

Dialog ("Login").WinEdit ("Password :") .SetSecure

DataTable ("pwd", dtLocalSheet)

Make parameterization using global data sheet

Steps

Enter the Agent Name and Password →Click OK→ Close the flight reservation window→select
configure icon in keyword view →select parameter→set the column name for the data table as user
name and for password close the application enter the values in global data table

And check for the iteration as specified for the values mentioned in data table

3
STC Technologies Pvt. Ltd.
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 to 100.

Step 1 – Open a new Test -> click on the “Record” button -> Open the “Notepad” to record ->type
some number in the notepad ->close the notepad -> stop recording ->now go to keyword view ->
click on the “configure value” button ->

4
STC Technologies Pvt. Ltd.
5
STC Technologies Pvt. Ltd.
Step 2 – Now select the “Parameter” and in that select “Random Number”

6
STC Technologies Pvt. Ltd.
Environmental Variable

The Environmental Variables can have Quick Test generated values or values supplied from external
files.

Environmental Variables are dynamic in nature, and it can be dynamic in changed. There are number
of environmental variables that can be referenced by programs and can be useful in finding
information.

There are two types of Environment variables

 Built-in-variables
 User Defined Variables

Built-in Variables - These variables will be by default available in every test and can be directly used
in any test with help of following syntax.

7
STC Technologies Pvt. Ltd.
Example

Var=environment. Value ("OS")

msgbox var

User-Defined Variables - The variables which are created by the user and can be invoked in test
script.

8
STC Technologies Pvt. Ltd.
Step Generator

The Step Generator enables to add steps by selecting from a range of context-sensitive options
and entering the required values.

In the Step Generator dialog box we can define steps that use
 Test Object methods and properties .(Test Only)
 Utility Object methods and properties.(Links,URL)
 Calls to library functions (Test only), VB Script functions and internal script functions.

Steps
 Before we open the Step Generator define a new step, first select where in the test a new step
should be inserted.

 After we open the Step Generator, first select the category for the Step Generator (Test Object,
Utility Object or Functions).

9
STC Technologies Pvt. Ltd.
 We can then select the appropriate method or function and define the arguments and return values,
parameterizing them if required.

 The Step Generator then inserts a step with the correct syntax into your test; we can continue to
add further steps at the same location without closing the Step Generator.

10
STC Technologies Pvt. Ltd.
 You can open the Step Generator from the Keyword view or Expert view while recording or
editing the test; we can also open the Step Generator from the Active Screen while editing.

11
STC Technologies Pvt. Ltd.
Virtual Objects

What are Virtual Objects?


Sometimes, an application under test may contain standard window object but are not recognized
by QTP. Under these circumstances, objects can be defined as virtual object(VO) of type button, link
etc. so that user actions can be simulated on the virtual objects during execution.

Example
Let us say we are automating a scenario in Microsoft Word. I activated MS word application and I
click on any icon in the ribbon. For example, on the Ribbon, Insert tab is clicked and then the user
clicks the "Picture" button. A button is recognized as WinObject; hence, importance of virtual
objects is pronounced.

Window ("Microsoft Word").WinObject ("Ribbon").Click 145, 45

Window ("Microsoft Word").WinObject ("Ribbon").WinObject ("Picture...").Click

170,104

Creating a Virtual Object


Step 1 – For such scenarios, virtual Objects are created using Virtual Object Manager or New Virtual
Object from “Tools” ---> “Virtual Object” ---> “New Virtual Object” and click the “Next” button.

12
STC Technologies Pvt. Ltd.
Step 2 − Map the
Object against the
Class Type and click
“Next”

Step 3 − Click “Mark Object” Button. A cross hair cursor would appear and mark the object that you
would like to map and click “Next”

13
STC Technologies Pvt. Ltd.
Step 4 − Select the parent of the Virtual object and click “Next”

Step 5 − Name the collection in which you would like to store the virtual object and click “Finish”

14
STC Technologies Pvt. Ltd.
Virtual Object Manager
Virtual Object Manager manages the collections of Virtual objects. Testers can add or Delete the
Virtual Objects from the Virtual Object manager.

Navigation to Virtual object Manager – “Tools”---> “Virtual Object Manager” as shown below –

Using Virtual Objects


After creating the Virtual Objects, the created object can be used as shown below −

15
STC Technologies Pvt. Ltd.
Window ("Microsoft Word").WinObject ("Ribbon").VirtualButton ("button").Click

Limitations
 QTP does not support virtual objects for analog or low-level recording.

 Checkpoints cannot be added on Virtual Objects.

 Virtual Objects are not controlled by Object Repository.

 Though we map an object to a particular class (button or List), all the methods of the native
objects are not supported by Virtual objects.

 Object Spy cannot be used on Virtual Object.

 The test execution will fail if the screen resolution changes as the co-ordinates change.

 Application Window should be of same screen size so that Virtual objects are captured
correctly.

Descriptive Programming

To understand the concept of descriptive programming lets understand the significance of an


objects name in QTP.

“An object name is simply used to map an object in script with its description in object repository”

It uses this name to track the object in object repository. For a parent you cannot have two child
objects with the same name. Hence, QTP uniquely maps the object in the repository

It then uses the stored description in the Object Repository and replaces the name with the
description. It then uses this statement to identify the object in the application under test

But what if instead of QTP replacing the object description, you as a tester directly specify the object
descriptions in your script. This is nothing but “Descriptive Programming”

Two ways to do descriptive programming -

You can use Descriptive programming in two ways

 Static
 Dynamic

Static Method

16
STC Technologies Pvt. Ltd.
Syntax

className (“property name: =property value”).method

EXAMPLE

SystemUtil.Run "c:\Program Files\Mercury Interactive\QuickTest


Professional\samples\flight\app\flight4a.exe","","c:\Program Files\Mercury Interactive\QuickTest
Professional\samples\flight\app\","open"

Dialog ("text: =Login").Activate

Dialog ("text: =Login").WinEdit ("attached text: =Agent Name :") .Set "malini"

Dialog ("text: =Login").WinEdit ("attached text: =Password :") .SetSecure "mercury"

Dialog ("text: =Login").WinButton ("text: =OK").Click

Window("text:=Flight Reservation").Close

17
STC Technologies Pvt. Ltd.
Dynamic Method

In case your script uses the descriptive programming object candidate multiple times, it will be very
tiresome to specify all the property value pairs for each statement. In such cases you can make use
of Description Class provided by QTP

Syntax

Set MyDescription = Description.Create();

MyDescription("property").Value = "property-value";

Example -

SystemUtil.Run "c:\Program Files\Mercury Interactive\QuickTest


Professional\samples\flight\app\flight4a.exe","","c:\Program Files\Mercury Interactive\QuickTest
Professional\samples\flight\app\","open"

‘Creating description for Login

Set a=description.Create

a("text").value="Login"

'Creating description for Agent Name

Set b=description.Create

b("attached text").value="Agent Name:"

'Creating description for Password

Set c=description.Create

c("attached text").value="Password:"

'Creating description for OK

Set d=description.Create

d ("text").value="OK"

'Creating description for Flight Reservation

Set e=description.Create

18
STC Technologies Pvt. Ltd.
e ("text").value="Flight Reservation"

Dialog (a).Activate

Dialog (a).WinEdit (b).set "malini"

Dialog (a).WinEdit(c).setsecure “mercury"

Dialog (a).WinButton (d).click

Window (e).close

Other Tools In QTP

Test Batch Runner

Executing a group of Tests or series of test at a time is known as Batch Testing or Batch Execution.
For performing Batch Testing, QTP is providing a separate Tool called Test Batch Runner. It is used to
perform Regression Testing and test batches are saved with .mts extension

Navigation

 Start ---> All Programs ---> QTP---> Tools --->Test Batch runner

 This is how the “Test Batch Runner” looks like

19
STC Technologies Pvt. Ltd.
 Go to Batch ---> Add(add test that has to be added to batch)

 Repeat the above steps if required


 File ---> Save as --->.mts extension

20
STC Technologies Pvt. Ltd.
 Go to “Batch” ---> Click on “Run” to execute the test script

21
STC Technologies Pvt. Ltd.

Вам также может понравиться