Interview Questions   Tutorials   Discussions   Programs   Videos   

QTP - Explain about SetToProperty, SetRoProperty, GetToProperty, GetRoProperty,GetToPrperties. with examples.




560
views
asked marvit August 21, 2014 06:21 AM  

Explain about SetToProperty, SetRoProperty, GetToProperty, GetRoProperty,GetToPrperties. with examples.


           

1 Answers



 
answered By Dharma   0  
Retrieving and Setting Test Object Property Values - Following are the pre-defined ways to retrieve and set values of test objects:
GetTOProperty
The GetTOProperty returns the value of the property from the test object's description, i.e., the value used by QTP to identify the object. It returns the value of a property for a test object which QTP recorded to identify during the recording (run time).
The GetTOProperty command will retrieve the value as it was originally recorded (or created via DP). It does not matter if the corresponding runtime object exists, or if that value was updated in "the real world" since the object was recorded.
Examples:

    Example 1(when object is in Object Repository):

  SystemUtil.Run "iexplore.exe"
  Browser("Google").Navigate "http://www.yahoomail.com/"
  abc = Browser("Google").Page("Yahoo! Mail: The best").WebEdit("login").GetTOProperties ("name")
  msgbox abc



    Example 2 (with descriptive programming):
   
Set obj = Browser("name:=Sign in to Yahoo!").Page("title:=Sign in to Yahoo!").WebEdit("html id:=username")
  msgbox obj.GetTOProperty("html id")


SetTOProperty
The SetTOProperty changes the value of a test object property. Changing the property doesn't affect the OR or Active Screen, but just the way QTP identifies the object during runtime. Actually, this changes the properties of the temporary copy of the object stored in RAM by QTP.
Any changes you make using the SetTOProperty method apply only during the course of the run session, and do not affect the values stored in the test object repository.
Example:
Set obj = Browser("name:=Sign in to Yahoo!").Page("title:=Sign in to Yahoo!").WebEdit("html id:=username")
msgbox obj.GetTOProperty("html id")
'Would retrieve the object html id from the test object description, whether it's in the OR or DP defined
'Now we set the name property
obj.SetTOProperty "name", "loginzzzzz"'And retrieve it
msgbox obj.GetTOProperty("name") 

GetTOProperties:
GetTOProperties is used to enumerate all the properties of an object used for identification.
Example:
Set abc = Browser("Google").Page("Yahoo! Mail: The best").WebEdit("login")
Set Props = abc.GetTOProperties
PropsCount = Props.Count
For i = 0 To PropsCount - 1
PropName = Props(i).Name (.Name = Returns the name of property)
PropValue = Props(i).Value (.value = Returns the value of property)
MsgBox PropName & " = " & PropValue
Next


Execute the above codes in QTP, you will get the results.

GetROProperty:

GetROProperty allows us to get the current value of a test object property. This means that unlike the GetTOProperty and GetTOProperties commands, GetROProperty requires the test object’s corresponding runtime object to exist.
Basically you would use GetROProperty to get the value of an object property during runtime, such as the current list/combo item selection, or the text in a WebEdit, or the size of an object (width & height).

Print Browser("X").Page("Y"). WebList ("z").GetROProperty("selected item index")


flag   
   add comment

Your answer

Join with account you already have

FF

Preview


Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!

Alert