How to use Descriptive Programming in practical applications

This is the 2nd part of a two part tutorial for Descriptive Programming in QTP. It describes practical application of  Descriptive Programming .It makes use of ChildObjects() a method used to find all Child Objects for a Parent object.

 

Please be patient . Video will load in some time. If you still face issue viewing video click here

Video Transcript with Key Takeaways highlighted

  • The million dollar question is why use DP when the Object Identification process is handled by QTP
  • Suppose you are assigned to test a job portal. You enter a search query into the portal and
  • your test expects you to select all available jobs .and click the apply job
  • But the no of jobs reflected will depend on the search query and jobs available at time of script execution but there is no way to predict in advance the no of jobs that would be reflected
  • In such cases, you can use descriptive programming. Even though you do not know the number and names of the checkboxes you do know the class for the objects as "WebCheckBox"
  • You can use the ChildObject method to return objects belonging to a particular parent
  • A line of code like - Set allObjects = Browser("Jobs").Page("QTP").ChildObjects()
  • Will return all child objects for this page.
  • But we want only WebCheckBox objects.To do so we can create a filter creation object and set its property as WebcheckBox and pass this filter as an argument for the ChildObjects method
  • In this case only the checkboxes are returned.
  • Next you can write a code like this which access the entire collection of checkboxes starting from zero and sets all checkboxes ON.
  • Next you can click apply button to complete the test
  • You can also use Descriptive Programming to run objects which are difficult to record like Auto-Hide Panels, Objects with changing hierarchies, Nested Inner Objects ,Sub-menus.
  • You can also do advanced string manipulations using descriptive programming
  • In conjunction with index property, descriptive programming could be very useful in identifying difficult objects.
  • If you use programmatic description for an object in object hierarchy you will need to use description programming for succeeding child objects
  • For example, for page object descriptive programming was used but for succeeding child object WinEdit Object Repository is used which is incorrect
  • On the contrary here for both Page and WinEdit descriptive programming is used which is correct

 

comments powered by Disqus
Search

Follow Us!

Feedback

Your Feedback is very important to us. Please tell us what you think of these tutorials - http://goo.gl/aPc4K