Implementing a class

In this recipe, you will learn the following:

  • The basic concepts and the syntax required by VBScript to implement a class
  • The different components of a class and interoperation
  • How to implement a type of generic constructor function for VBScript classes
  • How to use a class during runtime

Getting ready

From the File menu, navigate to New | Function Library…, or use the Alt + Shift + N shortcut. Name the new function library cls.MyFirstClass.vbs and associate it with your test.

How to do it...

We will build our MyFirstClass class from the ground up. There are several steps one must follow to implement a class; they are follows:

  1. Define the class as follows:
    Class MyFirstClass
  2. Next, we define the class fields. Fields are like regular variables, ...

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.