Monday, January 9, 2012

QTP : Synchronisation


Sometimes scripts fail when they are run because of the speed mismatch between QTP and the application. QTP is always faster than the application as a result, the application responds to QTP slower than expected and the test fails. Instances where the application responds slower than expected and the test fails. These speed mismatch problems can be handled by synchronising the test. Synchronising the test involves making the QTP wait until the application is ready for performing the next step.

Synchronising the Test

By modifying the default time settings for a test in QTP. QTP provides some setting for the test which makes QTP to wait for the mentioned time in the setting.
  1. Browser Navigation Timeout: This setting makes QTP wait for the web page to load completely for the specified amount of time. By default the maximum wait time specified by QTP is 60 seconds. This setting can further be modified bythe user based on his requirement. This setting is found in File>settings>Web>Browser navigation timeout. This setting is applicable only for web applications.
  2. Object synchronization timeout: This setting makes QTP wait for the specified amount of time for the objects to appear. By default the time setting is 20 seconds which can be modified by the user. these settings can be found in File>Setting>Run>Object synchronization timeout.
Wait/Exist statements
These statements can be inserted to make QTP wait until an object exists.
Wait statement: When a wait statement is encountered, QTP pauses its script execution  for the specified amount of time. Once the specified amount is lapsed, QTP proceeds with the execution of next step.
Syntax: wait(n), where n is the number of seconds.

Exist statement: When a exist statement is inserted it checks if the object exists or not  in the application under test and returns a Boolean value for the same. Based on the return value, appropriated steps can be taken to handle the timing mismatch.You can combine wait and exist statements within a loop to instruct QTP to wait until the objects exists before continuing with the test.

Inserting Synchronization Point

A synchronization point can be inserted which makes QTP pause the test until an object property achieves a specified value. Synchronization point is often referred to as intelligent wait statement. Steps to insert a synchronization point are given below:
  1. Start a recording session. Select Insert>Synchronization Point.
  2. Click the object in your application for which you want to insert a synchronization point.
  3. Select the object for which you want to insert a synchronization point and click OK.

                     
  4. The Add Synchronization Point dialog box opens as shown in figure below:

                     
    The property name contains the list of properties of the object, property value is the value for which QTP should wait before continuing to the next step in the test. Timeout specifies the maximum amount of time to wait for the specified property to be achieved.
  5. Enter all the required values in Add Synchronization Point dialog and click OK. A WaitProperty step is added to the Test.




    No comments:

    Post a Comment