Are you looking for job change in software testing/QA or interested in learning HP QTP from an ideal trainers ? your search will come to an end with www.testleaf.com - The Chennai's best test automation workshops. contact 9500006373 for more details.

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.