Sunday, 21 September 2008

Why to go for SetTOProperty in QTP.

The SetToProperty can be useful when the engineer does not want to add the multiple objects of same type with differing values. The same can be explained with an example like we have two editboxes in the application and both differ by an assistive proprty.Here we can add only one of them in ObjectRepository and while dealing with the second one we can use the first Object and define the assistive property at runtime in code. The code can go as

Object(Description).SetTOProperty Property,Value

Lets explore the same with Flight application example:

Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Type "shantanu"
Dialog("Login").WinEdit("Agent Name:").SetTOProperty "attached text","Password:"
Dialog("Login").WinEdit("Agent Name:").SetSecure "4884a1b87838d0a7a817a550056f14667e65eecd"
Dialog("Login").WinButton("OK").Click

Now here my ObjectRepository(OR) does contain only one WinEdit box and that is "Agent Name" only. So what i have done here is reduced the load on OR by defining the only one editbox and adding the second edit box at run time.

No comments: