Thursday, 16 July 2015

QTP GUIDE FOR BEGINNERS

Object Repository:
It is a storage place of QTP where objects information can be stored and it also acts as interface between the Test script and the AUT in order to identify the objects during execution.
Local Repository:

QTP creates a Local Repository for every Action automatically during Recording. That cannot be shared among tests.

User can add some more objects to Local repository

User can perform rename, delete operations on local repository. As it is QTP internal file user no need to save modifications.

Shared Repository: 

User (Test Engineer) creates the Shared Repository by adding objects. That can be shared among number of tests.

Using this method user can perform modifications on objects easily.

Overview:

Generally for every object 20-25 properties information available, qtp recognizes object using 2 0r 3 important properties.

Qtp has default object identification configuration for every environment, if we feel that config is not sufficient for recognizing objects in our application, we can configure some more

QTP learns information in the following in case of normal identification:

First of all the qtp learns all the mandatory properties at a time and thinks whether these properties sufficient to identify the object uniquely. if it feels sufficient then it stops learning otherwise,
It learns first assistive property and once again stops and thinks, like this qtp learns one by one. At the end of assistive properties list also if it feels not satisfied and it finally goes to Ordinal Identifier
.

QTP learns information in the following in case of Smart Identification:
Smart identification is an optional feature, if we feel normal identification is not sufficient for any object, and then we configure Smart Identification for that object, in order to avoid Ordinal Identifier.

After normal identification if qtp feels not satisfied then it goes to smart identification. in smart identification 2 types of properties available, first qtp learns all base filter properties at a time and thinks whether these properties are sufficient for identifying the object uniquely. If it feels sufficient, then it stops learning otherwise it goes Optional Filter Properties and learns one by one. Still it feels not satisfied finally it goes to Ordinal Identifier.


Ordinal identifiers:

There are 3 types of ordinal identifiers available

1) Location: is based on object location in the AUT ,location starts from zero.
 
2) index: it is based on sequence of the programs, index starts from zero
 
Entering / Providing objects information directly into the test script is called Descriptive Programming.

In this method of script creation, we no need to have Object Repositories.

Advantages:
a) Descriptive Programming based Test scripts are faster in execution than Repository based Test scripts.

b) Scripts are portable (we can run these scripts from any machine easily)

c) Maintenance is easy (less amount of resources)

d) We can start Test Execution process even though Application is not ready.

Descriptive programming is basically 2 types.

1. Static Programming
2. Dynamic Programming

Static Programming

  In this style of script generation, we provide objects information directly into the script.
Dynamic Programming

In this style of script generation, first we create description objects, provide properties information and use description objects in the test script.

It is a process of matching the speeds of both QTP and AUT in order to get proper execution and results.

Where Synchronization is required:

During test execution QTP gives instructions one by one with same speed, but AUT takes less time for some operations execution and more time for some operations execution, that time we may not get proper execution and results. In order to get proper results in between QTP & AUT synchronization is required.

There are several methods available in QTP for synchronization.

1. Inserting Wait statements.
2. Inserting Synchronization points.
3. Increasing Tool default synchronization time.
4. Sync Method (Only for WEB)
5. Exist Property

Inserting Wait Statements:

We can insert wait statements in our test in order to make QTP to wait until AUT completes current operation.
Syntax: Wait(time in seconds)

Note: If we insert wait statements QTP waits up to maximum time even though operation is completed.

Note: if we insert Synchronization points, it does not wait up to maximum time, after completion of the current operations, it goes to next step immediately.

Syntax: object hierarchy.waitproperty “property name”,value,time in milli seconds.

Increasing Tool default synchronization time:

Note: If we increase QTP tool default time that can be applied for all statements in the test, but QTP does not wait up to maximum time unnecessarily, After completion of one statement execution it goes to next statement immediately.

Selecting an appropriate Method:

1. Suppose in our test one or more statements only are taking more time for execution then selecting “Inserting synchronization method” is better.

2. Suppose in our test more statements are taking more time for execution then selecting “increasing tool time out” .

3. Above two are local features but wait statement is Vbscript feature, even though some drawbacks are there in using wait statement, it is better to use wait statement in functions.

Advantages of Wait Statement:
1)  It is a VBScript statement, we can use this globally

2) It is recommended, whenever we want to observe the Test Execution process
3) No object reference required to insert wait statements

4) It is useful to make QTP capture values and screen shots during test execution

QTP is providing a Utility object called Services for measuring transaction time
Suppose, we want to measure how much time that one test or part of the test is taking for execution/running, we can measure using these transaction point (Start and End) 




Debugging Tests

Debugging is a process of executing the script or a program in a User designed fashion with some temporary break points in order to identify the errors.

For debugging, QTP is providing debug commands and breakpoints.

Debug Commands:

1)  Step Into (short cut key F11):
  1. It starts execution
  2. It executes one statement at a time.
  3. If it is function call, it opens the function, after that it executes one statement at a time.
2) Step Over (Short cut key F10):

a) It executes one statement at a time after execution starts
b) It executes all functions statements at a time

Note: After opening the function, if we use step over it executes one statement at a time only.

3)  Step Out (shift +F11):

It executes all remaining statements in a function at a time.

Debug viewer Pane:

It is used for viewing, modifying or setting the value of the variables during the execution break with the help of 3 Tabs.
    1. Watch
    2. Variables
    3. Command
Note: Through Debug Viewer Pane, We can watch variables whether the variables are taking correct values or not at a specific point of time. We can change Values of Variables temporarily.

Environment Variables in QTP

These are global variables; if you want to use some variables globally (From number of tests) declaring as global variables is better. If we declare as local variables in number of tests, modifications are difficult.

Types of Environment variables:

1. Built in variables: These are system defined variables, we can access from all tests but these are designed as read only.

2. User defined variables: Variables that we predefine in the active external environment variables file. We can create as many files as we want and we can change values of variables.

Recovery Scenario Manager

To recover from unexpected events and errors that are occurred in the test environment during run session, we can use Recovery Scenario Manager. For good recovery, error must be known the occurrence is unknown.

There are (4) Types of events such as:

(i) Application Crash

An open application fails during Test Run.

i) Popup Window.

To handle unwanted popups

) Test Run Error.

A step in your test does not run successfully then Test Run Error
can be raised.

Object State.

The property values of an object in your application match
specified values. You can specify property values for each object in the
hierarchy.

Virtual Object Configuration:

Virtual Object Configuration is a process of making the QTP to treat a specified area or a user defined object as Virtual Object.

Virtual objects enable us to create and run tests on objects that are not normally recognized by QTP.

We can manage the virtual objects defined on our computer using the Virtual Object Manager.

 Batch Testing or Batch Execution

Executing a group of Tests or series of tests  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.

File System Operations

File System:

Its an operating system feature, it allows users to create, modify,
view and delete; drives,folders and files

VB Script is providing an object called scripting.filesystemobject
and some methods for performing file systems operations

File System Object Model:

The File System Object (FSO) model provides an object-based tool for working with folders and files. It allows us to use the familiar object.method syntax with a rich set of properties, methods, and events to process folders and files. We can also employ the traditional Visual Basic statements and commands.

The FSO model gives our application the ability to create, alter, move, and delete folders, or to determine if and where particular folders exist. It also enables us to get information about folders, such as their names and the date they were created or last modified.

The FSO model makes processing files much easier as well. When processing files, our primary goal is to store data in an efficient, easy-to-access format. We need to be able to create files, insert and change the data, and output (read) the data. Although we can store data in a database, doing so adds a significant amount of overhead to our application. We may not want to have such overhead, or our data access requirements may not call for the extra functionality associated with a full-featured database. In this case, storing our data in a text file or binary file is the most efficient solution.

The FSO model, contained in the Scripting type library (Scrrun.dll), supports the creation and manipulation of text files through the TextStream object; however, the FSO model does not support binary files. To manipulate binary files, use the FileOpen Function with the Binary keyword.

Database connections

Database connection is a facility in computer science that allows client software to communicate with database server software, whether on the same machine or not.

AOM Scripting (Automation Object Model)

Object Model:

An object model is a structural representation of software objects (classes) that comprise the implementation of a system or application. An object model defines a set of classes and interfaces, together with their properties, methods and events, and their relationships. 

We can use QTP Automation object Model to write scripts, that automate our QTP operations.

QTP Automation object model provides objects, methods and properties that enable us to control QTP from another application
.

We can use Scripting languages or programming languages such as VBscript, Java script or VC++, .Net for automating QTP operations.


Note: AOM Script can be used in Automation framework as an Initialization script.

Dynamic handling of object Repositories

Loading repositories during running, finding path of the repositories and removing repositories is called Dynamic Handling of Object Repositories.

Using this feature we can increase QTP performance. To do this, QTP is providing an object called “RepositoriesCollection”.


No comments:

Post a Comment