Pages

Sunday, April 3

Descriptive Programming in QTP - Part 4



Hello Friends!


In Part-1, Part-2, Part-3 of this post we learned basics, type, use and various methods of descriptive programming.


In this part we will continue with more good stuff.. :)


Apart from GetROPropety, these are some other methods which are very useful in DP.


- GetTOProperty
- GetTOProperties

- SetTOProperty



GetTOProperty returns the value of the specified property from the test object description.


Example:
Msgbox Browser("MyBrowser").Page("MyPage").GetTOProperty("html tag")




GetTOProperties returns the collection of properties and values used to identify the object.


Example:
Set Propset = Browser("MyBrowser").Page("MyPage").GetTOProperties
Above statement will give you all the properties used in object identification by QTP to an array Propset. All these properties and values can be retrieved using below code..


For i = 0 to Propset.Count-1
    Print Propset(i).Name & ":=" & Propset(i).Value
Next

SetTOProperty is used to set the value of the specified property in the test object description. It is used when you require to change the any particular property at run time.


For Example you need to work open/work on two instances of an application at same time. Obviously, all the properties will be same. In this situation you can use SetTOProperty to change properties at run-time.


Please note that changes made by SetTOProperty will be applicable at runtime only. Once your execution is finished, no change will be saved. Also changes will be applicable to that action only.



Example:
Browser("MyBrowser").Page("MyPage").WebElement("my text").SetTOProperty "Style", "'color:blue'"


Feel free to post comments if you have any question from this or last three posts.