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.

13 comments:

  1. hi can u explain the get, set properties with more syntax

    ReplyDelete
  2. All the posts are Very Good and really helpful.
    Thanks for sharing such a good knowledge on site.

    Thanks.

    ReplyDelete
  3. Classic and simple examples Mr.Jain. Thanks for sharing such great knowledge.

    Thanks
    Anvitha

    ReplyDelete
  4. hi
    i couldn't get the difference between gettoproperty and getroproperty

    please elaborate a little more.

    ReplyDelete
  5. Thnx... very simple and helpfull

    ReplyDelete
  6. Hi Abhikansh,
    First of all thanks for this informations which are really help full.
    I have question that how a tester use these properties (GetTOProperty,GetTOProperties,SetTOProperty) in real testing environment.
    I want to understand the concept of using these properties.

    I hope you will explain this very well.
    Thanks
    Nikunj

    ReplyDelete
  7. Awesome ...U r doing a great job..Its really helpful

    ReplyDelete
  8. This blog is very helpful please add more codes with examples for verious topis.

    ReplyDelete
  9. blog is useful? if testing a website how to write script using Descriptive Programming ? can u give me an sample?

    ReplyDelete
  10. Hello Mr Abhikansh,

    Thanks for very useful posts.
    It could be great if you can post some sample projects which completes the whole sense of all your posts.

    ReplyDelete
  11. @Sushma - Thanks for your words. Its not feasible to post whole projects on blog as a project/framework has lots of components!!

    More then happy to help on any queries you have..

    ReplyDelete
  12. @ Nikunj

    GetTOProperty - most commonly used, gives a one particular property
    GetTOProperties - gives all the properties of object in an array
    SetTOProperty - used to set a property at runtime

    I'll try to write a post on it asap. Thanks.

    ReplyDelete