Note that: The index of the child objects starts from 0 Since the object achieves its properties at runtime, we use the GetRoProperty method to retrieve the same. A couple of points to note: You will need the practice to master descriptive programming. No matter how many examples you look at and understand, you will need hands-on experience to really work with it. As a tester, you are not expected to know how the objects are coded into your AUT and what values they are set to. So use ObjectSpy from time to time to choose the right properties to view the properties. The test results will indicate that the test object was created dynamically during the run session using a programming description or the ChildObject methods.
|Published (Last):||21 November 2009|
|PDF File Size:||9.76 Mb|
|ePub File Size:||19.24 Mb|
|Price:||Free* [*Free Regsitration Required]|
This article will serve as a complete guide on Descriptive Programming. What is Descriptive Programming? Descriptive Programming also known as Programmatic Description provides a way to perform operations on objects that are not present in object repository. When and where is it used? How is it written? We will see complete details below.
Please note that the words Descriptive Programming and Programmatic Description can be used interchangeably. We will be using Descriptive Programming throughout this guide. When and Where to use Descriptive Programming? Listed below are some of the situations where Descriptive Programming can be considered useful: Handling Dynamic Object Property One of the very useful places where you can use Descriptive Programming is when the object properties in the Application Under Test AUT are dynamic in nature and need special handling to identify the object.
The best example would be of clicking a link which changes according to the user of the application. As can be seen in the example above, the text property of Link object shown above changes according to the username.
It is easier to handle such properties with descriptive programming. Using External Function Library Another place where DP can be of significant importance is when you are creating functions in an external file. You can use these function in various actions directly , eliminating the need of adding object s in object repository for each action.
This forms the basis of keyword driven framework approach. Huge Object Repository When object repository is getting huge due to the number of objects being added. Bulky object repository may decrease the performance of QTP while recognizing an object. Now for QTP to record the script and add the objects to repository, needs the application to be up, that would mean waiting for the application to be deployed before we can start making QTP scripts. But if we know the descriptions of the objects that will be created, we can start-off with the scripts using Descriptive Programming.
In such a case, you may use Descriptive Programming approach. Now adding all 15 objects in the Object repository would not be a good programming approach since the object description would be the same except the index ordinal identifier.
We can simple go for Descriptive Programming. On Different Pages: Suppose a web application with several pages has 3 navigation buttons on each page. Now recording action on these buttons would add 3 objects per page in the repository. For a 10 page flow, it would mean 30 objects which could have been represented just by using 3 objects.
So instead of adding these 30 objects to the repository, we can write 3 descriptions for the object and use those descriptions on any page. How to write Descriptive Programming? It is not limited to a particular technology.
In the examples that follow, we will use web based objects. There are two ways to create Descriptive Programming statements: 1. By giving description in form of the string arguments. A normal recorded statement for username would like Browser "Welcome: Mercury Tours". Page "Welcome: Mercury Tours". WebEdit "userName". Set "mercury" We will create a DP statement in place of the recorded statement above.
Here is the generic process that one should follow. Record the object for which you wish to write a DP statement. Open the repository corresponding to the object s. Note the property-value pairs used by QTP to identify the object. Write them using the syntax discussed above. QTP does not record any property for a browser or a page object. For a browser object, there is no other property required in case you are dealing with a single browser. Actually micclass is an implicit property which is taken automatically since QTP assumes that based on the test object type being referenced.
In case of Browser or page object, you can provide any one such implicit property. The copied values are formatted in standard DP syntax with line breaks between each property-value pair. You can paste the copied data to any document and then copy selected lines — after removing the line breaks- into a DP statement. As a rule of thumb, you should use a minimum set of properties to identify an object.
By creating properties collection object for the description. It is my observation that people find 1st method easier to work with. The process of writing DP statements remains almost the same as inline DP. However, in this case the property value pairs are written as part of a description object. Example For this example, we will create a description object for WebEdit.
Browser "Browser". Page "Page". WebEdit oDesc. If the name value above was username and you wanted the last three digits as a regular expression, you could write the same statement as oDesc "name". Check our regular expressions guide if you wish to learn about them in detail. The first image shown at the top has a dynamic username.
Page "QTP Training". Link oDesc. You can also optionally use index or location ordinal identifiers or similarity as one of the properties in an Insight object. Here is an example of using ImgSrc in DP. Window "Calculator". Click Important points to note while using Insight with Descriptive Programming. The image file should be accessible from the machine that runs the test. The file location can be either the local machine or ALM. It can not be a random site on the internet.
You can optionally use ordinal identifiers like index or location. You can optionally use similarity property with possible values ranging from Similarity property specifies in percentage how similar a control in the application has to be to the test object image for it to be considered a match.
The default value is The ImgSrc property does not support regular expressions. The Click method would click in the center of the image when you use Descriptive Programming on an Insight object.
When using Descriptive Programming from a specific point within a test object hierarchy, you must continue to use Descriptive Programming from that point onward within the same statement. For example, you can use Browser Desc1. Page Desc1. Link desc3 , since it uses Descriptive Programming throughout the entire test object hierarchy. Link desc3 , since it uses Descriptive Programming from a certain point in the description starting from the Page object description.
However, you cannot use Browser Desc1. QTP evaluates all property values in Descriptive Programming as regular expressions. Set "mercury" since parenthesis is a special regular expression character and in this case you would want to treat it as a literal. Make sure to use micclass. Descriptive Programming provides a way to bypass object repository and gives a bit of flexibility to identify the object. I recommend you to subscribe by Email and have new UFT articles sent directly to your inbox.
This article will serve as a complete guide on Descriptive Programming. What is Descriptive Programming? Descriptive Programming also known as Programmatic Description provides a way to perform operations on objects that are not present in object repository. When and where is it used?
Descriptive Programming in QTP/UFT: Dynamic & Static
Create ; MyDescription "property". You enter a search query into the portal and your test expects you to select all available jobs. Page "QTP". ChildObjects Will return all child objects for this page. But we want only WebCheckBox objects.