Showing posts with label qucik test professional. Show all posts
Showing posts with label qucik test professional. Show all posts

Friday, September 9, 2011

Recovery Scenario Manager in QTP

Recovery scenario manager is used to handle unexpected events/errors during the execution of QTP script.
This is the general definition which we are seeing for a long time. But the question that arises is when should we use Recovery scenario manager and when not? And why is recovery scenario manager not used for all the events that gets raised while QTP execution?
Recovery scenarios are used only when the event occurrence is not predictable. That is if we are not sure at what place the event may get raised, then we go for recovery scenarios. If the event occurrence is predictable, then it is always recommended to use programmatic handling by using statements such as IF conditions or On error resume next. Because using Recovery scenario manager will slower down the performance of QTP. 

For example, assume that Ads are getting raised when Application is opened in a browser or while accessing the application. Assume that sometimes they get raised immediately as soon as you open a browser and sometimes they get raised only after you are accessing something on the page. And also assume that you are not able to predict how many ads get displayed. In such situations we go for Recovery Scenarios. 

One of the other best example and common example is Printer out of Paper example. It is not possible to predict at what time Network would return the printer error. Hence Recovery scenario is used in this example because by the time the printer error message gets raised QTP might have progressed several steps before the error is displayed.
Some of the examples where we don’t go for Recovery scenarios:

The dialog box that gets prompted for remembering the password. This can be handled using If statements.

The dialog box that gets raised to overwrite the existing file during the process of saving a file.
How to create a Recovery Scenario:
Select Recovery Scenario Manager from Resources>>Recovery Scenario Manager.
Click on New to create a new Recovery Scenario and it takes the user to ‘Recovery Scenario Wizard’.
Recovery Scenario involves following steps: 

1. Define the trigger event that interrupts the test run 

Define the trigger event that interrupts the test run such as Popup window, QTP error or Application error.
2. Specify the recovery operation(s) required to continue
Specify the recovery operations that need to be performed on the trigger event such as closing the Popup through keyboard operation/mouse operation, closing the application, Calling a function or restarting windows.





3. Choose a post-recovery test run operation
Instructing QTP what should be done after performing the recovery operations on Triggered event. For example like re-executing the same step in the test or moving to next step in the test or moving to the next test or close the execution of qtp script etc.,



4. Specify a name and description for the recovery scenario
Specify the name and description for the recover scenario.






5.Specify whether to associate the recovery scenario to the current test and/or to all new tests
Specify whether to add the recovery scenario to current test or make it a default to all the new tests that are created here after.



Reference: Quick Test User guide - Defining Recovery Scenarios

Wednesday, July 20, 2011

Object Identification in QTP

QTP identifies each object uniquely based on the properties that are configured in Object identification window. When QTP is installed on a machine, it comes along with some basic properties configured basing on which QTP can identify some of the objects while recording and playback.
However, when it comes to AUT recording, there might be lot of cases where QTP can’t identify an object uniquely based on the properties that are mentioned in Object identification. In such cases while the script is played back, QTP stops execution and throws an error. To overcome this, object identification properties has to be configured.
There are so many properties for every object defined by default in QTP for identifying. Some of them are:
Class, name, disabled, default value, max length, value, abs_x, abs_y, height, width, innerhtml, innertext, outerhtml, outertext, htmlid, htmltag, href and so on. User can use the same properties or add some new properties through Object identification screen.
There are three types of identification methods in QTP:
1. Normal Identification
2. Smart Identification
3. Ordinal Identifier
1. Normal Identification
This is in turn divided into two sections:

a. Mandatory Properties
b. Assistive Properties

a. Mandatory Properties:

Open Object identification window from TOOLS>Objection identification.And then select the environment of the application whether it is windows, ActiveX or web. For example let us assume that the environment is WEB. As soon as the environment is selected, QTP displays list of objects in the left side of the menu. Select an object.

Now it is observed that right side of the window displays Mandatory properties section and Assistive properties section. Observe the properties that are mentioned in Mandatory properties section. Those are the properties that are set by default while QTP is installed. QTP identifies each and every object while recording/execution based on the properties that are mentioned here.
To edit the existing in the list, click on Add/remove button.


Select the property that you want to add by clicking on the checkbox. And for removing just uncheck the checkbox. If you want to add a new property for the selected object which does not exist in the property list, then just click on ‘New’ button available there and enter the name in the edit box.



Select the basic properties basing on which QTP can easily differentiate the difference between two objects in mandatory section (for example like class, name).

b. Assistive Properties
If QTP is not able to identify an object uniquely based on the properties mentioned in Mandatory, then it comes to Assistive and verifies whether any properties are configured in it or not. If there are any properties configured in Assistive properties section, then QTP stores those properties also while recording an object and uses the same while execution. Configuring of properties in Assistive section is similar to configuration of Mandatory section.

Note 1: If QTP is able to identify an object uniquely based on the properties mentioned in Mandatory, then it doesn’t come to assistive or remaining properties.
Note 2: If QTP is not able to identify an object uniquely based on the properties mentioned in Mandatory and if there are no properties configured in Assistive section, then QTP just ignores assistive section and moves to Smart Identification/Ordinal identifier to verify whether they are configured or not!!!
Note 3: QTP will not allow to choose the same property in Mandatory and Assistive section.

2. Smart Identification:

Smart Identification is again in turn divided into two types


a. Base filter properties
b. Optional filter properties
When QTP is not able to identify an object uniquely based on the properties mentioned in Normal identification (Mandatory/Assistive) then QTP comes to Smart Identification.
Smart Identification is not enabled by default. To enable Smart identification click on checkbox available in the right side of the window under Normal identification.
After the checkbox is checked, then the configure button gets enabled. Clicking on configure icon will take the user to Base filter and Optional filter section.
a. Base filter properties:
If QTP is unable to identify an object uniquely based on the properties mentioned in Mandatory and Assistive (if configured), then it comes to smart identification Base filter properties section. Configuring the base filter properties is just similar to configuring the Mandatory/assistive properties section. Add the properties using Add/Remove button.
b. Optional filter properties:
If QTP is unable to identify an object uniquely based on the properties mentioned in Mandatory, Assistive and Base filter properties, then it comes to Optional filter properties. Configuring is same just like others. Add the properties using Add/Remove button.
Note 1: QTP will allow adding the same property that is mentioned in Mandatory/Assistive section. But it is just wasting the memory again by duplicating the property addition.
Note 2: QTP will not allow adding the same property in both Base filter and optional filter sections.
Note 3: QTP will come to Smart identification only if it is unable to identify an Object with the properties mentioned in Mandatory and Assistive
Note 4: QTP will come to Smart identification only when Smart identification check box is checked.
Note 5: QTP will not display the list of properties that are mentioned in smart identification in Object repository unlike Normal identification. It just displays Smart identification as ‘True’ if it is configured. See the following window:
The properties getting displayed under ‘Description properties’ are those properties which are
configured in Normal Identification. If Smart identification process is enabled, then the value for
that is displayed as ‘True’.



3. Ordinal Identifier:

There are three types of Ordinal Identifiers in QTP:

a. Index
b. Location
c. Creation time

If QTP is unable to identify an object uniquely based on the properties mentioned in Normal and Smart identification sections, then it goes to Ordinal Identifier section

a. Index:
QTP assigns a value while recording to each and every object from source code. Assigning values is object-specific. That is if there are 5 edit boxes, 6 radio buttons and 7 check boxes in the source code of the page, then indexing will be separate for edit boxes, radio buttons and checkboxes. And indexing count starts from 0. That is in the above example firs edit box in the source code will have an index 0 and last edit box in source code will have an index 4.
b. Location:

QTP assigns a value while recording based on the location of object for unique identification. Assigning the values is Object specific. The value is based on the order, in which the object appears within the window, frame, or dialog box, in relation to other objects with identical properties. Values are assigned in columns from top to bottom, and left to right. Location count will start from 0. That is the first object in the window will have a location value 0.
See the below example to understand the values assignment to the objects.

c. Creation Time:
Creation time identifier is specific to Browser objects only. QTP assigns a value while recording based on Creation Time object property. This identifier is useful when there are multiple browsers with similar objects. QTP identifies the session start time and assigns a vale to it. Creation time value count starts with 0. For example when there are three browsers opened, then the browser that is opened initially will be assigned 0 and the browser that is opened last will have a value 2 assigned.
The question that gets raised here is, why not all the properties are selected in the same section?
All the properties can also be selected in the same section. But the negative results of this will be, every time when QTP records an object it records and stores the information of all the properties that are mentioned in mandatory as a result of which there would be more memory utilization. And while execution also QTP will verify all the properties that are stored which will result in time delay while execution.
Reference: Quick test Users guide - Configuring Object Identification