Sunday 18 August 2013

Introduction of SetTOProperty in QTP

The SetToProperty is a useful feature when the you do 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 handling the second one we can use the first Object and define the assistive property at runtime in code. The code could be like as follows
Object(Description).SetTOProperty Property,Value
Lets explore the same with sample application:
Dialog(”ABC”).Activate
Dialog(”ABC “).WinEdit(”First Name:”).set “XYZ”
Dialog(”ABC “).WinEdit(”First Name:”).SetTOProperty “attached text”, “Last Name”
Dialog(”ABC “).WinEdit(”First Name:”).Set “ABC”
Dialog(”Login”).WinButton(”Yes”).Click
Our OR contains only one WinEdit box and that is “First Name” and we have reduced the OR size by defining the only one editbox and adding the second edit box at run time.

No comments:

Post a Comment