Friday, July 22, 2011

Different ways of synchronizing in QTP

In QTP, we can do synchronizing between QTP tool and application in many ways:

1. The best one is, use synchronization point, which waits until the object meets the criteria. The general syntax is:
Object.waitproperty "your criteria"
Ex: B().P().WB().Waitproperty "enabled",1,10000
B().P().WE().WaitProperty "text",micNotEmpty(var)
(Here the tool waits until the object meets the criteria).

2. Wait(least preferred): It is like hard coding the time. The syntax is:
Wait(x) ' waits x seconds irrespective of the object state. For Ex. If we set the x as 60 Seconds and the object is ready by 2 seconds, even then it waits for 60 seconds.
If the object is not ready by 60 seconds, it wont bother and it moves to the next step(may causes script fail).

3. We can use Wait and Exists in some cases

4. And also we can use Wait and CheckProperty, which almost works like synchronization point.

5. You can also configure the default settings in the tool.
Browser navigation timeout : File -> Settings -> Web ->Browser navigation timeout
Object synchronization timeout : File -> Settings ->Run -> Object synchronization timeout.

6. We can also write custom script for QTP like below to wait till the application is loaded.

Set oPage=B().P().Object
While oPage.readystate=”Completed”
Wend

While oPage.Busy
Wend

1 comment:

Satish said...

Hi Uday,
Systemmonitor.GetValue("QTPro","Memory Usage (in MB)") will give the Memory usage of QTP. But how can I get the whole Memory usage of the computer (Not a specific application) ?


Thanks in advance


Regards,
satish