Monday, December 31, 2012

Actions in QTP


As mentioned by QTP, Each QuickTest test comprises calls to Actions. Actions are units that divide your test into logical sections. When you create a new test, it contains a call to one . By dividing your tests into calls to multiple actions, you can design more modular and efficient tests. 

-Actions help divide test into logical units, such as the main sections of a Web site, or specific activities that you perform in application. 

-A test comprises calls to actions. When a new test is created, it contains a call to a single action. By creating tests that call multiple actions, can design tests that are more modular and efficient. 


-An action consists of its own test script, including all of the steps recorded in that action, and any objects in its local object repository.

-Can divide test into multiple actions by creating new actions and inserting calls to them, or by inserting calls to existing actions.


There three types of action in QTP:
 
  Non-reusable action: an action that can be called only in the test with which it is stored, and can be called only once.
  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.
  External action: a reusable action stored with another test. External actions are read-only in the calling test, but can choose to use a local, editable copy of the Data Table information for the external action.


A reusable action can be called multiple times within a test and can be called from other tests. Non-reusable actions can be copied and inserted as independent actions, but cannot be inserted as calls to the original action.
** Priority in Object Repository

Call an action from within an action called nesting. 
Maintain the modularity of your test.
Run one or more actions based on the results of a conditional statement.

Example
Create test based on the user type

To nest an action within an existing action:
Highlight the step after which to insert the call to the action.
Insert Call

Split Action
Split an action into two sibling actions or into parent-child nested actions. When an action is split, the second action starts with the step that is selected. 


Can’t split an action and the option is disabled when:
-an external action is selected
-recording a test
-running a test
-read-only test

Inserting Calls to Copies of Actions


When to use?
    It is best to use this functionality
When the action can be partly used with the associated resources through edition of test steps and likely to be standalone test unit.
When the user knows that this functionality is likely to change in the future hence doesn’t want to be reusable.

Inserting Calls to Existing Actions


When to use?
    It is best to use this functionality
When the functionality in the action can be completely used in another action such as a Login.
When the user likely to maintain a reusable actions for easier maintenance.

Remove Action

 
Removing a Non-Reusable Action
Removing a Call to a Reusable or External Action from the Test Flow
Removing a Reusable or External Action from a Test


Action Template:

Action template can include one or more statements in every new action in test. An action template applies only to actions created on your computer.

To create an action template: 


Create a text file containing the comments, function calls, and other statements that to be included in action template. The text file must be in the structure and format used in the Expert View.
Save the text file as ActionTemplate.mst in your <QTP Installation Folder>\dat folder. All new actions you create contain the script lines from the action template.


Note: Only the file name ActionTemplate.mst is recognized as an action template. 

RunAction:


RunAction is the key word to call an existing actionand execute the same

Syntax: 
RunAction ActionName, [Iteration , Parameters]
Eg:
1.RunAction “Create", allIterations
2.RunAction “Login", oneIteration, Parameter
retVal = RunAction (ActionName, IterationQuantity, Parameters)

Exit Action:

 
Exit an action before it runs in its entirety. May want to use this option to return the current value of the action to the value at a specific point in the run or based on the result of a conditional statement.
ExitAction. Exits the current action, regardless of its iteration attributes.
ExitActionIteration. Exits the current iteration of the action.
ExitRun. Exits the test, regardless of its iteration attributes.

LoadAndRunAction Statement: 

 
This is only available from QTP 10.0 +
Loads the specified action when this step runs, and then runs the action.
The action is loaded only when the step runs (and not when the test opens). Therefore the action is never listed in:
The Resources pane in QuickTest.
The Test Flow pane in QuickTest.
The Missing Resources pane in QuickTest.
The Dependencies tab in the Quality Center Test Resources module.
 

Syntax:
LoadAndRunAction(TestPath, ActionName, [Iteration], [Parameters]) 


 

Tuesday, November 6, 2012

Parameterization in QTP

When I need to test multiple set of data for the same functionality how will I do this?

QTP has a concept called Parameterization which will handle these situations. In general parameterization means replacing the hard coded value by a variable or parameter which holds data or multiple data. In simple words giving multiple inputs to the test (i.e. Test script). The main use of parameterization is re usability of the test script. Parameterization can also be done through looping statement (which I will discuss later). In other words QTP enables to expand the scope of a basic test by replacing fixed values with parameters. This process, known as parameterization, greatly increases the power and flexibility of test.

Why and When to use Parameterization in QTP?


- As discussed earlier, when I need to test same functionality for different set of inputs I will go for parameter. For example: In any on-line shopping site buyer, seller, dealer and other users will have their own access and responsibility to the site. I can verify how the functionality works for all the different users.
- Working with Common parameters across Scripts like URL, Result Folder, etc...
- When I have N numbers of inputs for a particular functionality or action I can go for parameterization, Once I was working for performance testing for one of my client, where I need to change the password (as the password expires every 90 days in my case) I had around 500+ user who needs to be updated, do you think for this I should go for 500+ times scripting or I can create one Test (script) and parameterize that?
These are very few real time examples where parameterization can be used. 

Types of Parameterization in QTP:

QTP has its own four ways to do parameterization

1. Datatable
2. Environment Variable
3. Test/Action Parameters
4. Random Numbers

We will see how these types will be used in which situation/scenarios in details.

Monday, March 26, 2012

Object Identification Process


Object Identification Process:

QTP has a unique way of Identifying the object from AUT, as discussed above it uses three Mandatory & Assertive properties, Ordinal Identification and Smart Identification.
QTP uses Mandatory & Assistive Properties to identify the object, If no property/properties matches with the object description in Object Repository (OR) it will throw an error stating that Object not found, If QTP identifies one or more properties similar with other object present in OR then it will try to identify the object using the next property which is ordinal Identifier if it still doesn't find the object it will try to identify the object using Smart Identification(Provided when it is Enabled(File-->Setting-->Run uncheck Disable Smart Identification During the run Session)), Which can be easily understood from the flow chart. Personally I don't recommend to use Smart Identification as it consumes execution time.

Monday, November 28, 2011

Object Identification Process

Object Identification:

How does QTP identifies the objects ?

QTP has a unique procedure to identifies the object, as per my expereince I feel this separts QTP from rest of the tool.
There are three ways by which QTP Identifies the Object in the Object Repository(OR) and they are :
-Mandatory Properties & Assistive properties
-Ordinal Identifiers
-Smart Identification

What is Mandatory properties and Assistive properties..?


These are the property which we give in Initial stage of Identifying the objects, like the name, title and Url properties for Browser Class. These are the basic properties which QTP uses to identifiy the objects in the application.The Mandatory and Assistive properties can selected after analysing the unqine property/properties by which the objects can be identified easily without any confilct. We can selet which properties should be madatory and assitive property.

Tool --> Object Identification...

Object Identification Window opens. Select the property/properties which is required by clicking 'Add/Remove' button then click 'OK'.
You can select the Oridinal identifier and Enable Smart Identification here itself.

Ordinal Identifiers:

Ordinal Identifier are the unique numerical value which QTP assigns for objects class in order to identify them. Ordinal Identifiers comes in object process when the Manadatory and assistive properties fails to identify the object. Ordinal Identifiers cannot be viewed using Spy.

 There are three types of Ordinal Identifiers
- Index
- Location
- Creation Time
Index : Index property are the numerical value generated by QTP for the object class. The starting value of index is Zero.
Location : Location Property are the numerical value of the objects which are in the The starting value of index is Zero.parent Window/browser, Frame and other objects.
Creation Time: This Ordinal Identifier is specifically for Browser class objects only. Numerical values are generated in the order in which the browsers are opened.

Smart Identification:


Smart Identification is used when QTP fails to identifies the object using Manadotry & Assative properties and ordinal Identifiers. Smart Identification uses two types of properties and they are Base Filter Properties and Optional Filter Properties.
Base Filter Properties:Base filter properties are the basic and fundamental properties of the object which cannot be changed without changing the object itself.
Optional Filter Properties:These are the properties which are  the remaining other properties which are unlikely to change frequently.

Object Identification Process:

Click here for more details

Monday, October 3, 2011

Object and Object Repositories

Object and Object Repositories

Objects:

        In QTP all the elements are saved in script as objects. Objects are combination of properties which are unique in Nature. Objects are composed of types and properties. Each object will have its set of properties to identify its object uniquely in the Application. For example, for a  text box its type is text box and property is to write any text in it. At the time of execution , QTP identifies the objects on the screen by comparing them with the objects and their properties in the Repository.


Mostly used objects in QTP(I will be discussing based on Web application only)
Browser
Page
Links
List Box
Radio Button
Web Table
Frame
Image

Web Edit
and so on..

There are two types of object in QTP:

1. Test Objects
    Object stored in object repository are called Test objects.
2. Run Time Objects
    Objects which are identified in run time (i.e Dynamic)are called Run Time Objects.




Object Spy:


Object spy is used to know the object information which are properties and values of the object, the methods associated to it and Object Spy will also display the object's hierarchy(i.e Structured view of objects). We can get the properties and methods by selecting the object required by the Pointer in Object spy. We can use Object spy for both Run Time and Test Objects.

Note: In earlier versions of QTP we can only view the objects information from Object spy, From QTP 11 we can add objects to the OR directly from object Spy.




Object Repositories (OR):

Collection of objects pertaining to the application under test(AUT) are called Object Repositories.

Types of Object Repository
In QTP there are two types of object Repository and they are
    - Per Action object repository(Local Object Repository)
    - Shared Object Repository

Per Action Object Repository:

Which is also called as local object repository. This is the default Repository of QTP and saved within the action itself.This Object Repository Specific to actions (Will be used only for a particular action). This OR is preferable when application is not dynamic with respect to time. Per Action Object Repository cannot be reused.
 
File Type:
Per Action Repository's extension is .bdb

Shared Object Repository:

The collection of Objects which are stored in a file (with extension of.tsr) that can be accessed by multiple users at the same time,
is known as Shared object repository. By Default ,Shared Object Repository is opened in Read-only mode. To enable editing click File (QTP Toolbar) > Enable Editing Shared object repository occupies less memory than the local object repository.
 
File Type:
Shared Object Repository's extension is .tsr

How to make a Object Repository as Shared OR ?

To make an object Repository as Shared Object Repository open the Object Repository i.e
Resources --> Object Repository
Then go to File in the Object Repository and then Export Local Object
i.e File -->Export Local Objects
After that save the repository where you want to maintain the file with extension '.tsr'


Check out for Object Identification here

Thursday, September 8, 2011

TESTING PROCESS IN QTP


TESTING PROCESS IN QTP

1. Create Test Plan
2. Generate the Tests
3. Enhance the Tests
4. Debug the Tests
5. Run the Tests
6. Analyze Test Results
7. Report Defects

1) Create Test Plan
The First step in the QTP testing Process is Creating Test Plan. Here we analyze the Application Under Test (AUT) and create Test plan for Automation testing. After that, we select the Test cases for Automation. Once the test cases are selected we prepare the test data and if required configure the QTP according to our requirements.

2) Generating Tests/scripts and Enhancing Tests
The next step is Generating the Tests/Scripts (scripts are called tests in automation testing, Will be using Test henceforth). Tests can be prepared either by recording (mostly not recommended) or by scripting using VBScript, QTP supports only VB scripting. In Generation of Tests itself, we will create Object Repository and add the required object to it. We use descriptive programming (will discuss about Descriptive programming in detail in my later post) when required. 
   Once the generation of Tests is done, the next step is to enhance the test. While Enhancing the test we insert checkpoints, output Values, add comments to the steps, and insert Synchronization, Parametrization and calling the Actions (Reusable) and functions.

 3) Debugging Tests
 After enhancing the tests, we debug the test to check its efficiency. Here we use multiple debugging options like breakpoints, watch, debug Viewer (debugging comments present in QTP).  

 4) Running Tests
 These tests are finally executed using several modes: Normal Execution, Batch Execution, executing tests from framework. 

 5) Analyzing Results
 After the Test execution, QTP automatically opens the result Window. Here we filter the results (depending what is required whether we need only the passed and Failed results or etc), Export the results to Shared folder where everyone can have access.

6) Reporting Defects
 If we find any defects after the execution of our Tests, the next step in QTP process is to report the defects. We can report manually or we can even mail our results directly to the concerned person. On the other hand, we can also log the defects directly in Quality Center Tool.

Friday, August 26, 2011

INTRODUCTION TO QTP

Quick Test Professional is a functional and regression test automation software tool developed by Mercury Interactive. Currently owned by HP and commonly known as HP Quick test professional.
  QTP is a Record and playback tool(recording not preferred always) as well as Programmatic tool which uses VbScripting for scripting. QTP Supports technologies depending upon the Version of the tool, Web, Java, .Net, SAP, Oracle, Siebel, PeopleSoft, Delphi, Power Builder, Flex, Sliver light.
QTP is a licensed tool it comes with a trail version.
Latest QTP version is 11.0 - Released in 2010.

Advantages of QTP

1. Ease of use.

2. Use of VBScript, which makes QTP significantly easier for a non-programmer person to understand and create Test case / scripts.

3. Object identification mechanism is better.

4. Technology support is good. The supported technologies, depending on the QTP version, are available for Web, Java(Core and Advanced), .Net, WPF, SAP, Oracle, Siebel, PeopleSoft, Delphi, Power Builder, Stingray 1, Terminal Emulator, Flex, Web Services, Windows Mobile, VisualAge Smalltalk, Silverlight and mainframe terminal emulators.

5. Various Parameterization types in QTP, which ease the test cases for the same operations with multiple sets of data.

6. QTP Supports Framework like modular, Keyword, data driven and Hybrid.

7. Handling Dynamic objects are possible with use of Descriptive programming.

8. QTP Reports are clear and easily understand.
 
Disadvantages or drawbacks of QTP

1. QTP works only on Windows OS thereby becoming Platform dependent tool.

2. Poor support for cross browser testing. Supports only IE and little version of Firefox.

3. License and maintenance cost is high.


4. QTP consumes more memory.

5. In QTP you cannot work on multiple scripts at a time like in winrunner.


6. CPU utilization is more in QTP.

Major Topics in QTP:

-Testing Process

-Object and Object Repositories

-QTP Recording

-Actions

-Parameterization

-Check Points

-VB Scripting

-Descriptive Programming

-Synchronization

-File system Objects

-Frameworks

Will be explaining each topics in my upcoming posts.