QTP:Difference Between GetToProperty and GetRoProperty

GetToProperty GetRoProperty
GetToProperty returns the value of a test object which was recorded by QTP. GetRoProperty returns the current value of test object property.
GetToProperty returns the value from the test object’s description. GetRoProperty returns the current property value of the object in the application during the test run.
GetToProperty retrieves value from object repository. GetRoProperty retrieves value from application (at the run time).

To understand the difference, record a script in QTP as per following steps:-

  1. Open Gmail
  2. enter some user name(even junk data would do)
  3. enter some password(even junk data would do)
  4. Check the checkbox – ‘Stay signed in’.
  5. Click ‘Sign in’ button.

Following script would be recorded:-
1) Browser(“Gmail: Email from Google”).Page(“Gmail: Email from Google”).WebEdit(“Email”).Set “xcvbfbgf”

2) Browser(“Gmail: Email from Google”).Page(“Gmail: Email from Google”).WebEdit(“Passwd”).SetSecure “4d087e6be00c49557ee4cfbd0d440cc1d468cf7f830dde2a6892d6b7d5a6f8c4”

3) Browser(“Gmail: Email from Google”).Page(“Gmail: Email from Google”).WebCheckBox(“PersistentCookie”).Set “ON”

4) a = Browser(“Gmail: Email from Google”).Page(“Gmail: Email from Google”).WebCheckBox(“PersistentCookie”).GetTOProperty(“checked”)

5) msgbox a

6) b = Browser(“Gmail: Email from Google”).Page(“Gmail: Email from Google”).WebCheckBox(“PersistentCookie”).GetROProperty(“checked”)

7) msgbox b

8) Browser(“Gmail: Email from Google”).Page(“Gmail: Email from Google”).WebCheckBox(“PersistentCookie”).Set “OFF”

9) c = Browser(“Gmail: Email from Google”).Page(“Gmail: Email from Google”).WebCheckBox(“PersistentCookie”).GetTOProperty(“checked”)

10) msgbox c

11) d= Browser(“Gmail: Email from Google”).Page(“Gmail: Email from Google”).WebCheckBox(“PersistentCookie”).GetROProperty(“checked”)

12) msgbox d

13) Browser(“Gmail: Email from Google”).Page(“Gmail: Email from Google”).WebButton(“Sign in”).Click
In the script above, insert the code highlighted at appropriate points and run the script.

Following messages would be displayed.
a=0 — here, data is retrieved from object repository by using GetToProperty.

b=1– here, data is retrieved from application on run time by using GetToProperty. At this point, if we go and see the gmail page, checkbox – ‘Stay signed in’ is checked.

c=0 — here, data is retrieved from object repository by using GetToProperty.

d=0 — here, data is retrieved from application on run time by using GetToProperty. At this point, if we go and see the gmail page, checkbox – ‘Stay signed in’ is unchecked.

This Post Has 6 Comments

  1. Anonymous

    nice example thanku..

  2. Anonymous

    I think there is a print mistake in the last section
    b=1– here, data is retrieved from application on run time by using GetToProperty. At this point, if we go and see the gmail page, checkbox – ‘Stay signed in’ is checked.

    Instead of GetToProperty it should be GetRoPropery

    Similarly for D= 0 as well

  3. naveen varma

    Awesome example. Thank you so much…

  4. Unknown

    Really Nice….I understood very well.

  5. Swetha

    Hi, I am Swetha. It may be a print misatke. GetROproperty returns the value of runtime object value not test object value.

  6. Amita

    I do get what are you saying Swetha. Yes it's the runtime object value – i just wrote it "current"…

    Thanks for reading and commenting 🙂

Comments are closed.