Tuesday, January 26, 2010

How to Apply Synchronization Point in web and desktop Applications in QTP

What is Synchronization Point: Synchronization Point instructs QTP to pause until an object property achieves a specific value.

Why we use Synchronization Point: We use “Synchronization Point” to maintain the time coordination between testing process and our application process.

Different ways to Apply Synchronization Point:
Basically there are 4 ways

1) sync (only for web applications)
Syntax: Browser("Browser").Page("Page").Sync
Description: “sync” is more dynamic than wait. In wait we have to wait for specified time even if the process has been completed in less time but with “sync” the page will move on after completion of a process. It is very good to apply but unfortunately we can’t apply it in desktop application.
For example, if we apply wait(60), to process and open some utube video, when we will run the test, it will wait for complete 60 seconds and do not move to the next page even the video opened but with sync
How to Apply: We can apply “sync” by editing the code in expert view
Example: Browser("Google").Page("UrduPoint Network, Urdu").Sync

2) Wait
Syntax: wait(n)…… same for Web and Desktop applications
Description: This statement instruct QTP to stay (waits) on the same page for specified 'n' seconds even though process has occurred in less than n seconds
How to Apply: we can apply “wait()” by editing the code manually in expert view after a test is recorded.
For Web Application: wait(10) ….. it will stay on the same page for 10 seconds
For Desktop Application: same as above

3) Wait Property
Syntax: Browser("Browser").Page("Page").WebElement("WebElement").WaitProperty "property name", property value, timeout(time in miliseconds)
For Desktop: Window("Window").WinObject("Window Object").WaitProperty property name", property value, timeout(time in miliseconds)
Description: Here wait property contains 3 things as you can see above, the Property Name list contains the test object properties associated with the object. Select the property which you want to use for the Synchronization Point.
Next comes the Property value for which QTP should wait before continuing to the next step in the test.
Then enter the Synchronization Point timeout (in milliseconds) after which QTP should continue to the next step, even if the specified property value was not achieved or if the specified value was achieved in less time even then it will wait for the specified milliseconds.
How to Apply: Synchronization point can be added while recording without writing any code from “Insert  Synchronization point” it will open your web page, here click the object  “object selection – Synchronization Point” pop up opens  here select the object  after clicking on any object “Add Synchronization Point” pop up opens  here select property name, enter property value and timeout. We can also add wait property by editing in expert view after a test is recorded.
For web Application: Browser("Google").Page("UrduPoint Network, Urdu").WebElement("WebElement").WaitProperty "abs_x", page, 50000
For Desktop Application: Window("Flight Reservation").WinObject("Insert Done").WaitProperty "text", text,30000

NOTE: There is a mistake done by beginners is to apply and try to find synchronization point after stopping the recording.

4) Exist
You can enter Exist and/or Wait statements to instruct QuickTest to wait for a window to open or an object to appear. Exist statements return a boolean value indicating whether or not an object currently exists. Wait statements instruct QuickTest to wait a specified amount of time before proceeding to the next step. You can combine these statements within a loop to instruct QuickTest to wait until the object exists before continuing with the test.
For example, the following statements instruct QuickTest to wait up to 20 seconds for the Flights Table dialog box to open.
blnDone=Window("Flight Reservation").Dialog("Flights Table").Exist
While Not blnDone
Wait (2)
blnDone=Window("Flight Reservation").Dialog("Flights Table").Exist
If counter=10 then
End if

No comments:

Post a Comment