0 Shares 1350 Views 13 Comments

Object Repository or Descriptive Programming

Oct 30, 2014
1350 Views 13


ObjectRepository vs Descriptive Programming

This is a frequently being discussed question within test automation teams while you are planning for an automation. I have also observed this question being asked in interviews as in “which way you would like to go for Object Repository or Descriptive programming?’ I believe there is no “verses” here, i.e. it is not something to choose between  Object Repository or descriptive programming. 

The way I see to it, is two different features of QTP meant for different purposes. It basically depends on the needs of the test, at some point you may need and simply use object repository and at some point there is  no way without using Descriptive programming.

A simple example, lets say if you have to click on a link on a page. Its a very simple scenario, where simply adding the object into object repository will do the required. But in the same situation if you 100 links on the page and you need to verify each one of those by clicking. In this case its not good to have all the 100 objects in the OR whereas we should use descriptive programming here.

But in the case where you have to decide (irrespective of the need of test, I see many people create frameworks and decides not to use object repository and go with descriptive programming only) whether to go for either Object Repository or descriptive programming, I prefer to go with Object repository mostly (not very much convinced with “only” descriptive programming approach). Not only because it has been built for that purpose but it makes our life easy in multiple sense.

Here is another example, you have a page where you have a button with text as “Submit”. You have developed your script for the button click. Now in the next release the button text is changed and becomes “Submit Order”. if you have used Object Repository, you just need to change the text property of the button. All scripts using that repository will be updated automatically. But In case of Descriptive programming, you will have to manually modify every script requiring the update. I understand that we can definitely sort this out in scripting as well. I have some more pointers 🙂 Descriptive programming statements need to be implemented manually. Finding a set of properties to uniquely identify the object consistently can be time consuming. To help with selecting the properties, you can use the Object Spy or temporarily add the object to the repository.

QTP/UFT identifies an object using a set of property/value pairs that uniquely identify the object. When determining whether to use the object repository or descriptive programming, you should consider how the property/value pairs are selected and used.When objects are learned into the object repository, QTP/UFT automatically determines which properties and values are needed to uniquely identify the object. QTP/UFT starts with a predefined set of mandatory properties that must be learned. If those properties do not uniquely identify the object, QTP/UFT includes predefined Assistive properties, one at a time, until there is a unique identification. If the mandatory and assistive properties do not uniquely identify the object, QTP/UFT includes an ordinal identifier. In addition to these properties, if Smart Identification is enabled for the object class, QTP/UFT will learn additional properties that can be used during replay if the defined object definition does not match an object in the application. During replay, if QTP/UFT cannot find an object using the defined properties or smart identification, an error (“Cannot identify object”) will be generated.

QuickTest Professional (QTP) / Unified Functional Testing (UFT) can perform faster when using information from the object repository to identify the object. When QTP/UFT first encounters an object during replay, it uses the object description (from the Object Repository) to create a temporary version of the test object. For the remainder of the test run, QTP refers to that temporary version of the test object rather than to the test object in the object repository. This internal “mapping” helps QTP locate the objects quickly. Statements using descriptive programming can be slower. This is because QTP/UFT must check every object and compare it with the specified properties to find a match.

When descriptive programming is used, all property pairs that are listed are considered mandatory. You must manually create the property list to identify the object at runtime. During replay, if QTP/UFT cannot find an object using the defined properties, an error (“General Run Error” or “Cannot identify object”) will be generated. To help with selecting the properties, you can use the Object Spy or temporarily add the object to the repository.

additionaly Descriptive programming is useful when you need to perform an operation on an object whose properties match a description determined dynamically during replay.

Example:OrderNo = 4 ‘ assume the order number is generated during test execution

Window(“Flight Reservation”).WinEdit(“attached text:= Order No:”, “text:=”& OrderNo).Highlight

If you will be using the object description in multiple statements, you can create a Description object to hold the description.

 

Let us know your views on this, which one you prefer to go with and in what scenarios.

You may be interested

Setting up Web Service Automation Project
Katalon Studio
244 views
Katalon Studio
244 views

Setting up Web Service Automation Project

Saket - Oct 24, 2017

Web services are specific services that can be published and called over the Internet by client applications. Katalon Studio supports functional testing of web services. This topic…

Setting up Mobile Automation Project in MacOS
Katalon Studio
242 views1
Katalon Studio
242 views1

Setting up Mobile Automation Project in MacOS

Saket - Oct 09, 2017

Using Katalon Studio, mobile tester can design automation test for both Android and iOS to run on physical devices, cloud services and emulators. This tutorial explains how…

UFT Jenkins Integration
Unified Functional Testing
801 views
Unified Functional Testing
801 views

UFT Jenkins Integration

Saket - Oct 03, 2017

In our earlier post, we got to know the easy integration of UFT with GIT. This post focuses on integration of UFT and Jenkins. I have also…

13 Comments

  1. Hello Saket,

    while creating Keyword framework, I am getting lot of confusion. below is my structure.
    1) Function lib
    2) Test Data
    3) Test Case(manual)
    4) Main script
    5) test Group
    6) Result
    could you help me to create good Frmework.

    Reply
  2. Thanks for your help:

    Test Group: This is a sheet which specifies the business flow of the test case. if contains a series of business keywords Mapped against each TEst case.

    i got the ans for my confusion.

    Reply
  3. hi Saket,

    help me,
    1) what is difference between event and mouse?

    2) What is the difference between FireEvent and ReplayType 2?

    Reply
  4. Hi Saket,

    could you help me where and which scenario, i could use Dictionary object in my project.

    Reply
  5. Hi Saket,

    I am working on windows based java application.It has a java tree whose branches value changes with application environment being used.When recording with qtp it stores hard code index value of branch chosen.So doesn’t work in different environment as the position of same desired branch changes.Can you please guide me on this how to automate so that it works in all environment

    Regards,
    Neha Saini

    Reply
    • Hi Neha,
      you can simple use Select method to select a node in your tree. e.g if you tree structure is like “Parent Node > Sub Node > Item”
      your statement should be like – JavaWindow("x").JavaDialog("x").JavaTree("x").Select "Parent Node;Sub Node; Item"

      if this does not work then you should go for descriptive, check each node and select
      1. get the count of items/nodes in the tree
      2. loop through the items get itemaname, use getItem
      3. if name matches the required select the item, use Select method.

      let me know if this helps.

      Reply
  6. Pingback: LeanFT Tutorial #4: Application Model Overview - Automated-360

Leave a Comment

Your email address will not be published.

Most from this category

Join The Growing Group of 15000+ Test Automation Engineers

Signup for our newsletter and get access to free downloads, as well as tips, tricks and techniques and various test automation resources.
Name
Email Address
Secure and Spam free...