Consider this program,
SystemUtil.Run "iexplore.exe", "http://www.gmail.com"Browser("Gmail: Email from Google").page("Gmail: Email from Google").SyncBrowser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Email").Set "swatiseela"Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Passwd").SetSecure "sfgs686898"Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebButton("Sign in").ClickBrowser("Gmail: Email from Google").Page("Gmail - Inbox").Link("Sign out").Click
In an ideal world, as soon as you hit the “Sign in” button in the gmail login page, the “Inbox” should get displayed without any delays. That means, the state of the application is ready for the last statement in our example to be executed immediately after the last but one statement runs.
But in real time, due to many reasons applications don’t always load at the same pace. If we do not instruct QTP to wait a certain while before it moves on. More specifically until an object attains a certain state.
A synchronization point is used to instruct QTP to wait until a particular object property achieves the value you specify.
On inserting a sync point a “Wait Property” statement is inserted into the test.
Browser("Gmail: Email from Google").Page("Gmail - Inbox"). Link("Sign out").WaitProperty “Visibile”,true,20
So your new program is going to look something like this: (line #6 below)
SystemUtil.Run "iexplore.exe", "http://www.gmail.com"Browser("Gmail: Email from Google").page("Gmail: Email from Google").SyncBrowser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Email").Set "swatiseela"Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Passwd").SetSecure "sfgs686898"Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebButton("Sign in").ClickBrowser("Gmail: Email from Google").Page("Gmail - Inbox"). Link("Sign out").WaitProperty “Visible”,true,1000Browser("Gmail: Email from Google").Page("Gmail - Inbox").Link("Sign out").Click
It can be inserted while recording using the menu option “Insert->Synchronization Point”. Choose the Object to insert the sync point.
Enter the value as required:
This is the statement that gets inserted:
Browser("Gmail - Inbox").Page("Gmail - Inbox").Link("Sign out").WaitProperty "visible", true, 10000
No comments:
Post a Comment