Working
with Test Object and object repositories:
Working with
test objects and object repository
Here I
am reproducing one of the most important extract from QTP help section. If you
understand this part be assured you of your success in QTP Job interviews,
other question that follow will be of very elementary nature.
When Quick Test uses the learned description to identify an object, it searches for an object that matches all of the property values in the description. In most cases, this description is the simplest way to identify the object, and, unless the main properties of the object change, this method will work.
If Quick Test is unable to find any object that matches the learned object description, or if it finds more than one object that fits the description, then QuickTest ignores the learned description, and uses the Smart Identification mechanism to try to identify the object.
While the Smart Identification mechanism is more complex, it is more flexible. Therefore, if configured logically, a Smart Identification definition can probably help QuickTest identify an object, if it is present, even when the learned description fails.
The Smart Identification mechanism uses two types of properties:
· Base Filter Properties—The most fundamental properties of a particular test object class; those whose values cannot be changed without changing the essence of the original object. For example, if a Web link's tag was changed from {A} to any other value, you could no longer call it the same object.
· Optional Filter Properties—Other properties that can help identify objects of a particular class. These properties are unlikely to change on a regular basis, but can be ignored if they are no longer applicable.
Understanding the Smart Identification Process
If QuickTest activates the Smart Identification mechanism during a run session (because it was unable to identify an object based on its learned description), it follows the following process to identify the object:
1. QuickTest "forgets" the learned test object description and creates a new object candidate list containing the objects (within the object's parent object) that match all of the properties defined in the Base Filter Properties list.
2. QuickTest filters out any object in the object candidate list that does not match the first property listed in the Optional Filter Properties list. The remaining objects become the new object candidate list.
3. QuickTest evaluates the new object candidate list:
o If the new object candidate list still has more than one object, QuickTest uses the new (smaller) object candidate list to repeat step 2 for the next optional filter property in the list.
o If the new object candidate list is empty, QuickTest ignores this optional filter property, returns to the previous object candidate list, and repeats step 2 for the next optional filter property in the list.
o If the object candidate list contains exactly one object, then QuickTest concludes that it has identified the object and performs the statement containing the object.
4. QuickTest continues the process described in steps 2 and 3 until it either identifies one object, or runs out of optional filter properties to use.
If, after completing the Smart Identification elimination process, QuickTest still cannot identify the object, then QuickTest uses the learned description plus the ordinal identifier to identify the object.
If the combined learned description and ordinal identifier are not sufficient to identify the object, then QuickTest stops the run session and displays a Run Error message.
Reviewing Smart Identification Information in the Test Results
If the learned description does not enable QuickTest to identify a specified object in a step, and a Smart Identification definition is defined (and enabled) for the object, then QuickTest tries to identify the object using the Smart Identification mechanism.
If QuickTest successfully uses Smart Identification to find an object after no object matches the learned description, the Test Results receive a warning status and indicate that the Smart Identification mechanism was used.
If the Smart Identification mechanism cannot successfully identify the object, QuickTest uses the learned description plus the ordinal identifier to identify the object. If the object is still not identified, the test or component fails and a normal failed step is displayed in the results.
Walking Through a Smart Identification Example
The following example walks you through the object identification process for an object.
Suppose you have the following statement in your test or component:
Browser("Mercury Tours").Page("Mercury Tours").Image("Login").Click 22,17
When you created your test or component, QuickTest learned the following object description for the Login image:
When Quick Test uses the learned description to identify an object, it searches for an object that matches all of the property values in the description. In most cases, this description is the simplest way to identify the object, and, unless the main properties of the object change, this method will work.
If Quick Test is unable to find any object that matches the learned object description, or if it finds more than one object that fits the description, then QuickTest ignores the learned description, and uses the Smart Identification mechanism to try to identify the object.
While the Smart Identification mechanism is more complex, it is more flexible. Therefore, if configured logically, a Smart Identification definition can probably help QuickTest identify an object, if it is present, even when the learned description fails.
The Smart Identification mechanism uses two types of properties:
· Base Filter Properties—The most fundamental properties of a particular test object class; those whose values cannot be changed without changing the essence of the original object. For example, if a Web link's tag was changed from {A} to any other value, you could no longer call it the same object.
· Optional Filter Properties—Other properties that can help identify objects of a particular class. These properties are unlikely to change on a regular basis, but can be ignored if they are no longer applicable.
Understanding the Smart Identification Process
If QuickTest activates the Smart Identification mechanism during a run session (because it was unable to identify an object based on its learned description), it follows the following process to identify the object:
1. QuickTest "forgets" the learned test object description and creates a new object candidate list containing the objects (within the object's parent object) that match all of the properties defined in the Base Filter Properties list.
2. QuickTest filters out any object in the object candidate list that does not match the first property listed in the Optional Filter Properties list. The remaining objects become the new object candidate list.
3. QuickTest evaluates the new object candidate list:
o If the new object candidate list still has more than one object, QuickTest uses the new (smaller) object candidate list to repeat step 2 for the next optional filter property in the list.
o If the new object candidate list is empty, QuickTest ignores this optional filter property, returns to the previous object candidate list, and repeats step 2 for the next optional filter property in the list.
o If the object candidate list contains exactly one object, then QuickTest concludes that it has identified the object and performs the statement containing the object.
4. QuickTest continues the process described in steps 2 and 3 until it either identifies one object, or runs out of optional filter properties to use.
If, after completing the Smart Identification elimination process, QuickTest still cannot identify the object, then QuickTest uses the learned description plus the ordinal identifier to identify the object.
If the combined learned description and ordinal identifier are not sufficient to identify the object, then QuickTest stops the run session and displays a Run Error message.
Reviewing Smart Identification Information in the Test Results
If the learned description does not enable QuickTest to identify a specified object in a step, and a Smart Identification definition is defined (and enabled) for the object, then QuickTest tries to identify the object using the Smart Identification mechanism.
If QuickTest successfully uses Smart Identification to find an object after no object matches the learned description, the Test Results receive a warning status and indicate that the Smart Identification mechanism was used.
If the Smart Identification mechanism cannot successfully identify the object, QuickTest uses the learned description plus the ordinal identifier to identify the object. If the object is still not identified, the test or component fails and a normal failed step is displayed in the results.
Walking Through a Smart Identification Example
The following example walks you through the object identification process for an object.
Suppose you have the following statement in your test or component:
Browser("Mercury Tours").Page("Mercury Tours").Image("Login").Click 22,17
When you created your test or component, QuickTest learned the following object description for the Login image:
However, at some point after you created your test or component, a second login button (for logging into the VIP section of the Web site) was added to the page, so the Web designer changed the original Login button's alt tag to: basic login.
The default description for Web Image objects (alt, html tag, image type) works for most images in your site, but it no longer works for the Login image, because that image's alt property no longer matches the learned description. Therefore, when you run your test or component, QuickTest is unable to identify the Login button based on the learned description. However, QuickTest succeeds in identifying the Login button using its Smart Identification definition.
The explanation below describes the process that QuickTest uses to find the Login object using Smart Identification:
1. According to the Smart Identification definition for Web image objects, QuickTest learned the values of the following properties when you recorded the click on the Login image:
2. QuickTest begins the Smart Identification process by identifying the five objects on the Mercury Tours page that match the base filter properties definition (html tag = INPUT and image type = Image Button). QuickTest considers these to be the object candidates and begins checking the object candidates against the Optional Filter Properties list.
3. QuickTest checks the alt property of each of the object candidates, but none have the alt value: Login, so QuickTest ignores this property and moves on to the next one.
4. QuickTest checks the name property of each of the object candidates, and finds that two of the objects (both the basic and VIP Login buttons) have the name: login. QuickTest filters out the other three objects from the list, and these two login buttons become the new object candidates.
5. QuickTest checks the file name property of the two remaining object candidates. Only one of them has the file name login.gif, so QuickTest correctly concludes that it has found the Login button and clicks it.
Step-by-Step Instructions for Configuring a Smart Identification Definition
You use the Smart Identification Properties dialog box, accessible from the Object Identification dialog box, to configure the Smart Identification definition for a test object class.
To configure Smart Identification properties:
1. Choose Tools > Object Identification. The Object Identification dialog box opens.
Note: The environments included in the Environment list are those that correspond to the loaded add-in environments.
3. Select the test object class you want to configure.
4. Click the Configure button next to the Enable Smart Identification check box. The Configure button is enabled only when the Enable Smart Identification option is selected. The Smart Identification Properties dialog box opens:
5. In the Base Filter Properties list, click Add/Remove. The Add/Remove Properties dialog box for base filter properties opens.
6. Select the properties you want to include in the Base Filter Properties list and/or clear the properties you want to remove from the list.
Note: You cannot include the same property in both the base and optional property lists.
You can specify a new property by clicking New and specifying a valid property name in the displayed dialog box.
Tip: You can also add property names to the set of available properties for Web objects using the attribute/ notation. To do this, click New. The New Property dialog box opens. Enter a valid property in the format attribute/ and click OK. The new property is added to the Base Filter Properties list. For example, to add a property called MyColor, enter attribute/MyColor.
7. Click OK to close the Add/Remove Properties dialog box. The updated set of base filter properties is displayed in the Base Filter Properties list.
8. In the Optional Filter Properties list, click Add/Remove. The Add/Remove Properties dialog box for optional filter properties opens.
9. Select the properties you want to include in the Optional Filter Properties list and/or clear the properties you want to remove from the list.
Note: You cannot include the same property in both the base and optional property lists.
You can specify a new property by clicking New and specifying a valid property name in the displayed dialog box.
Tip: You can also add property names to the set of available properties for Web objects using the attribute/ notation. To do this, click New. The New Property dialog box opens. Enter a valid property in the format attribute/ and click OK. The new property is added to the Optional Filter Properties list. For example, to add a property called MyColor, enter attribute/MyColor.
10. Click OK to close the Add/Remove Properties dialog box. The properties are displayed in the Optional Filter Properties list.
Working
with Test objects
Test
Object Model Conceptualization
Applying the Test Object Model Concept
Viewing Object properties Using Object Spy
Demo on Test Object Model features of QTP
Mandatory properties:
For each Test Object class, Quick Test has list of mandatory properties…
Assistive properties:
Quick Test adds assistive properties one by one to the description until it has compiled a unique description…
Ordinal identifier:
If the combination of all defined mandatory and assistive properties is not sufficient to create a unique test object description, Quickest also records the value for the selected ordinal identifier.
Smart Identification:
A Smart Identification definition can help QuickTest identify an object, if it is present, even when the recorded description fails due to changes in one or more property values.
Test Object Model
How Quick Test Identifies objects during the test run?
Quick test searches for a run time object that exactly matches the description of the test object from the object repository it learned while recording…
Test Object :
Test Object is an object that Quick Test creates in the test to represent the actual object in the application…
Run Time Object :
It is the actual object in the web site or application on which methods are performed during the test run..
Test Object Model
Viewing object properties by Object Spy :
Using the object spy, users can view the properties of any object in an open application…
Viewing object methods and methods syntax using object spy…
Object Spy enables users to view both the run time object methods, the test object methods associated with an object and to view the syntax for a selected method…
Managing Test objects
Object Repository Dialog box :
- Per Action Mode
- Shared Action Mode
Managing Test objects
Identifying the Object :
- Logical Name
- Class
Viewing the Objects Property :
Type - Constant, Data table property ,variable parameter.
Property - Name of the Property
Value - The value of the property
- Smart Identifier
- Add/ Remove
Adding or Viewing New objects :
- Add New Objects
- Object spy
- Saves all the object properties and values from a per action object repository to a separate file for use as a shared object repository in another test…
- Modify the Test object properties
- Finding the Test object properties
- Modifying the Logical Names
Object Properties Modification
Users can modify the properties of the temporary version of the object during the test run with out affecting the permanent values in the object repository
- SetTOProperty
- GetTOProperty
Main phases of QTP testing Process
Preparing to record
Recording a session on the application
Executing the test
Enhancing your test
Debugging your test
Re-executing the tests on a new version of the application
Analyzing the test results
Reporting defects
Types of Checkpoints (Verification Process)
Parameterising Tests
Different Types of Parameters
Test & Action Parameters
Data Table
Environment Variable
Defining a Data Table Parameter
Adding Parameter Values to a Data Table
Modifying Steps Affected by Parameterization
Running and Analyzing a Parameterized Test
Creating Output Values
Creating an Output Value
Running and Analyzing a Test with Output Values
Using Regular Expressions
Regular Expression Syntax
Working with Regular Expressions
Running and Analyzing a Test with Regular Expressions
Dividing Tests into Multiple Actions
Working with Multiple Actions
Creating New Actions
Inserting Existing Actions
Parameterizing an Action
Running and Analyzing a Multi-action Test
Different Types of Actions
Recovery Scenarios
Defining Recovery Scenarios
Creating a Recovery File
Understanding the Recovery Scenario Manager Dialog Box
Understanding the Recovery Scenario Wizard
Welcome to the Recovery Scenario Wizard Screen
Select Trigger Event Screen
Specify Pop-up Window Conditions Screen
Select Object Screen
Set Object Properties and Values Screen
Select Test Run Error Screen
Select Processes Screen
Recovery Operations Screen
Recovery Operation Screen
Recovery Operation – Click Button or Press Key Screen
Recovery Operation – Close Processes Screen
Recovery Operation – Function Call Screen
Post-Recovery Test Run Options Screen
Name and Description Screen
Completing the Recovery Scenario Wizard Screen
Saving the Recovery Scenario in a Recovery File
Managing Recovery Scenarios
Applying the Test Object Model Concept
Viewing Object properties Using Object Spy
Demo on Test Object Model features of QTP
Mandatory properties:
For each Test Object class, Quick Test has list of mandatory properties…
Assistive properties:
Quick Test adds assistive properties one by one to the description until it has compiled a unique description…
Ordinal identifier:
If the combination of all defined mandatory and assistive properties is not sufficient to create a unique test object description, Quickest also records the value for the selected ordinal identifier.
Smart Identification:
A Smart Identification definition can help QuickTest identify an object, if it is present, even when the recorded description fails due to changes in one or more property values.
Test Object Model
How Quick Test Identifies objects during the test run?
Quick test searches for a run time object that exactly matches the description of the test object from the object repository it learned while recording…
Test Object :
Test Object is an object that Quick Test creates in the test to represent the actual object in the application…
Run Time Object :
It is the actual object in the web site or application on which methods are performed during the test run..
Test Object Model
Viewing object properties by Object Spy :
Using the object spy, users can view the properties of any object in an open application…
Viewing object methods and methods syntax using object spy…
Object Spy enables users to view both the run time object methods, the test object methods associated with an object and to view the syntax for a selected method…
Managing Test objects
Object Repository Dialog box :
- Per Action Mode
- Shared Action Mode
Managing Test objects
Identifying the Object :
- Logical Name
- Class
Viewing the Objects Property :
Type - Constant, Data table property ,variable parameter.
Property - Name of the Property
Value - The value of the property
- Smart Identifier
- Add/ Remove
Adding or Viewing New objects :
- Add New Objects
- Object spy
- Saves all the object properties and values from a per action object repository to a separate file for use as a shared object repository in another test…
- Modify the Test object properties
- Finding the Test object properties
- Modifying the Logical Names
Object Properties Modification
Users can modify the properties of the temporary version of the object during the test run with out affecting the permanent values in the object repository
- SetTOProperty
- GetTOProperty
Main phases of QTP testing Process
Preparing to record
Recording a session on the application
Executing the test
Enhancing your test
Debugging your test
Re-executing the tests on a new version of the application
Analyzing the test results
Reporting defects
Types of Checkpoints (Verification Process)
Parameterising Tests
Different Types of Parameters
Test & Action Parameters
Data Table
Environment Variable
Defining a Data Table Parameter
Adding Parameter Values to a Data Table
Modifying Steps Affected by Parameterization
Running and Analyzing a Parameterized Test
Creating Output Values
Creating an Output Value
Running and Analyzing a Test with Output Values
Using Regular Expressions
Regular Expression Syntax
Working with Regular Expressions
Running and Analyzing a Test with Regular Expressions
Dividing Tests into Multiple Actions
Working with Multiple Actions
Creating New Actions
Inserting Existing Actions
Parameterizing an Action
Running and Analyzing a Multi-action Test
Different Types of Actions
Recovery Scenarios
Defining Recovery Scenarios
Creating a Recovery File
Understanding the Recovery Scenario Manager Dialog Box
Understanding the Recovery Scenario Wizard
Welcome to the Recovery Scenario Wizard Screen
Select Trigger Event Screen
Specify Pop-up Window Conditions Screen
Select Object Screen
Set Object Properties and Values Screen
Select Test Run Error Screen
Select Processes Screen
Recovery Operations Screen
Recovery Operation Screen
Recovery Operation – Click Button or Press Key Screen
Recovery Operation – Close Processes Screen
Recovery Operation – Function Call Screen
Post-Recovery Test Run Options Screen
Name and Description Screen
Completing the Recovery Scenario Wizard Screen
Saving the Recovery Scenario in a Recovery File
Managing Recovery Scenarios
Working with functional test object maps
This
section describes how you can use test object maps to facilitate your
functional testing effort. The test object map is a static view that describes
the known test objects in the application-under-test.
- Test
object maps
The Functional Tester test object map lists the test objects in the application-under-test. It is a static view that describes test objects known to Functional Tester in the application-under-test. - Creating
and using a test object map to test applications
You create a test object map, refine it to more accurately describe the application, and share the map with other scripts you create to test the application. - Creating
a new test object map
You can create a customized, shared test object map that you can associate with scripts. - Merging
multiple test object maps
You use the Merge Test Objects into the Test Object Map page to merge multiple private or shared test object maps into a single map. - Adding
objects to a test object map
When you add an object to a test object map, you can choose to add just the selected object, include the children of the immediate parent, or include all the visible controls in the current window. - Using
ClearCase with test object maps
You can use ClearCase® with shared test object maps and to merge scripts across branches. - New test
objects in an object map
After recording, Functional Tester may automatically display the test object map. This occurs by default if new test objects were added to an existing map. You can turn this on or off in the Recorder page by selecting or clearing the Bring up object map if there is new test objectbox. - Adding a
test object to an object map and a script
Functional Tester enables you to add a test object to an object map and a script at the same time. - Editing
object properties
You can edit information in the property sets in the lower (or right) pane of the test object map window. - Displaying
associated scripts
You can list scripts associated with a test object map. You can use the list to select multiple scripts that you want to add test objects to. - Renewing
a name in associated script(s)
You can change a vague test object name to a more meaningful name. Functional Test updates the name in associated scripts from the test object map. - Renewing
all names in associated script(s)
You can change vague test object names to more meaningful names. Functional Tester updates the names in associated scripts from the test object map. - Adding
test objects to a script
You use the test object map to include an object in one or more scripts. As part of the procedure, Functional Tester displays a list of possible methods for the object and you can choose the one you want to use for the test object. - Adding
test object descriptions
You can enter descriptive text about an object that Functional Tester adds to the Administrative property set tab for the object. Functional Tester also displays the description when you place the cursor over the object name in a script. - Editing
test object descriptions
You can customize the text for test objects displayed in the hierarchy tree of the test object map. - Deleting
test objects from an object map
When you delete a test object from an object map, Functional Tester removes all references to the object. - Unifying
two test objects
If an object in the application-under-test changes, a test object map may have two map objects that describe the same object. You can combine these objects into a single map object. When you unify two objects, Functional Test updates scripts. - Maintaining
a test object map
To maintain a test object map, you update it to reflect new versions of the application by accepting new objects on the map, unifying test objects that are similar, and deleting any obsolete test objects. - Renaming
a test asset
You can rename a Functional Tester script, test object map, or other files in a project. - Updating
recognition properties
You can update recognition properties for a test object in the application-under-test. - Deleting
a test object map
Deleting a test object map invalidates any scripts associated with the map, making them unusable. Deleting a test object map cannot be undone. - Locating
a test object in the application
You can select an object in the test object map or the Script Explorer and have Functional Tester highlight the object in the application-under-test. - Searching
for objects in a test object map
To search for test objects in a test object map, you can use a property, a value, or either. There are two ways to search for objects in a test object map: Quick Find and Find by Filters. - Regular
expressions
You can replace a recognition property with a regular expression or a numeric range to allow for a pattern-based recognition. The pattern allows for more flexibility in the object recognition. You can convert properties to regular expressions and numeric ranges from within the Verification Point Editor or the object map. - Object
library
Use the object library to configure object recognition properties and property weights.
Object
Spy:
Object spy is the very much important tool in qtp. With the use of Object spy we can learn basic structure of
test object. The main advantage
of object spy is that we can see object structure of specific object in tree view. So that makes testobject more understandable and easier.
In addition to this we can view the run-time and test object properties and methods of any object in open application.
Now let’s understand and use object spy practically.
How to use Object spy in qtp?
1. Go to Tools->Object spy.
2. One window named Object Spy will open
3. Then open the application whose object properties or methods you want to see.
4. Then just click on “Pointer image” of object spy window.
5. Click on Object whose object properties or methods you want to see.
Above figure is window of object spy. I have used “object Spy” tool on “google.com” logo “Google’. QTP recognize this logo "Google" as image. Using Object spy you can view two things one is properties of specific object and second is methodsapplicable for that object.
Use of Object spy:
- You can view different object properties of selected objects.
- Let’s see some example, you can know file name of image see in fig. “logo.gif”
- You can see link of the image like “http://www.google.com/intl/en_ALL/images/logo.gif” so in short you can view all objectproperties of objects.
- You can view different methods applicable for this object using that you can access object. Like capturebitmap, click, GetROproperty, exist, drag and drop etc.
- You can also understand the basic structure of object using which QTP identifies specific object. Refer above figure for image object’s structure understanding. You can see upper part in figure, first parent object is Browser second is page and third is image. So this is how QTP writes following sentence to identify this image object.
Browser("Google").Page("Google").Image("Google").Click
In above sentence you can see one object method named “click” that you observed in object spy.
So I hope now you are clear how QTP understand the object.
You are always welcome to share your feedback on this post "object spy in QTP".
In addition to this we can view the run-time and test object properties and methods of any object in open application.
Now let’s understand and use object spy practically.
How to use Object spy in qtp?
1. Go to Tools->Object spy.
2. One window named Object Spy will open
3. Then open the application whose object properties or methods you want to see.
4. Then just click on “Pointer image” of object spy window.
5. Click on Object whose object properties or methods you want to see.
Above figure is window of object spy. I have used “object Spy” tool on “google.com” logo “Google’. QTP recognize this logo "Google" as image. Using Object spy you can view two things one is properties of specific object and second is methodsapplicable for that object.
Use of Object spy:
- You can view different object properties of selected objects.
- Let’s see some example, you can know file name of image see in fig. “logo.gif”
- You can see link of the image like “http://www.google.com/intl/en_ALL/images/logo.gif” so in short you can view all objectproperties of objects.
- You can view different methods applicable for this object using that you can access object. Like capturebitmap, click, GetROproperty, exist, drag and drop etc.
- You can also understand the basic structure of object using which QTP identifies specific object. Refer above figure for image object’s structure understanding. You can see upper part in figure, first parent object is Browser second is page and third is image. So this is how QTP writes following sentence to identify this image object.
Browser("Google").Page("Google").Image("Google").Click
In above sentence you can see one object method named “click” that you observed in object spy.
So I hope now you are clear how QTP understand the object.
You are always welcome to share your feedback on this post "object spy in QTP".
Object Spy Dialog window is having Two Tabs. One is "Properties
Tab" and another is "Methods Tab".
Each tab is having radio button to chose one of two options "Run-Time Object" and "Test Object".
The Object Spy displays the selected object’s hierarchy tree and its properties and values in the Properties tab of the Object Spy Dialog box.
The Object Spy enables you to view both the run-time object methods and the test object methods associated with an object in the Methods tab of the Object Spy dialog box.
And, we can to view the syntax for a selected method.
We can bring the "Object Spy" by clicking the Tools->Object Spy... menu or by clicking a toolbar button (an icon showing a person with hat). This icon can be accessed from Object Repository window also.
To see the properties of an object, first click on the button showing hand symbol in the Object spy Dialog.
The mouse pointer now changes in to a hand symbol and we have to point out the object to spy the details about the object.
If the required object is not visible, or window is minimized then hold the Ctrl Key and activate the required window to bring the required window to the front.
Then release the Ctrl button to make the cursor again hands symbol so that you can point the required object.
Object Identification Configuration
Each tab is having radio button to chose one of two options "Run-Time Object" and "Test Object".
The Object Spy displays the selected object’s hierarchy tree and its properties and values in the Properties tab of the Object Spy Dialog box.
The Object Spy enables you to view both the run-time object methods and the test object methods associated with an object in the Methods tab of the Object Spy dialog box.
And, we can to view the syntax for a selected method.
We can bring the "Object Spy" by clicking the Tools->Object Spy... menu or by clicking a toolbar button (an icon showing a person with hat). This icon can be accessed from Object Repository window also.
To see the properties of an object, first click on the button showing hand symbol in the Object spy Dialog.
The mouse pointer now changes in to a hand symbol and we have to point out the object to spy the details about the object.
If the required object is not visible, or window is minimized then hold the Ctrl Key and activate the required window to bring the required window to the front.
Then release the Ctrl button to make the cursor again hands symbol so that you can point the required object.
Object Identification Configuration
Overview:
Generally for every object 20-25 properties information available, qtp recognizesobject 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
Object Identification Types
a) Normal identification
1) Mandatory properties
2) Assistive properties
b) Smart identification
1) base filter properties
2) optional filter properties
c) Ordinal identifier
Generally for every object 20-25 properties information available, qtp recognizesobject 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
Object Identification Types
a) Normal identification
1) Mandatory properties
2) Assistive properties
b) Smart identification
1) base filter properties
2) optional filter properties
c) Ordinal identifier
1) location
2) index
3) creation time(only for web)
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 thatobject, 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
2) index
3) creation time(only for web)
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 thatobject, 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
3) Creation time: it is based on loading time of the web
objects. qtp generates 0,1,2 like numbers.
Tool Settings Globalization:
As QTP is a I-tier(Stand-alone) application,making Tool settings globally is not possible.
For making tool settings global, QTP is providing a special feature called "Generate Script".
STEPS:
1) Settings available in 3 areas.
a) File->Settings
b) Tools->Options
c) Tools->Object Identification
2) Perform required settings and generate Scripts
3) Share Script files to team members and ask them to execute those scripts.
Tool Settings Globalization:
As QTP is a I-tier(Stand-alone) application,making Tool settings globally is not possible.
For making tool settings global, QTP is providing a special feature called "Generate Script".
STEPS:
1) Settings available in 3 areas.
a) File->Settings
b) Tools->Options
c) Tools->Object Identification
2) Perform required settings and generate Scripts
3) Share Script files to team members and ask them to execute those scripts.
Smart
identification:
Smart Identificaton is applicable for web application only.
Record one object from application and modify the object property and execute
your script. You will get one worning message in result. Navigate to working
message in result file and read the note for smart identification.
Smart Identification is nothing but, if any property of
test object is not matching with run time object property, it will write an
worning to result and execute rest of the steps.
Note: In the result Cap symbol will added for smart
identification. (By looking in to this we can say that properties of test
object is not matching with run-time object)
Creating
and managing object repositories
Managing
Object Repositories Using Object Repository Manager
Object Repository Manager
The Object Repository Manager enables you to manage all of the shared object repositories used in your organization from a single, central location, including adding and defining objects, modifying objects and their descriptions, parameterizing repositories to make them more generic, maintaining and organizing repositories, merging repositories, and importing and exporting repositories in XML format.
Navigation: - Resources->Object Repository Manager
Using Object Repository Manager we can
1.
Creating
Shared Object Repositories
2.
Managing
objects in Shared object repositories
3.
Modifying
Test Object Details
4.
Comparing
object repositories
5.
Merging
Object Repositories
Creating Shared object repositories we can do in two
ways
1.
From
object repository dialog box directly we can export local objects to shared
2.
From
Object repository Manager
But modifying, deleting or changing objects in
shared object repositories is possible only with Object repository manager.
Creating Shared object Repositories
In the Object Repository Manager, choose File-> new or click the new button. A new object repository opens. You can now add objects to it, modify it, and save it.
Editing Shared object Repositories
Navigation: - In object repository manager select an Object Repository and then File->Enable Editing
When you open an object repository, it is opened in read-only mode by default. You can open it in editable format by clearing the Open in read-only mode check box in the Open Shared Object Repository dialog box when you open it.
If you opened the object repository in read-only mode, you must enable editing for the object repository before you can modify it. You do not need to enable editing for an object repository if you only want to view it or copy objects from it to another object repository. When you enable editing for an object repository, it locks the object repository so that it cannot be modified by other users. To enable other users to modify the object repository, you must first unlock it (by disabling edit mode, or by closing it). If an object repository is already locked by another user, if it is saved in read-only format, or if you do not have the permissions required to open it, you cannot enable editing for it.
Object Repository comparison Tool
Navigation: - Tools->Object Repository Comparison Tool
Object repository comparison tool enables you to compare two shared object repositories and to view the differences in their objects, such as different object names, different object descriptions, and so on.
Creating Shared object Repositories
In the Object Repository Manager, choose File-> new or click the new button. A new object repository opens. You can now add objects to it, modify it, and save it.
Editing Shared object Repositories
Navigation: - In object repository manager select an Object Repository and then File->Enable Editing
When you open an object repository, it is opened in read-only mode by default. You can open it in editable format by clearing the Open in read-only mode check box in the Open Shared Object Repository dialog box when you open it.
If you opened the object repository in read-only mode, you must enable editing for the object repository before you can modify it. You do not need to enable editing for an object repository if you only want to view it or copy objects from it to another object repository. When you enable editing for an object repository, it locks the object repository so that it cannot be modified by other users. To enable other users to modify the object repository, you must first unlock it (by disabling edit mode, or by closing it). If an object repository is already locked by another user, if it is saved in read-only format, or if you do not have the permissions required to open it, you cannot enable editing for it.
Object Repository comparison Tool
Navigation: - Tools->Object Repository Comparison Tool
Object repository comparison tool enables you to compare two shared object repositories and to view the differences in their objects, such as different object names, different object descriptions, and so on.
After
opening the comparison tool, to compare the object repositories you need to provide two object repositories
file paths and click on OK. Then the
Comparison Tool provides a graphic presentation of the objects in the object
repositories, which are shown as nodes in a hierarchy. Objects that have
differences, as well as unique objects that are included in one object
repository only, can be identified according to a color configuration that you
can select. Objects that are included in one object repository only are
identified in the other object repository by the text "Does not
exist". You can also view the properties and values of each object that
you select in either object repository.
Object Repository Merge Tool
Navigation: - Tools->Object Repository Merge Tool
Object repository merge tool enables you to merge two object repositories into a single shared object repository. You can also use this tool to merge objects from the local object repository of one or more actions into a shared object repository.
Object Repository Merge Tool
Navigation: - Tools->Object Repository Merge Tool
Object repository merge tool enables you to merge two object repositories into a single shared object repository. You can also use this tool to merge objects from the local object repository of one or more actions into a shared object repository.
This
tool enables you to merge two shared object repositories (called the primary object repository and the secondary object repository), into a new third
object repository, called the target object repository. Objects in the
primary and secondary object repositories are automatically compared and then
added to the target object repository according to preconfigured rules that
define how conflicts between objects are resolved.
After
opening the merge tool, to merge the object repositories you need to provide two object repositories file paths and click
on OK. After the merge process, the Object Repository Merge Tool provides a
graphic presentation of the original objects in the primary and secondary
object repositories, which remain unchanged, as well as the objects in the
merged target object repository. Objects that had conflicts are highlighted.
The conflict of each object that you select in the target object repository is
described in detail. The Object Repository Merge Tool provides specific options
that enable you to keep the suggested resolution for each conflict, or modify
each conflict resolution individually, according to your requirements.
The Object Repository Merge
Tool also enables you to merge objects from the local object repository of one
or more actions into a shared object repository. For example, if QuickTest
learned objects locally in a specific action in your test, you may want to add
the objects to the shared object repository, so that they are available to all
actions in different tests that use that object repository.
Merjing
shared object repositories:
Merging Shared Object
Repositories
QuickTest
Professional provides the ability to merge existing assets from two
repositories into a single shared object repository using the Object Repository
Merge Tool. This tool enables you to merge two shared object repositories
(called the primary object repository and the secondary object repository), into a new third
object repository, called the target object repository. Objects in the
primary and secondary object repositories are automatically compared and then
added to the target object repository according to preconfigurable rules that
define how conflicts between objects are resolved.
After the merge process, the
Object Repository Merge Tool provides a graphic presentation of the original
objects in the primary and secondary repositories, which remain unchanged, as
well as the objects in the merged target object repository. Objects that had
conflicts are highlighted. The conflict of each object that you select in the
target object repository is described in detail. The Object Repository Merge
Tool provides specific options that enable you to keep the suggested resolution
for each conflict, or modify each conflict resolution individually, according
to your requirements.
The Object Repository Merge
Tool also enables you to merge objects from the local object repository of one
or more actions into a shared object repository. For example, you may have
learned objects locally in a specific action in your test and want to add them
to the shared object repository, so that they are available to all actions in
different tests that use that object repository.
Comparing
Shared Object Repositories
QuickTest Professional enables you to compare existing assets
from two different object repositories using the Object Repository Comparison
Tool. The tool is accessible from the Object Repository Manager, and enables
you to compare different object repository resources, or different versions of
the same object repository resource, and identify similarities, variations, or
changes.
You can compare two object repositories by following below steps:
1. In QuickTest Professional, select Resources > Object Repository Manager.
2. In the Object Repository Manager, select Tools > Object Repository Comparison Tool. The New Comparison dialog box opens on top of the Object Repository - Comparison Tool window.
3. In the First file and Second file boxes, enter or browse to and select the .tsr object repository files that you want to compare. The object repository files can be located in the file system or Quality Center. By default, the boxes display the last files selected for comparison using the Object Repository Comparison Tool. You can click the down arrow next to each box to view and select recently used files.
4. Click OK. The Object Repository Comparison Tool compares the objects in the selected object repositories and displays the results in the Statistics dialog box on top of the Object Repository - Comparison Tool window.
5. Review the statistics.
6. In the Object Repository - Comparison Tool window, you can:
- Filter the objects in the object repositories
- Find specific objects in the object repositories
Please note that the Object Repository Comparison Tool does not compare checkpoint or output objects. You cannot work with the Object Repository Manager or the Object Repository Merge Tool when the Object Repository Comparison Tool is open.
This Comparison Tool automatically identifies objects during the comparison process by classifying them into one of the following types:
1. Identical: Objects that appear in both object repository files. There is no difference in their name or in their properties.
2. Matching description, different name: Objects that appear in both object repository files that have different names, but the same description properties and values.
3. Similar description: Objects that appear in both object repository files that have similar, but not identical, description properties and values. One of the objects always has a subset of the properties set of the other object. This implies that it is likely to be a less detailed description of the same object. For example, an object named Button_1 in the second object repository has the same description properties and values as an object named Button_1 in the first object repository, but also has additional properties and values.
Objects that do not have a description, such as Page or Browser objects, are compared by name only. If the same object is contained in both the object repositories but with different names, they will be shown in the object repositories as two separate objects.
Please note that the Object Repository Comparison Tool gives precedence to matching object descriptions over the matching of object names. For this reason, certain object nodes may be linked during the comparison process and not others.
4. Unique to first file, or Unique to second file: Objects that appear in only one of the object repository files.
5. Does not exist: Objects that do not exist in one of the repository files, but do exist in the other file.
After the compare process, the Comparison Tool provides a graphic presentation of the objects in the object repositories, which are shown as nodes in a hierarchy. Objects that have differences, as well as unique objects that are included in one object repository only, can be identified according to a color configuration that you can select. Objects that are included in one object repository only are identified in the other object repository by the text "Does not exist". You can also view the properties and values of each object that you select in either object repository.
If you are connected to a Quality Center 10.00 project with version control enabled, you can compare two versions of the same object repository.
You can compare two object repositories by following below steps:
1. In QuickTest Professional, select Resources > Object Repository Manager.
2. In the Object Repository Manager, select Tools > Object Repository Comparison Tool. The New Comparison dialog box opens on top of the Object Repository - Comparison Tool window.
3. In the First file and Second file boxes, enter or browse to and select the .tsr object repository files that you want to compare. The object repository files can be located in the file system or Quality Center. By default, the boxes display the last files selected for comparison using the Object Repository Comparison Tool. You can click the down arrow next to each box to view and select recently used files.
4. Click OK. The Object Repository Comparison Tool compares the objects in the selected object repositories and displays the results in the Statistics dialog box on top of the Object Repository - Comparison Tool window.
5. Review the statistics.
6. In the Object Repository - Comparison Tool window, you can:
- Filter the objects in the object repositories
- Find specific objects in the object repositories
Please note that the Object Repository Comparison Tool does not compare checkpoint or output objects. You cannot work with the Object Repository Manager or the Object Repository Merge Tool when the Object Repository Comparison Tool is open.
This Comparison Tool automatically identifies objects during the comparison process by classifying them into one of the following types:
1. Identical: Objects that appear in both object repository files. There is no difference in their name or in their properties.
2. Matching description, different name: Objects that appear in both object repository files that have different names, but the same description properties and values.
3. Similar description: Objects that appear in both object repository files that have similar, but not identical, description properties and values. One of the objects always has a subset of the properties set of the other object. This implies that it is likely to be a less detailed description of the same object. For example, an object named Button_1 in the second object repository has the same description properties and values as an object named Button_1 in the first object repository, but also has additional properties and values.
Objects that do not have a description, such as Page or Browser objects, are compared by name only. If the same object is contained in both the object repositories but with different names, they will be shown in the object repositories as two separate objects.
Please note that the Object Repository Comparison Tool gives precedence to matching object descriptions over the matching of object names. For this reason, certain object nodes may be linked during the comparison process and not others.
4. Unique to first file, or Unique to second file: Objects that appear in only one of the object repository files.
5. Does not exist: Objects that do not exist in one of the repository files, but do exist in the other file.
After the compare process, the Comparison Tool provides a graphic presentation of the objects in the object repositories, which are shown as nodes in a hierarchy. Objects that have differences, as well as unique objects that are included in one object repository only, can be identified according to a color configuration that you can select. Objects that are included in one object repository only are identified in the other object repository by the text "Does not exist". You can also view the properties and values of each object that you select in either object repository.
If you are connected to a Quality Center 10.00 project with version control enabled, you can compare two versions of the same object repository.
Associating a Shared Object Repository to
the Current Test in
QTP
working with test object methods and
properties
Property Access Methods
Property access
methods execute specific code whenever the associated property's value is
referenced or assigned a new value. These methods enable you to perform a
variety of operations:
§ Execute code before assigning
property values to perform actions such as:
§ Check for proper types and
dimensions
§ Provide error handling
§ Execute code before returning the
current values of properties to perform actions such as:
§ Calculate the value of properties
that do not store values (for an example, see Using a Dependent Property)
§ Change the value of other
properties
Property access
methods execute automatically whenever you query or set the corresponding
property values.
Restrictions on Access Methods
You can define
property access methods only:
§ For concrete properties (that is,
properties that are not abstract)
§ Within the class that defines the
property (unless the property is abstract in that class, in which case the
concrete subclass must define the access method).
MATLAB has no default
set or get property access methods. Therefore, if you do not define property
access methods, MATLAB software does not invoke any methods before assigning or
returning property values.
Once defined, only the set and
get methods can set and query the actual property values. See Set Method Behavior for information on cases where
MATLAB does not call property set methods.
Note
Property set and get access methods are not equivalent to user-callable set and get methods used to access property values from
an instance of the class. See Implementing a Set/Get Interface for Properties for information on user-callable set and get methods.
|
Access Methods Cannot Call Other Functions to
Access Property Values
You can set and get
property values only from within your property set or get access method. You
cannot call another function from the set or get method and attempt to access
the property value from that function.
For example, an
anonymous function that calls another function to do the actual work cannot
access the property value. Similarly, an ordinary access function cannot call
another function to access the property value.
Defining Access Methods
Access methods have special names
that include the property's name. Therefore, get.PropertyName executes
whenever PropertyName is
referenced andset.PropertyName executes
whenever PropertyName is
assigned a new value.
Define property access methods in
a methods block that specifies no attributes. You cannot call these methods,
MATLAB calls them when any code accesses the properties. Therefore, property
access methods do not appear in the list of class methods returned by the methods command
and are not included in themeta.class object's Methods property. However, the meta.property object's SetMethod property contains a function
handle to the property's set method and theGetMethod property
contains a function handle to the property's get method.
For example, if the class myClass defines a set function for its Text property, you can obtain a
function handle to this method from the meta.class object:
m = ?myClass;
m.Properties{1}.SetMethod % Assuming Text is the first property in the cell array
ans =
@\mydir\@myClass\myClass.m>myClass.set.Text % This is a function handle
The meta.class object (m) contains meta.property objects corresponding to each class
property in its Properties property.
This example assumes that the Textproperty corresponds to the first meta.property object in the cell array of meta.property objects. The order of the class
properties in the meta.classProperties property
is the same as the order in which the class definition defines the properties.
Property Set Methods
Property set methods have the
following syntax, where PropertyName is
the name of the property.
methods % No method attributes
function obj = set.PropertyName(obj,value) % Value class
end
Here obj is the object whose property is
being assigned a value and value is
the new value that is assigned to the property.
Value class set
functions must return the object with the new value for the property assigned.
Value classes replace the object whose property is being assigned with the
object returned by the set method. Handle classes do not need to return the
modified object.
methods % No method attributes
function set.PropertyName(obj,value) % Handle class
end
The property set
method can perform actions like error checking on the input value before taking
whatever action is necessary to store the new property value.
function obj = set.PropertyName(obj,value)
if ~(value > 0)
error('Property value must be positive')
else
obj.PropertyName = value;
end
end
Set Method Behavior
MATLAB software calls
a property set method whenever a property value is assigned, if a set method
for that property exists. However, property set methods are NOT called in the
following cases:
§ Assigning a value to a property
from within its own property set method, to prevent recursive calling of the
set method
§ Assigning a property to its
default initial value
§ Initial values specified in class
definitions do not invoke the set method
§ Copying a value object (that is,
not a handle object). Neither the set or get method is called when copying
property values from one object to another.
When assigning a
property value, the calling function's copy of the object that has been passed
to the set method reflects the changed value.
Therefore, an assignment to even
a single property is able to affect the whole object. This behavior enables a
set method to change other properties in the object as well as its designated
property. For example, a graphics window object can have a Units property and a Size property. Changing the Units property can also require a
change to the values of the Size property
to reflect the new units.
Property Get Methods
MATLAB calls a property's get
method whenever the property value is queried. For example, passing a property
value in the following statement causes the methodget.XYData to
execute, if it exists.
plot(obj.XYData)
Property get methods have the
following syntax, where PropertyName is
the name of the property. The function must return the property value.
methods % No method attributes
function value = get.PropertyName(obj)
end
Set and Get Methods for Dependent Properties
Dependent properties
do not store data because the value of a dependent property depends on the
current state of something else. Dependent properties must define a get method
to determine the value for the property, when queried. Typically, the property
get method queries other property values to determine what value to return for
the dependent property.
For example, suppose an Account object contains a dependent
property called Balance and concrete property called Currency:
classdef Account
properties
Get Method for Dependent Property
One application of a property get
method is to determine the value of a property only when it you need it, and
avoid storing the value. To use this approach, set the property's Dependent attribute to true:
properties (Dependent = true)
PropertyName
end
Now the get method for the PropertyName property
determines the value of that property and assigns it to the object from within
the method:
function value = get.PropertyName(obj)
value = calculateValue;
...
end
The get method calls a function or static
method calculateValue to calculate the property value
and returns value to the code accessing the
property. The property get method can take whatever action is necessary within
the method to produce the output value.
When to Use Set Methods with Dependent Properties
While a dependent
property does not store its value, there are situations in which you might want
to define a set method for a dependent property.
For example, suppose you have a
class that changes the name of a property from OldPropName to NewPropName.
You want to continue to allow the use of the old name without exposing it to
new users. You can make OldPropName a
dependent property with set and get methods as show in the following example:
properties
NewPropName
end
properties (Dependent, Hidden)
OldPropName
end
methods
function obj = set.OldPropName(obj,val)
obj.NewPropName = val;
end
function value = get.OldPropName(obj)
value = obj.NewPropName;
end
end
There is no memory wasted by
storing both old and new property values, and code that accesses OldPropName continues to work as expected.
It is sometimes useful for a set
method of a dependent property to assign values to other properties of the
object. Assignments made from property set methods cause the execution of any set
methods defined for those properties. See Using a Dependent Property for
an example.
When to Use Private Set Access with Dependent
Properties
If you use a dependent property
only to return a value, then do not define a set access method for the
dependent property. Instead, set the SetAccess attribute
of the dependent property to private. For example, consider the
following get method for the MaxValue property:
methods
function mval = get.MaxValue(obj)
mval = max(obj.BigArray(:));
end
end
This example uses the MaxValue property to return a value that
it calculates only when queried. For this application, define the MaxValue property as dependent and
private:
properties (Dependent, SetAccess = private)
MaxValue
end
Set and Get Method Execution and Property Events
MATLAB software
generates events before and after set and get operations. You can use these
events to inform listeners that property values have been referenced or
assigned. The timing of event generation is as follows:
§ PreGet —
Triggered before calling the property get method
§ PostGet —
Triggered after the property get method has returned its value
If a class computes a property
value (Dependent
= true), then the behaviors
of its set events are like the get events:
§ PreSet —
Triggered before calling the property set method
§ PostSet —
Triggered after calling the property set method
If a property is not computed (Dependent = false, the default), then the
assignment statement with the set method generates the events:
§ PreSet —
Triggered before assigning the new property value within the set method
§ PostSet —
Triggered after assigning the new property value within the set method
Access Methods and Subscripted Reference and Assignment
You can use subscripting as a way
to reference or assign property values (that is, a = obj.prop(6) or obj.prop(6) = a)
without interfering with property set and get methods. When using subscripted
reference, the get method returns the whole property value and MATLAB accesses
the value referenced by subscripting that object.
For subscripted
assignment, MATLAB:
§ Invokes the get method to get the
property value
§ Performs the subscripted
assignment into the returned property
§ Passes the new property value to
the set method
MATLAB always passes
scalar objects to set and get methods. When reference or assignment occurs on
an object array, the set and get methods are called in a loop.
Performing Additional Steps with Property Access Methods
Property access methods are
useful in cases where you want to perform some additional steps before
assigning or returning a property value. For example, theTestpoint class
uses a property set method to check the range of a value. It then applies
scaling if it is within a particular range, and set it to NaN if it is not.
The property get
methods applies a scale factor before returning its current value:
classdef Testpoint
properties (Dependent)
expectedResult = [];
end
properties(Constant)
scalingFactor = 0.001;
end
methods
function obj = set.expectedResult(obj,erIn)
if erIn >= 0 && erIn <= 100
erIn = erIn.*obj.scalingFactor
obj.expectedResult = erIn;
else
obj.expectedResult = NaN;
end
end
function er = get.expectedResult(obj)
er = obj.expectedResult/obj.scalingFactor;
end
end
end
No comments:
Post a Comment