Micro Focus QTP (UFT) Forums
static vs dynamic dscritve programing - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: static vs dynamic dscritve programing (/Thread-static-vs-dynamic-dscritve-programing)



static vs dynamic dscritve programing - ramesh.tahiliani - 09-08-2009

hi ,

to set a editBox :

static descriptive approach :-
Code:
window("Title:=Login").WinEdit("AttachedText:=Agent Name:","height:=20","width:=119" ).Set "abcd"

dynamic descriptive approach :-
Code:
Set myvar= description.Create()
myvar("AttachedText").value="Agent Name:"
myvar("height").value=20
myvar("width").value=119
window("Title:=Login").WinEdit(myvar ).Set "abcd"
I have read a article that the " Dynamic descriptive prog provides more power, efficiency, and flexibility".
but i dont understand this concept that how it is flexible,powerful & efficient . As we can see that in both the cases we are using the same number of properties to identfy a object


please help me in undestanding this concept


RE: static vs dynamic dscritve programing - Tarik Sheth - 09-08-2009

Hi,

Static Descriptive programming: This is quick and short but it may cause the problem when your scripts are maturing at a level that you might require same object in different screen of the same test script......This syntax has the benefit of being shot and quick, but may cause problems if we’ll use the object again somewhere else. In this case we’ll have to rewrite the all the description strings, making the code less readable, and harder to maintain (i.e., if one of the properties were to change, we’ll be forced to make several repairs in different places throughout the code).

Dynamic Descriptive Programming: The main reason I guess this is used is for sometime an object will appear under a different parent each time (e.g. – a pop-up which appears under the initiating sub-window). In some applications, the only way to work with such objects is with DP. Apart from that there are some dynamic objects like list box for which content keeps on changing so at that moment this dynamic descriptive will be more efficient and flexible enough.

one more advantage is According to this, instead of working with a single object at a time, we can gather all the objects in an array which answer to our identification properties, and work with them as a collection, and resize the array whenever we need it.

Hope this clears your query.


RE: static vs dynamic dscritve programing - ramesh.tahiliani - 09-08-2009

Sorry; but still i didnt get the concept clear


RE: static vs dynamic dscritve programing - Tarik Sheth - 09-08-2009

Hi,


Let me attempt to explain further.

In static descriptive programming: we provide state of values and propertiesthat describes the object directly


Code:
window("Title:=Login").WinEdit("AttachedText:=Agent Name:","height:=20","width:=119" ).Set "abcd"

In the code above for placing abcd on all the winedit box you require more number of statements. What if in future you get more than the specified number of winedit box, one needs to write more statements to accomodate it. while in dynamic descriptive programming you will be having all the collection of winedit box in an array and you can use it in some kind of loop, the best example could be a winlist or dropdown box object.

In Dynamic descriptive programming: We provide collection of properties and values to desscription of the object and then we provide other statements in support of the object collection e.g. .Childobjects
Moreover an object and its property contains name of the object and value of the property of the object. in return it provides a collection of object having same properties. Once the object property is created we can have add, remove values to or from the object property can be entered during run time


Hope this helps.


RE: static vs dynamic dscritve programing - Saket - 09-08-2009

Hi Ramesh
I would like to try to explain this with an example
Say you have a page in which there are multiple Submit buttons
if you want to click each button one by one.
In that case if you use static DP then you will have to uniquely identify each button and then click each one which will take you to the repeateative steps
but using Dynamic DP you can do this easily using childobjects and a loop.
Code:
static
Browser("micclass:=Browser").Page("micclass:=Page").WebButton("micclass:=Button", "name:=Submit", "index:=1").Click
Browser("micclass:=Browser").Page("micclass:=Page").WebButton("micclass:=Button", "name:=Submit", "index:=2").Click

Dynamic

Set oButton = Description.Create
oButton("micclass").value = "Button"
oButton("name").value = "Submit"
set oButtons=browser("micclass:=Browser").page("micclass:=Page").ChildObjects(oButton)
For cnt=0 to oButtons.count-1
oButtons(cnt).Click
Next
I must say here that there is no rule that we have to use static or dynamic. we should always decide this based on the situation we are in.
hope I am able to clarify the point to you.


RE: static vs dynamic dscritve programing - ramesh.tahiliani - 09-08-2009

Hi
Great explnation from u all
I could understand the examples mentioned
So we can say : like the biggest advantage is to get rid of multiple statements using dynamic DP

Thanks
Ramesh Tahiliani