Sunday, January 17, 2016

GetROProperty, GetTOProperty, GetTOProperties and SetTOProperty in QTP:

GetROProperty:

Description: GetROProperty is used to retrieve the current property value of an object in the application during run session.

Syntax: ObjObject.GetROProperty(Property Name)

Return Type: A variant value.

Example:
Dim var_Name, var_Type, var_Visible, var_MaxLength

var_Name = Browser("Browser").Page("Page").WebEdit("Webedit").GetROProperty("Name")

MsgBox var_Name

var_Type = Browser("Browser").Page("Page").WebEdit("Webedit").GetROProperty("type")

MsgBox var_Type

var_Visible = Browser("Browser").Page("Page").WebEdit("Webedit").GetROProperty("visible")

MsgBox var_Visible 'This will retuen a booelan value

var_MaxLength= Browser("Browser").Page("Page").WebEdit("Webedit").GetROProperty("max length")

MsgBox var_MaxLength

This statement will return value of the edit field during run session.

---------------------------------------------------------------------

GetTOProperty:

Description: GetTOProperty is used to retrieve the particular property of an object which QTP has 
recoded to identify that object and it is taken from Object Repository.

Syntax: ObObject.GetTOProperty(“Property Name”)

Return Type: A variant value.

Example: Browser(“Browser”).Page(“Page”).WebEdit(“WebEdit”).GetTOProperty(“Type”)

Browser(“Browser”).Page(“Page”).WebEdit(“WebEdit”).GetTOProperty(“Name”)

Browser(“Browser”).Page(“Page”).WebEdit(“WebEdit”).GetTOProperty(“micclass”)

Browser(“Browser”).Page(“Page”).WebEdit(“WebEdit”).GetTOProperty(“Html tag”)

-----------------------------------------------------------------

GetTOProperties:

Description: GetTOProperties is used to retrieve the collection of Properties and Values which QTP has recorded to identify the object.

Syntax: ObjObject.GetTOPerties

Return Type: An Object object.

Example:
Set ObjObject = Browser("Page").Page("Page").WebButton("Submit").GetTOProperties

MsgBox ObjObject.Count

For i = 0 to ObjObject.Count-1

PropertyName= ObjObject(i).Name

PropertyValue = ObjObject(i).Value

MsgBox "PropertyName = " & PropertyName & "," & "Property Value= " & PropertyValue

Next
-------------------------------------------------------

SetToProperty:

Description: SetTOProperty is used to change the property value which is used to identify the object at run time.

Syntax: ObjObject.SetTOProperty(“Property_Name”,“New_Value”)

Return Type: None

Example:

Browser("Page").Page("Page").WebButton("Submit").SetTOProperty “Name”, “New_Name”

Browser("Page").Page("Page").WebButton("Submit").SetTOProperty “type”, “New_type”

Browser("Page").Page("Page").WebButton("Submit").SetTOProperty “micclass”, “New_micclass”

Browser("Page").Page("Page").WebButton("Submit").SetTOProperty “html tag”, “New_html_tag”


Note: It has no effect on the value of the property which is saved in the OR.

No comments:

Post a Comment