Testing is now an important phase of the software development life cycle to secure the product’s quality. Also, without having testing, we can’t ensure the fulfillment of all the requirements. Here automation is playing an essential role in the testing cycle to reduce the efforts and time. In the market, there are multiple testing tools available to automate the testing process. The most used automation testing tool is UFT.
In this topic, we are going to learn about the UFT Object Repository, descriptive programming approach and concept of virtual object in UFT, which are the most important features of UFT.
UFT Tutorial – Table of Content
UFT Tutorial #3: UFT Object Repository
UFT Object Repository:
An object repository is the primary component of UFT as an automation test tool. It is the collection of test objects which are used to map the applications with the UFT test scripts. Basically, one or multiple properties that can uniquely represent any test objects of the application are stored in Object Repository. For example, name, id, inner text, these are the common properties used to represent any object. It follows the below properties to identify the field objects –
Mandatory property -> Assistive property -> Ordinal Identifier -> Smart Identification
Object Repository Classification:
Two types of object repositories are available in UFT –
- Local Object Repository
- Shared Object Repository
Shared Object repository – An object repository that is located outside of the test case is known as a shared object repository. It can be shared across multiple actions or test scripts. We can build it with the help of the object repository manager. It’s used for reusability purposes. We can store it as a .tsr file in any location. This type of object repositories is mostly used for reusability purposes in Keyword or Hybrid test frameworks.
Guideline for Object Repository:
- The logical name of the objects in the repository should be given based on the application functionality.
- Smart identification should be disabled to increase performance.
- Object Repository size should not be big; descriptive programming can be partially used to reduce the size.
- Handle dynamic objects through regular expressions or descriptive programming.
- Use a shared object repository instead of a local.
- Do not use multiple entries for the same object in Repository.
Different Options in Object Repository:
ObjectFinder – This is one of the most important and helpful features of UFT to analyze the test object. Through this option, we can view/analyze the different properties of test objects before adding them to Object Repository. It will help us to define the object identification approaches for test automation. Without object Finder, it is very difficult to define the descriptive programming approach.
Add Object – It’s used to add any application object into the repository.
Update from the application – We can update any objects which are already added to the repository directly from the application through this option.
Highlight – Object can be highlighted in the application.
Locate in Repository – We can locate the actual object available in the repository from the application.
Object Properties section – Descriptive properties, ordinal identifier, and smart identification configuration can be view/ edit from this section.
UFT Object Hierarchy: The UFT test object hierarchy includes one or multiple levels of test objects. The highest level of the object may represent a window, dialog box, or browser type object, depending on the environment. For any web applications, three levels of object hierarchies are available – Browser, Page, and individual test object. So, the identification has been made sequentially from top to bottom.
Browser(“Test Browser”).Page(“Test Page”).Link(“test link”).Click
Object Identification Mechanism:
Objects from the repository can be identified based on the properties or behavior as appeared in the application. There are three different types of property options that are available to locate any object uniquely. Those are –
Descriptive Properties – Based on the application development, behavior or properties are defined in the application. It has two parts – Mandatory properties and assistive properties. Based on the uniqueness of the properties, UFT is able to identify the objects. First, the tool is to try to identify the Mandatory properties such as name, id, text, etc., which are defined during the application development, are used to identify the object. If any unique combination is not available, UFT is trying to identify the application with the help of some additional properties, which are referred to as assistive property.
Ordinal Identifier – When the descriptive properties are not sufficient to identify any object uniquely, UFT is trying to define some additional properties based on the appearance of the objects in the application to identify. These properties are called an Ordinal Identifier. Three types of ordinal identifiers are available –
Index – it’s defined based on the position of the object in the application. Index value always starts from 0.
Location – it’s defined based on the location of the object in the application. The location value always starts from 0.
CreationTime – it’s defined based on the creation time of the object in the application. The value of CreationTime always starts at 0.
Smart Identification – When Descriptive properties and Ordinal Identifiers are failed to identify any object, some additional configuration/properties are used, which are predefined to identify the objects in this case. Smart Identification is the last option to identify the objects. It’s only applicable if we set the value as true. But this feature has slowed down the test execution. So, as best practices, in most cases, we need to disable these features.
Step by step guide to add Objects:
- Open the test application and move to the desire page/screen to add objects.
- Open local object repository from UFT by clicking on the Object Repository icon or pressing “Ctrl+R” keys. In case of a shared repository, we can open it from “Resources-> Object Repository Manager.”
- Click on the add object button(Green plus button) in the repository. Now the tool will allow us to select the object by clicking on the desired field in the application.
- After the selection of an object, an intermediate “Object Selection – Add to Repository” popup will appear. Click on the OK button to add the object.
- After adding the object, we can edit the properties or logical names based on the requirements.
Object Repository Manager:
Object repository manager is used to manage/ work with a shared repository. We can add, update, delete objects from the shared repository through the wizard. Navigation to open – Resources -> Object Repository Manager.
How to Create a Shared Object Repository:
The different approaches are –
- Create through Object Repository Manager – Open “Resources-> Object Repository Manager” and add objects from this window. After adding objects, we can save it as a .tsr file to create a shared object repository.
- Converting Local Repository into Shared Repository – Exporting the local object repository (File -> Export Local Objects) into a shared object repository.
- Drag Drop approach – Drag the objects from the Local Repository and drop them into a shared repository.
Associate Shared Object Repository in action:
Two options are available –
- In the Solution Explorer of UFT, right-click on the action name node and select the Associate Repository with Action.
- In the Open Shared Repository dialog box, select the object repository and click Open.
Object Repository Comparision Tool:
This is used to compare two shared repositories and identify the mismatches.
- This tool can be opened from “Object Repository Manager” by the following path – “Tools-> Object repository Comparision Tool.”
- Select both the shared repository and press on OK button.
- Now comparision details will be available to analyse.
Object Repository Merge Tool:
This is used to merge two shared repository into one.
- Merge tool can be opened from “Object Repository Manager” by the following path – “Tools-> Object repository Merge Tool.”
- We need to select the primary and secondary repositories for merging.
- Now analyze the conflicts and save for merging both the repositories into the primary repository.
Handling Dynamic Objects:
Two options are available to handle dynamic objects –
- Descriptive programming approach – We later about descriptive programming in this article.
- Regular Expression – It’s a series of characters that form a pattern/string which is used to identify the objects. We can define it by replacing the dynamic part of any properties with wild characters. Let see the below example –
We have a dynamic link with text as – “Current date is 03-04-2000”. Here we can observe that in this link, the “Current date is “ part is constant by rest part is getting change every day. So we can use the either of below pattern while defining the objects in Object Repository –
“Current date is .*” – Here ‘.*’ represent any string of any size.
“Current date is \d\d-\d\d-\d\d\d\d” – Here ‘\d’ can replace one numeric digit only.
Similarly, there are more regular expressions available. Please click here to see that.
Descriptive programming is an approach to define the description of the object during execution time. Through this approach, we can execute the test cases when the objects are not stored in the object repository.
The purposes of using the Descriptive Programming approach are –
- The test object is dynamic in nature.
- To execute test cases without adding objects in Object Repository.
- Execution performance may decreases if we use a big Object Repository. Descriptive programming can be used to avoid it.
- ChildObjects are used to create a collection of objects which are matched based on the defined object descriptions. The parent objects proceed ChildObjects. Example – refer above example.
Working with descriptive Programming:
There are two ways to develop test cases using descriptive programming –
1. Description Objects – Script is created using the Description object with the required properties. Example – Below descriptive programming approach is used to find the number of links available on a particular webpage.
2. Description Strings – The Description of the object are passed as a string during the test case creation. Example –
Comparision Study between Object Repository and Descriptive Programming:
|Object Repository||Descriptive Programming|
|Object need to be added here.||No need to add object in OR.|
|Difficult to handle dynamic objects.||Easy to handle dynamic objects.|
|Reduce the performance of the execution.||Increase the performance of the execution.|
|Object need to be defined prior to execution.||Objects are defined during execution.|
Virtual Object in UFT:
Sometimes, we have observed that objects in test applications are not recognized by the UFT for automation. Instead of that, the entire region identified as standard window objects. To handle this kind of scenario, UFT provides a feature as a virtual object to define those unrecognized objects as Button, link, textbox, etc., based on their behavior.
We can open the virtual object creation wizard from the path – “Tools-> Virtual Object->New Virtual Object.” By following the step by instruction from this wizard, we can define the Virtual Objects.
Limitations of Virtual Object are –
- UFT is not able to record the virtual objects.
- It’s not controlled by Object Repository.
- Checkpoints can not be added here.
- Object Finder can not inspect the virtual objects.
- Execution may fail if the screen resolution has been changed.
Creation of Virtual Object in UFT:
1. Open Virtual Object Manager from navigation “Tools-> Virtual Object” and click on New button.
2. Click on Next from “Welcome to Virtual Object Manager” screen.
3. Select class and click Next from “Map to a Standard Class” screen.
4. Now mark the test object from application using mouse and click on next.
5. Now configure the object and click next.
6. Now click on Finish to save virtual Object.
In this article about UFT Object Repository, we have learned about how to identify objects from the application under test and the classification. Click here to understand more from the Microfocus support portal. Also, if you want to prepare for UFT Interview Questions, please click here.