Monday 20 May 2013

Class in vb script.


Class in vb script.

Class is also one of the important part of vb script, basically if you want to set some pre condition scenarios or you want to execute some scripts at the end of your test execution.

Typically classes can be defined outside a function in .vbs or .txt files and then associates this with resources tab of QTP.
Example to define a class is as follow.

Class Class myNewClass
  private sub Class_Initialize()
        ‘This procedure gets called when the object of the class is created.
        ‘This method is typically used for all initialization activity.
         MsgBox "inside initialize method"
   end sub
   private sub  Class_terminate()
         ‘This procedure is get called at the end of the execution.
‘This method is typically used for all post execution   ‘activities.like closing external connection.
          ‘ executing scripts to generate dashboards and the end of ‘execution.   
MsgBox "Inside terminate method"
  end sub
 Function Hello()
       ‘MsgBox "Inside Hello"  
 End Function
End Class


Set myObjnew myNewClass
myObj.Hello()




No comments:

Post a Comment