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()




Tuesday 14 May 2013

Topic: Object Synchronization.




Object synchronization is one of the important aspect in Quick Test Pro , While working with Web.
The details to the topic are as below.

1.       What is synchronization?
a.       When we consider QTP application , it has its own speed of running and the application under test has its own speed, To Synch that’s to match the running speed to QTP with Application Under Test we need synchronization points.

2.       Why we need synchronization?
a.       We need synchronization to match the speed of application under test and QTP.

3.       How to synchronization and what are different ways to synchronize.
a.       The different ways to synchronize QTP with the AUT are
                                                               i.      Using Wait() statement.
1.       The Syntax to use Wait(Sec), Where “Sec “ it’s the time in term of second for which you want application to wait/pause the execution.
                                                             ii.      Using  .Exist
1.       When you use .Exist, the default execution pause time is 20 seconds, However still this can be altered, by Changing QTP setting s By navigating to File->Setting->Run , You need to enter the value in the field “Object Synchronization timeout”. Unit is seconds. You can change the value in this field and Click on apply to reflect the changes.
                                                            iii.      Using Wait property.
1.       Wait property is basically used when you want application to wait for a certain time or the property of an object is changed.
Simple syntax to use wait property is “Object. WaitProperty("attribute/readyState", "complete", 4000WaitProperty("attribute/readyState", "complete", 8000)”
                                                           iv.      Using .Synch
1.       The syntax to use .Sync is Object.Sync, This pauses the QTP execution for the default time out set in “Object Synchronization timeout” field of File->Setting->Run
                                                             v.      Using loops.
1.       We can also make QTP to wait by using loops, the simple example is using do loop.
Do
      myObjProperty=Browser(“browser”).Page(“page”).WebEdit(“webedit”).GetROProperty(“visible”)
      Wait(1)
Loop While myObjProperty =False

4.       Where to use Synchronization?
a.       Typical use of application of synchronization is when application speeds are not matching, or you have two different applications running in a single browser.
I hope this article has sufficient information on Synchronization. If you need anything specific, Please don’t hesitate to post.
Or even you want me write article on any specific module, your suggestions are most welcome.