Tuesday, September 25, 2007

Example of Sync

Make sure that your internet is On and QTP is open.

Click on Record. When we click on Record, "Record and Run Settings" window opens up. Go to "Web" tab and choose first option "Record and run test on any open browser." and click on ok.

Open internet explorer (make sure your default page is www.google.com, so that when you open internet explorer, it by default opens google.com as homepage..)

Type Blogger in the search text box and click on "I'm Feeling Lucky" button instead of Search button.

When www.blogger.com is open (i.e. when you see 'Done' on the status bar at the bottom) , click on Back toolbar button (below File menu) to go back to google.com again.

Go toFile(Menu)->Exit.

It will record the following code with sync automatically recorded by QTP (see 4th step).


1)SystemUtil\Program files\Internet Explorer\IEXPLORE.EXE","","C:\Documents and Settings\Sachin","open"
2) Browser("Google").Page("Google").WebEdit("q").Set "blogger"
3) Browser("Google").Page("Google").WebButton("I'm Feeling Lucky").Click
4) Browser("Google").Page("Blogger: Create your Blog").Sync
5) Browser("Google").Back
6) Browser("Google").WinToolbar("ToolbarWindow32").Press "&File"
7) Browser("Google").WinMenu("ContextMenu").Select "Close"

Try to run this code, it works fine.

Now go to File(Menu)->Settings, Web tab and change the 'Browser navigation Timeout' to 2 seconds for example and then run the above code again. It will fail because sync method waits for the browser to complete the current navigation, but here we have set the browser navigation timeout to 2 seconds, which is too short for a browser to complete the navigation i.e. to open www.blogger.com after clicking on "I'm Feeling Lucky" button (I am not on T1 lines, my internet connection is average), because what happens is, after the 3rd step it just waits for 2 second after which it goes to the Back button, but it finds it disabled as it gets enabled only when www.blogger.com is open.

Keep 'Browser navigation Timeout' to 10 seconds in File(Menu)->Settings and then it should pass because in 10 seconds it surely makes the back button enabled after the 3rd step of clicking "I'm Feeling Lucky".