Sunday, 27 October 2013

QTP Synchornization


-> Its part of error handling. but now a days independent topics.

-> its used to synchronize QTP with AUT for finding the error.


what is syncronization?

Global definition : This is process of matching speed of two things

QTP Definition : This is process of matching of speeds of Tool and application under test in order to get proper execution and result.


why synchronization?


During the execution we need synchornization . here two main concerns 1) Test design 2) Test Execution. we will got the problem during test execution.so that time we need Synchornization.

During the instruction QTP give instruction one by one with same speed. But application may take more time for execution. Here we are not blaming to application. because application not respond same speed for all the process.

Example:

Enter value into Editbox,select the check box or select the option box the application may respond the same speed. but downloading process or uploading process application respond speed is less.in order to keep both of the sync we need synchrinozation


when synchronization required?


QTP Default synchornization time is 20 second. if application need more than 20 seconds, that time we need QTP synchronizaion.

Example:

QTP not wait 20 sec for each an every statement in scripts. if one statement actual require 2 sec for respond, that time QTP goto next statement after 2 sec respond. its not keep on wait 20 sec normal time.

If another statement requires 27 sec for respond. QTP wait still 20 sec, but after 20 sec its show error.

In order to avoid the application, we need  to sync QTP and application(AUT).


How to Synchornization?


Three regular method:

a) Insert wait statement ( Vb Script feature)

syntax :

    Wait(time is seconds)  or wait  time in seconds( without paranthesis)


b) Inserting synchronization point ( QTP Tool feature)

Syntax :

Object heirarchy. WaitProperty "property name", property value, time in

milliseconds ( 1000 ms = 1 s)

c) Increase the QTP tool default time

File -> Settings -> Run -> Object synchronization timeout


Irregular method ( not for all scenario)

d) using Exist Property


Select appropriate methods

wait ("time in milliseconds");

The one drawback of wait() is its waiting for maximum time even though the application completed the operation.

Ex: wait (32)  or wait 32

Drawback of Wait ()

if the application reponsed at the time of 23, but here the maximum time is mentioned 32. so its waiting maximum time then goto the next statement. So remaining time 32-23= 9 sec the system in idle with out perform any operations. This problem is overcome by below synchronization point.


Synchronization Point

Its wait required time only, not maximum time.

Object hierarchy.WaitProperty "Peroperty name ", property value, time in milliseconds

If we want to insert wait () method, we can insert wherever we need synchronization after the QTP scripts.But if we want to insert synchronization point, we should consider below two things

1) Try to find on which object we need to implement synchronization point.
2) Try to find the above object property

Thses both steps are included and called object reference.



Example .

Example Script :

Browser("gmail").Page("gmail").WebButton("apply").click
Browser("gmail").Page("gmail").WebButton("ok").click


After click the apply for submit any form, the application need to wait the still submit the application. SO after submit the application the "OK" button is enabled and click "ok" for complete the process. Here still application submitted, the "ok" button is disabled.


Here we need synchronization point, because if application requires the 20 sec its not problem. But if the applicatin requires more than 20 sec, its shows the error like "the object is disabled". Because after  submit the application only "ok" button get enabled to click. we use above two methods for insert synchronizaion point.

For using Wait() for insert synchronization point

Browser("gmail").Page("gmail").WebButton("apply").click
wait 56
Browser("gmail").Page("gmail").WebButton("ok").click


Here the script is execute with out any issues. The above script instruct to wait the application still 56 sec. But if the application response in 30 sec, the remaining time executed process is wastage. so in order to avoid this problem, we can use snchronization point.


For using insert snchronization point

we should find the object name and object property for this method before synchronization needed.


Browser("gmail").Page("gmail").WebButton("apply").click
Browser("gmail").Page("gmail").WebButton("ok").waitproperty "enabled",True,30000
Browser("gmail").Page("gmail").WebButton("ok").click



-> So the above script the application wait still 30 sec. But if "ok" button is enabled (that means the application submitted) before 30 sec, the exected

process goto the next statement. Its not wait full 30 sec if sync completed.if the "ok" button is not enabled still 30 sec its shows the Error message like "The object is disabled"

For using insert snchronization point with out using time parameter

Browser("gmail").Page("gmail").WebButton("apply").click
Browser("gmail").Page("gmail").WebButton("ok").waitproperty "enabled",True,30000
Browser("gmail").Page("gmail").WebButton("ok").click

-> so the above scripts wait still the "ok" button gets enabled. the waiting time may any time. But we want to use carefully this operation, becaues for

failed case the execution process is waiting for long time.


For using QTP Tool insert the synchronization Point

a) Place the curser in script where we need the synchronization.
b) Recording mode-> select insert -> Synchronization Point -> select the object for which waiting for synchronization -> then select the Property name, Property value and select milliseconds.
c) Then finally the below cade added into the script

Browser("gmail").Page("gmail").WebButton("apply").click
Browser("gmail").Page("gmail").WebButton("ok").waitproperty "enabled",True,30000
Browser("gmail").Page("gmail").WebButton("ok").click


c) Increase the QTP tool default time ( Its tool feature)

File -> Settings -> Run -> Object synchronization timeout

This is applicable for all statement. If we setting the synchronization time out, the application wait for required time onlt. Not actual time for all statement in script

Example:

Consider we set the Object Synchronization Time out is 50 sec.If first statement 2 sec its not wait still 50 sec, its wait 2 sec and prcoess the statement and goto the next statement.

No comments:

Post a Comment