Tips and Tricks for Testing HTML Applications

This topic provides tips and tricks for recording and playing back scripts to test HTML applications.

Start Recording First and then Start the Application

When recording scripts on your HTML applications, use Functional Tester to start the application during recording. Functional Tester opens the HTML page that you specify in your default browser or in a specific browser.

Recording a Hover on HTML Menus

When recording scripts on your HTML applications, you can record a hover on drop-down menus that are activated when you roll the mouse over the drop-down menu. These drop-down menus are implemented with DIV tags. To record a hover for drop-down menus, and make the sub-menu drop down, hover the mouse over the menu item text and press Shift. Make sure the mouse is on the text of the menu item and not on the blank space to the right of the menu item text.

Use deleteCookies Method in Your Scripts

Two versions of the deleteCookies method are available. One method deletes all cookies for the current profile or user and the other method deletes cookies in a specific path or domain for the current profile or user. For information, see the Functional Tester API Reference, in the com.rational.test.ft.object.interfaces package, under IBrowserObject.

Avoid Including Menu Items in Scripts

Because selections on browser menus are recorded based on their screen coordinates, scripts may not play back reliably if the browser size or position change. Also, menus are different on different browsers, which may also cause scripts to play back incorrectly.

Make Sure Java Applets are in Full View During Playback

If you resize the browser to a smaller size, Functional Tester does not scroll the applet objects into view during playback if they are not in view.

Use the loadURL( ) Method to Change URLs

The location of the Address field in a browser is based on screen coordinates, which can change if the browser's size and position change. A script usually fails if you click in the Address field and type the new URL. When recording, insert a browser click (Browser_htmlBrowser) in your script to change URLs:

Using .size Property for INPUT Elements

If you use .size Property for INPUT elements and do not specify the .size property within the Html of an INPUT element, the default value returned by the Internet Explorer is 20 and by Netscape is 0 (zero).

Use Toolbar Buttons Common to Both Browsers

When you create a cross-platform script, avoid toolbar buttons that only appear in one browser. The following toolbar buttons are common to both browsers:

Use the Close Button to Exit a Browser

The Close button is available on both the Internet Explorer and Netscape. When you record a cross-platform script, avoid using alternative methods of exiting the browser. For example, pressing Alt+F+C works only for Internet Explorer and pressing Alt+F+X works only for Netscape. Either key combination causes a script to fail when run on the other browser.

Use waitForExistence Method to Compensate for Browser Startup Speed

Because Netscape takes longer to start than Internet Explorer, use a waitForExistence method when recording cross-browser scripts to wait for a browser. For example:

Avoid these Click and Key Combinations in Cross-Platform Scripts

To handle a pop-up menu, Netscape ignores a click on a link immediately following a right-click. When this click combination is necessary, right-click the link, click an empty space in the document, and then click the link. Although this is only necessary in Netscape, it is good practice for Internet Explorer.

In Netscape, pressing Ctrl and clicking a link opens the page in another instance of Netscape. In Internet Explorer, this same key sequence results in a normal link click. A script that contains this combination of actions plays back differently and should be avoided for cross-browser testing.

In Netscape, when you right-click an item in a list box and then click an item, Netscape ignores the click. When this click combination is necessary, right-click the item, click an empty space in the document, and then click the subitem in the list box.

Run a Utility to Fix Badly Formed HTML

Occasionally errors in HTML can cause different browsers to interpret the HTML DOM hierarchy differently. A script that runs successfully in one browser can fail in another. Record one script against each browser and compare the resulting test object maps. If the maps show a different hierarchy, run a utility, such as HTML Tidy. If the utility reports errors, it is possible that the errors are causing the different interpretations of the object model, resulting in different hierarchies. HTML Tidy is available from the World Wide Web Consortium, www.w3.org.

Handling Pop-Up Message Boxes

When recording a script in Netscape, pop-up message boxes (browser user interface dialog boxes), such as encryption notices occasionally appear. When recording a cross-browser script, you do not want to include these message boxes, because they usually do not appear in Internet Explorer. To avoid this problem:

    1. When a pop-up message appears, pause recording.

    2. Select any check box on the message that prevents the message from appearing again.

    3. Click Cancel to close the message box.

    4. Resume recording.

You can modify your script to handle these kinds of message boxes, but the code can be complicated. For more information, see Advanced Topics for Functional Tester, Java Scripting or Functional Tester, VB.NET Scripting.

When you record a cross-browser compatible script, try to avoid recording any pop-up message boxes. If you are not recording a cross-browser compatible script, you can record pop-up message boxes in your script.

Functional Tester supports the Login, File Download, Certificate/Security Warnings, File Picker (File Open/File Save), and Print dialog boxes on the Windows platform. These user interface dialog boxes are for a specific browser and are not cross-browser compatible. In most cases, the Login dialog box is cross-browser compatible.

Testing URLs without Configuring the Application.

When you configure an application, Functional Test adds the application name to the Application Configuration Tool. If you test a lot of different URLs, the Applications list can become long. If you do not want to add a URL to the list, you can use the startBrowser command in an empty script to test it.

  1. Create a new Functional Tester script without recording.

  2. On a blank line, type the following command:

  3. where url is the URL you want to test.

  4. Save the script and run it.

  5. When the page is displayed, on the Functional Test toolbar, click Insert Recording into Active Functional Tester Script Insert Recording into Active Functional Tester Script button and start recording against the page.

Testing HTAs

Functional Tester supports testing Microsoft HTML Applications (MSHTA). Before you can test a MSHTA, you must configure it by running mshta.exe. To configure each HTA you want to test:

    1. In the Kind field of the Application Configuration Tool, select executable or batch.

    2. In the Executable file field, select mshta.exe.

    3. In the Args field, pass the parameter x.hta to the executable, where x is the name of the HTA file.

For more information, see Configuring Applications for Testing.

Perform Remote Testing through TestManager

If TestManager is installed, use it to test HTML applications remotely on Linux computers. For information, see About Local and Agent Computers.

Handling Java Plug-in Errors

If an error about the Java plug-in is returned, when you test HTML applications or start the Comparator from the View Results link in the HTML log, you need to verify that your browser's Java plug-in is configured properly. For instructions, see Enabling the Java Plug-in of a Browser.

Note About TestManager Integration

Functional Tester is integrated with Rational TestManager version 2003.06.13. If you have the 2003.06.13 version of TestManager, you will be able to use the integrated features of Functional Test and TestManager. Please see Understanding Functional Tester Product Packaging and Integrations for important information on using the products together.

Terms of use | Feedback
(C) Copyright IBM Corporation 2002, 2004. All Rights Reserved.