Friday, July 16, 2010

Tutorial 32 - Descriptive Programming

This is the 1st part of a two part tutorial for Descriptive Programming. It introduces Descriptive Programming and its two type viz. static and dynamic.



Video Transcript with Key Takeaways Highlighted:

* To understand the concept of descriptive programming lets understand the significance of an objects name in QTP
* An object name is simply used to map an object in script with its description in object repository.
* Meaning if I change the object name here to ABC and correspondingly change the object name in script to ABC the script will still work fine.
* Consider this statement, which sets the Agent Name as Guru99. Let us do an experiment..Let's delete the Object Description of Agent Name Win Edit Box from the Object Repository.
* If I run the test again it will fail since it can not recognize the object. Lets examine the reason why the script is failing
* During Run Time, QTP identifies the operation that is performed on WinEdit box and the Object Description in Object Repository is stored as Agent Name
* It uses this name to track the object in object repository. For a parent you cannot have two child objects with the same name. Hence, QTP uniquely maps the object in the repository
* It then uses the stored description in the Object Repository and replaces the name with the description. It then uses this statement to identify the object in the application under test
* Since in our case we had deleted this object description all together the script fails
* But what if instead of QTP replacing the object description, you as a tester directly specify the object descriptions in your script. This is nothing but "Descriptive Programming"
* You can use Descriptive programming in two ways 1) Static 2) Dynamic
* Lets look at Static First. In Static Method , for object identification in the following format property:=values , you mention an objects property ,and its corresponding values separated by a colon and equal to sign. This format is called property value pair and is enclosed in inverted commas
* If your object uses multiple descriptions for identification, you can specify those using commas
* So in our case the description for Agent Name becomes "nativeclass:=Edit", "attached text:=Agent Name:"
* Next Step is to Replace Object Name with above description. In QTP , lets do the replacement and run the test. It runs fine . In the test results the Agent Name object is enclosed in parentheses indicating that Descriptive Programming was used in its identification. * This is the static method
* The second method of doing the same action is using Dynamic Descriptive programming
* In case your script uses the descriptive programming object candidate multiple times, * it will be very tiresome to specify all the property value pairs for each statement
* In such cases you can make use of Description Class provided by QTP
* Syntax for creating an description object is
Set MyDescription = Description.Create();
MyDescription("property").Value = "property-value";
This is the Dynamic Method

No comments:

South Beach Smoke E-Cigarette - The Better Smoking Choice