Adding a new method to a class

You can also override an existing TO method and we could actually extend a TO class with new methods. Such custom methods will be registered in the same fashion as those which override the existing ones. For example, if you wish to retrieve the comment property of a TO, use the following code:

Print "username: " & Browser("AdvancedQTP - Overriding").Page("AdvancedQTP - Overriding").WebEdit("username").GetTOProperty("miccommentproperty")

Instead of writing this every time, the best practice would be to create a new method, which passes in the properties of the TO and returns the retrieved value.

How to do it...

Proceed with the following steps:

  1. Open Object Repository in which we previously added the objects from our HTML ...

Get Advanced UFT 12 for Test Engineers Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.