Monday, 26 August 2013

Understanding Descriptive Programming: Part 2

Continuing from... Understanding Descriptive Programming: Part 1
Now till this moment I expect reader are aware of the Objects and how the object are stored in OR(Object Repositories). Now it is time to come to real point.
Till now we were referring the Object by indicating the QTP that the definition of the particular object is stored in OR  
Idea Behind DP: The basic idea behind DP is to access Object without referring to OR.

How to implement: To implement such feature we describe the properties with which the object can be defined within the code instead of storing those in ORs.

Where to use DP/Why not Object Repositories: It can be used to perform operation on the objects which aren't stored in OR or to perform operation on the object whose properties matches a set of description properties which we can determine at run time.

Ways to implement DP  : DP can be implemented by two way. Static and Dynamic Descriptive Programing.

Static Descriptive Programing: In this type of DP, we mention the description properties within
 the Vb Script statement.


Please notice we have used ":=" instead of usual "=".
This is the General Syntax.Please notice that each "property:=value" must be separated by comma.

Below is a sample Vb Script statement which uses static DP, and a practical use of the static DP

Browser("BrowserName").Page("PageName").Webtable("TableNAme").Webedit("name:="&MyVar).Set "SampleText"

Now please notice that in above statement we have used a variable Myvar for sting. *a very imporatant thing in static DP is that u cant have static DP object in middle of OR based statment.Means
Browser("BrowserName").Page("PageName").Webtable("TableNAme").Webedit("name:=Submit").Set "SampleText"
is prefectly valid syntax , but we cant use
Browser("BrowserName").Page("PageName").Webtable("htmlid:=inventroyform").Webedit("Submit").Set "SampleText"
is an invalid syntax, as we cant get reference for the Submit button from DP based object as it is expecting OR based reference.
I will be discussing on dynamic DP in later posts

No comments:

Post a Comment