## WINRUNNER 4.03 with Beta Netscape Extensions. ## Netscape test script. Hopefully Mercury will make the scripting language between ## Netscape and MSIE identical or very similar, so that scripts will be portable between ## the two browsers. This will allow for very easy testing on multiple platforms and ## multiple browsers. (By default we will be able to test specialized AOL browsers ## BellSouth.net and other derivatives of the mainstream browsers.) ## Functions ################################################################### # sync_point () is a function whose purpose is to perform the generic task of # ensuring that the web page has loaded. Any easy modification would be to have # sync_point take a time limit before timeout, and you could vary this global URL # load timeout variable depending on if you were on a LAN or modem. ################################################################### public function sync_point (PointName) { # Declare local variables static end, start, elapsed; # Sync point, allows scripts to be used with modems and LANs # Get the start time of the wait for the URL to load start = get_time(); # Set the window to the Netscape Main Window set_window ("Netscape Main Window", 10); # The actual sync point. Wait for the big N and commets to stop. if (obj_wait_bitmap("NSAnimation", "Img2", 30, 3, 1, 34, 32) == E_OK) { report_msg ("The URL "&PointName& " loaded successfully."); end = get_time(); # compute the total time to load the URL elapsed = end - start; report_msg ("The total time for the page to load was "&elapsed & " seconds."); } else { report_msg("The URL " &PointName& " did not load successfully"); } } ################################################################### # function web_test is the actual 'guts' of the tests. The idea is to isolate the # actual web tests, so that if we have something like a Diamond Stealth 3d # we can test at one resolution, do a hot swap, and test at a lower resolution. # You could even have seperate bitmap captures etc. The main idea will # be to make sure that the end user can get to all the links at any resolution. # Sometimes web developers use settings such as invisible frames, which # can make a website inoperable at lower resolutions. ActiveX controls and # Java applets can also be very size sensitive and the multiple resolutions # should catch that as well. ################################################################### public function web_test ( resolution) { report_msg ("The current test resolution is " & resolution & "."); # If we were doing a browser generic package we might have to pass in # a variable on the win activiates or do something else creative. win_activate ("Netscape Main Window"); set_window ("Netscape Main Window", 10); menu_select_item ("File;Open Page... Ctrl+O"); set_window ("Open Page", 10); win_activate ("Open Page"); type ("http://127.0.0.1"); button_press ("Open"); # Wait for browswer to load. Important for slow connections sync_point ("PaySys Home Page"); # end sync win_activate ("Netscape Main Window"); set_window ("PaySys Home Page", 10); link("PaySys International, Inc.,"); sync_point ("Company Page"); set_window ("Paysys Company", 10); win_activate ("Netscape Main Window"); set_window ("Netscape Main Window", 10); obj_mouse_drag ("Afx:400000:8:15d6:10:0", 27, 16, 26, 16, LEFT); set_window ("PaySys Home Page", 10); image_link("main_image_paysys", 52, 254); # Wait for browswer to load. Important for slow connections sync_point ("Customers Area"); # end sync win_activate ("Netscape Main Window"); set_window ("Netscape Main Window", 10); obj_mouse_drag ("Afx:400000:8:15d6:10:0", 27, 16, 27, 17, LEFT); set_window ("PaySys Home Page", 10); image_link("main_image_paysys", 53, 31); # Wait for browswer to load. Important for slow connections sync_point ("Career Area"); # end sync set_window ("PaySys Career Opportunities", 10); link("Online Resume"); # Wait for browswer to load. Important for slow connections sync_point ("Resume"); # end sync ###### FORM COMPLETION ###### # Here is an example of filling out a form. Notice that the Netscape extensions # to WinRunner actually grab the actual object names. Notice that the list # select isn't grabing the text to select. (COME on mercury!) set_window ("PaySys Personnel File", 10); edit_set_insert_pos ("CurrentTitle", 0, 0); type ("Quality Engineer"); list_select_item ("CurrentTime", "#3"); edit_set_insert_pos ("Responsibilities", 0, 0); type ("Currently I am testing web applications."); edit_set_insert_pos ("requisitionnumber", 0, 0); type ("ME45"); edit_set_insert_pos ("DesiredPosition", 0, 0); type ("Challenging"); edit_set_insert_pos ("RelevantExperience", 0, 0); type ("5 Years Internet Expereiie"); type ("nce"); edit_set_insert_pos ("MinimumSalary", 0, 0); type ("1,000,000"); list_select_item ("Expiration", "#3"); edit_set_insert_pos ("Contact_FullName", 0, 0); type ("Caleb"); edit_set_insert_pos ("Contact_StreetAddress", 0, 0); type ("980 Walter Blvd #2636"); edit_set_insert_pos ("Contact_City", 0, 0); type ("Lawrenceville"); edit_set_insert_pos ("Contact_State", 0, 0); type ("GA"); edit_set_insert_pos ("Contact_ZipCode", 0, 0); type ("30093"); edit_set_insert_pos ("Contact_ZipCode", 0, 4); type ("4"); edit_set_insert_pos ("Contact_Country", 0, 0); type ("US"); edit_set_insert_pos ("Contact_HomePhone", 0, 0); type ("770 2771096"); edit_set_insert_pos ("Contact_Email", 0, 0); type ("calebb@bigfoot.com"); button_press ("Submit Information"); # Here is a typical security wrench. Make sure you do a win_exists or # some other test to test for security at any submit area. Be careful # about loading all of the plugins and setting security to low on your test # machines. This is a good reason to use something like partition magic # and create clean test machines after EVERY major test run. Further # it would be a good idea to test the web site at high browser security setting # medium, and low. set_window ("Security Information", 10); button_press ("Continue"); # Wait for browswer to load. Important for slow connections sync_point ("PaySys Home Page"); # end sync } # main() # The main starting point of our scripts begin here. Notice that we load the gui map here. # We could easily unload the netscape and reload an IE or AOL GUI map. # Remember we want to do two types of testing from the browser perspective: # 1. Browser testing on the mosts popular browsers for our test site. WUT (Web Under Test?) # 2. HTML verification to ensure that our HTML is 3.2 or 3.0 compliant. Currently # no test tool that I am aware of supports HTML verification. # Web tools such as Hotmetal will do this and you can probably expect it as the # web test environment matures. # Initialization of script # Set up GUI maps GUI_close_all (); GUI_load("c:\\mercury\\wrun40\\tmp\\netscape.gui"); # Load Netscape set_window ("Program Manager", 10); list_activate_item ("SysListView32", "Netscape Navigator"); # Item Number 4; win_wait_info("Netscape Main Window","displayed",1,65); if ( win_exists("Netscape Main Window",0) != E_OK) { report_msg ("Error, the netscape window did not load in the allowed time."); } # Make sure netscape window is positioned and in correct location win_activate ("Netscape Main Window"); win_move ("Netscape Main Window", 11, 5); # Start testing at different resolutions if (win_exists ("Netscape Main Window", 0) == E_OK) { #Begin testing because Netscape loaded. web_test ("1024x768x16bpp"); set_window ("Program Manager", 10); obj_mouse_click ("SysListView32", 52, 529, RIGHT); # The command to switch our video card to a different resolution. menu_select_item ("Switch Desktop;800 x 600 x 16 bpp Ctrl+F2"); web_test("800x600x16bpp"); } else { report_msg ("Aborted testing because Netscape was not loaded."); }