Skip Headers
Oracle® Functional Testing OpenScript User's Guide
Version 9.20

Part Number E15488-05
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

5 Using the Web Functional Test Module

This chapter provides instructions on configuring and using the OpenScript Web Functional Test Module, which tests Web-based applications by accessing objects through the Document Object Model (DOM) of the Web browser.

5.1 About the Web Functional Test Module

The OpenScript Web Functional Test Module is an application module that supports functional testing of Web-based applications that uses the Web Document Object Model (DOM). OpenScript provides a flexible and easy-to-use scripting interface for both Technical Testers and Non-Technical Testers. The OpenScript Functional Test Module enables script creation from both the code view and GUI view scripting interfaces.

The Functional Test Module extends the OpenScript platform with Document Object Model (DOM) recording and playback capabilities. The DOM recorder automatically captures Web page objects, actions, and navigations and records them as tree view nodes (with the underlying code in the Code View) in the script. The Functional Test Module also provides additional GUI script modification options. Web Functional Test Scripts differ from HTTP Scripts. Even though both are used to test web applications, HTTP scripts automate the underlying HTTP network protocol, whereas Web Functional Test scripts automate the browser UI.

The Web Functional Test Module is an extension module to the Oracle OpenScript platform that extends the platform with Web Functional Test recording and playback capabilities. The Web Functional Test Module is fully integrated with the OpenScript platform including the Results view, Details view, Properties view, Console/Problems views, Preferences, Step Groups, Script Manager, and Workspace Manager.

The Web Functional Test recorder displays commands in the Tree View in easy-to-understand commands. By default, script commands are grouped into Steps Groups by the Web page on which they were performed. Each Step Group contains one or more script commands corresponding to recorded actions that were performed on the page. The default name for the Step Group is the Web page Title (as specified in the "Title" tag).

OpenScript shows the results of Web Functional Test script playback in the Results view. The Results view shows results for each script command (including duration and summary for failures). The Results Report compiles the same information into an HTML Results Report. Results can be exported from the OpenScript GUI in standard format (CSV / HTML). Results are also generated for unattended playback through the command line.

The Web Functional Test Module API includes a "Web" class that provides additional programming functionality.

5.1.1 Key Features of the Web Functional Test Module

The Web Functional Test Module provides the following functionality:

  • Records Document Object Model objects and actions for playback automation. The objects and actions can be generated by a Web browser (i.e. IE or Firefox).

  • Plays back functional testing scripts to validate proper functionality. Playback runs interactively in the OpenScript user interface. Playback runs interactively in the OpenScript user interface and is also supported in Oracle Test Manager.

  • Provides full script code view integration to support script generation for the Web Functional Test Module. The Web Functional Test Module includes an additional API to support Web Functional Test protocol code scripting.

  • Allows users to parameterize user inputs to Functional Test scripts and drive those inputs from an external data file (Databank).

  • Allows users to insert test cases for validation of objects and actions.

  • Provides additional options/settings that are specific to Functional Test scripts within the Functional Test categories in the preferences interface.

  • Reports playback results for Functional Test scripts in the Results and Console views.

5.2 Recording Web Functional Tests

The Web Functional Test Module records Document Object Model objects and actions in a Web browser for playback automation. The Recorder creates functional and regression test scripts for automating GUI applications in a browser.

OpenScript records standard Web DOM objects (links, images, forms, form elements, etc.) and events (click, mousedown, focus, etc.) for playback. Web DOM objects are identified by one or more attribute as configured through the Web Functional Test Record Preferences under Object Identification. Object Identification attributes can later be modified by users through the Preferences global settings for new scripts or for already recorded commands in the tree view or code view. All Web DOM objects, events and attributes should be supported. Recording can be configured through Internet Explorer or Firefox. You can set the browser type in the Preferences.

The Web Functional Test Module provides a record toolbar button that lets you initiate the Web DOM recorder and capture Web page actions to the script view. The record toolbar includes start and stop recording toolbar buttons. OpenScript recorders also open a floating toolbar that can be used while recording without having to switch between the browser and OpenScript.

5.2.1 Setting Web Functional Test Record Preferences

Before recording Web Functional Test scripts, set Web record preferences.

  1. Start OpenScript.

  2. Select OpenScript Preferences from the View menu.

  3. Expand the OpenScript node and the Record category.

  4. Select Web Functional Test.

  5. Click the General tab and set the general recording preferences as follows:

    Browser: Specify the browser options that will be used during Web Functional test recording.

    • Always launch a new browser when recording a different script: When selected, a new browser opens each time a new script is recorded.

    Miscellaneous: Specifies the miscellaneous record settings.

    • Capture Screen Shots: When selected, screen images are captured during recording.

    • Capture HTML: When selected, page source HTML is captured during recording.

    • Capture URLs: When selected, the page URL will be captured.

    • Capture Frames: When selected, the HTML frames on the page will be captured.

    • Ignore Auto Page: When selected, server-side auto pages are ignored during recording.

    • Action Cache Interval(s): Specifies how often to cache page actions during recording. The following cases are determined by this setting:

      If while recording, the text on the same Web page element is changed within the Action Cache Interval time setting, the previously recorded value will be replaced by the changed value. In the Java code, the setText action will be replaced with the changed value.

      If while recording, a browser window closes within the Action Cache Interval after a user performs an action on a web page (for example, a button click) the window close event will not be recorded, as the window close event is considered to be caused by the previously performed action.

    • Record "waitForPage actions: When selected, the script recorder generates "wait for page" actions for test steps that generate a page transition in the browser. When cleared, the script recorder generates a "capture page" action for test steps that generate a page transition in the browser. For Web functional test scripts, the "wait for page" action is the normal record option. See the Siebel Functional test record preferences for additional information.

    • Create Title Test for every Page: When selected, The Web Functional Test recorder automatically inserts a page title test for every page recorded. The page title test compares the recorded page title to the page title received during playback. The default test does not stop playback if the page title comparison fails. When cleared, page title tests are not inserted during recording.

    • Create HTML Test for every Page: When selected, The Web Functional Test recorder automatically inserts an HTML test for every page recorded. The HTML test compares the recorded HTML to the HTML received during playback. The default test stops playback if the HTML comparison fails. Select the result in the Results view and view the differences in the Comparison tab of the Details view. When cleared, page HTML tests are not inserted during recording.

  6. Click the Object Identification tab and use Add or Edit to customize the object identification elements or attributes.

  7. Click OK when finished.

5.2.2 Adding/Editing Object Identifiers

The Web Functional Module uses object identification to specify attributes used to identify Web objects. The Web Functional Test Module includes predefined path attributes for common Web objects. Object paths are specified in XPath format. For example, for web objects, the object identification path appears as follows in Java code commands:

/web:window[@index='0']

   /web:document[@index='0']

   /web:form[@index='0']

   /web:input_text[@id='ticker' or @name='ticker' or @index='0']


You can set the default object attributes in the Web Functional Test Module Record Preferences. You can also edit object attributes in recorded scripts in the tree view or the code view.

In addition to the predefined object identification, you can add an Object Library to the script to record paths into a library file. Object Library files may be shared and reused across other scripts. The Object Library files provide a more convenient "short name" for objects to provide for more convenient programming.

The Web Functional Test Module includes object identifiers that specify how the recorder identifies Browser objects. You can add object identifiers or edit the existing object identifiers in the Record preferences.

To add or edit an object identifier:

  1. Select the OpenScript Preferences from the View menu.

  2. Expand the Record node and select Web Functional Test.

  3. Click the Object Identification tab.

  4. Click Add or select an existing object identifier and click Edit.

    The Object Element dialog box lets you define an object identifier for a Web Functional Test recorder. The object identifier specifies how the OpenScript Web Functional Test recorder module identifies web objects in the Document Object Model on a Web page.

    Active Profile: Specifies which object identification profile to use as the active profile when recording scripts. Profiles define a specific set of object identifiers to use when recording Web functional tests. Use the Add Profile option to create a new custom profile. Once you have created a profile, select the profile name in the Name column and use Add Object to define custom objects and attributes in the custom profile.

    Name: Shows the name(s) of the defined Web object identifiers.

    Attributes: Shows the pattern(s) specified for the defined Web object identifiers.

    Add Profile: Opens a dialog box for specifying a new Web object identifier profile.

    Add Object: Opens a dialog box for specifying a new Web object identifier.

    Edit: Opens a dialog box for editing the selected Web object identifier or profile.

    Delete: Deletes the selected Web object identifier or profile. The default profile cannot be deleted.

    Export: Opens a dialog box for exporting the currently selected Web object identifier profile to an XML file. Select the profile name in the Name column to activate the export option.

    Import: Opens a dialog box for importing the currently selected Web object identifier profile to an XML file. Select a profile name in the Name column to activate the import option.

    Revert: reverts the default Web object identification profile to the default profile. Any changes to the default profile are removed. Select the default profile name in the Name column to activate the revert option.

    For each object element, you specify a name (typically a Web object attribute), an operator, a value and a value type. As you add object elements, OpenScript builds the object identifier using logical OR between each object identifier element. Click Edit to change between logical OR and AND.

  5. If adding a new object identifier, click Add Object and specify the path segments for the object identifier.

    The Path Segment dialog box lets you define a segment of an object identifier for a Web Functional Test recorder. The object identifier specifies how the OpenScript Web Functional Test recorder module identifies web objects in the Document Object Model on a Web page.

    Attribute: When selected, specify the name, operator, value, and value type for the object identifier.

    • Name: Specify the name of the Web object attribute to use to identify the object.

    • Operator: Specify the logical operator to use to identify the object value.

    • Value: Specify the value of the Web object attribute to use to identify the object.

    • Value Type: Specify the value type to use to identify the object. The value type can be a string, a number, or by variable reference. Set the Value type to match the specified value.

      • String: The value in the Value field will be matched as a text string to identify the Web object.

      • Number: The value in the Value field will be matched as a numeric value to identify the Web object.

      • Reference: The value in the Value field will be matched as a variable name to identify the Web object.

    Group: when selected the Web object identifier can be specified as a string representing a logical group of Names, Operators, and Values.

  6. If editing an existing segment, click Edit and specify the path attributes for the object identifier.

    The Path Attribute dialog box lets you edit an element of an object identifier.

    Name: Specify the name of the Web object attribute to use to identify the object.

    Operator: Specify the logical operator to use to identify the object value.

    Value: Specify the value of the Web object attribute to use to identify the object.

    Value Type: Specify the value type to use to identify the object. The value type can be a string, a number, or by variable reference. Set the Value type to match the specified value.

    • String: The value in the Value field will be matched as a text string to identify the Web object.

    • Number: The value in the Value field will be matched as a numeric value to identify the Web object.

    • Reference: The value in the Value field will be matched as a variable name to identify the Web object.

    And/Or: specifies logical OR or AND between object elements. This option does not appear if the object element being edited is the last object element in the object identifier group.

  7. If editing an existing path, click Edit and specify the path attributes for the object identifier.

    The Path Attribute Group dialog box lets you edit an object identifier group as a string value.

    Group: A text string of the object identifier group. The object identifier group syntax follows the @name operator value/type format. Values by reference are enclosed in double curly braces {{}}. String values are enclosed in single quotation marks. Numeric values are not enclosed. Logical OR or AND are used between object elements. Parenthesis are used for logical grouping of multiple object elements. Object identifiers can use the wildcard characters * (asterisk) for multiple characters and ? (question mark) for single characters. For example, @text="Login*". The following are examples of object identifier group syntax:

    @index={{index}} or @title='title' or @number=5
    
    
    @text={{text}} or @href={{href}} or @index={{index}}
    
    
    (@id={{id}} or @name={{name}} or @index={{index}}) and multiple mod {{multiple}}
    
  8. Click OK when finished adding or editing segments or attributes. The object identifier is added to the record preferences.

  9. If you have the browser open when adding or editing object identifiers, close and restart the browser.

5.2.2.1 Available Attributes for Web DOM Elements

The following table lists the attributes available for Web Document Object Model objects.

Element Attributes
Common attributes for all web DOM elements tag, id, index, title, style, class, html, _adftrueval, rn, un, ot
web:window index, title
web:document index, url
web:a disabled, text, href
web:button type, name, value, disabled, text
web:input_button type, name, value, disabled, text
web:input_file type, name, value, index, disabled, size
web:input_hidden type, name, value, index, disabled
web:input_image type, name, disabled, alt, align, border, height, hspace, src, lowsrc
web:input_submit type, name, value, disabled, text
web:input_text type, name, value, defaultValue, disabled, maxlength, readOnly, size
web:input_check type, name, value, disabled, checked, defaultChecked, readOnly, size
web:input_radio type, name, value, disabled, checked, defaultChecked, readOnly, size
web:img alt, height, longdesc, name, src, width
web:option value, text, optionIndex(index in the select), defaultSelected, selected
web:select name, disabled, value, selectedIndex
web:textarea name, disabled, value, defaultValue, readonly, cols, rows

5.2.3 Recording Web Functional Test Scripts

To record Web Functional Test scripts:

  1. Start OpenScript.

  2. Set the Web Functional Test Recording preferences.

  3. Select New from the File menu.

  4. Expand the Functional Testing group.

  5. Select Web.

  6. Click Next.

  7. Select the Repository and Workspace.

  8. Enter a script name.

  9. Click Finish. A new Script tree is created in the Script View.

  10. Select Record from the Script menu. The browser automatically opens when you start recording.

  11. Load the web page where you want to start recording into the browser.

  12. Navigate the web site to record page objects, actions, and navigations. The page objects, actions, and navigations will be added to the node of the script tree specified by the Set Record Section setting (the Run node is the default).

  13. When finished navigating pages, close the browser.

  14. Select Stop from the Script menu or click the Stop button on the OpenScript toolbar.

  15. Expand the Run node of the script to view the page objects, actions, and navigation nodes in the script tree.

    You can customize the script using the menu options or the Code View for specific testing requirements.

    Note:

    Do not close the script editor view or script project while recording or playing back scripts. Doing so could result in unpredictable behavior in the OpenScript application.

5.3 Playing Back Scripts

OpenScript plays back recorded Web actions/commands which consist of an event plus an object identified by its attributes (for example: click link(text="Home")). The actions used for playback will either be those that are recorded or are specified manually in the Java Code view. Playback can be configured through Internet Explorer or Firefox. Unattended playback is supported through Oracle Test Manager or third-party tools using OpenScript's command line interface. Web Functional Test scripts do not play in Oracle Load Testing.

The Web Functional Test Module provides playback and iterate toolbar buttons that allows users to start the script playback for either a single playback through the script or multiple iterations using data from a databank file. Playback results for Web Functional scripts can be viewed in the Results and Console views.

5.3.1 Setting Web Functional Test Playback Preferences

To set Web Functional Test Playback preferences:

  1. Start OpenScript.

  2. Select OpenScript Preferences from the View menu.

  3. Expand the OpenScript node and the Playback category.

  4. Select Web Functional Test.

  5. Expand the Object Timeout group and set the preferences as follows:

    Timeout(S): Specifies the maximum number of seconds OpenScript should wait for an object to appear before considering the object not found. This is the default timeout when waiting for an object to appear before invoking an action against it. This is also the default timeout when waiting for an object to appear before continuing the script.

    You can override individual object wait timeouts in waitForPage() or object.waitFor() by editing their "timeout" properties. Action timeouts cannot be overridden.

  6. Expand the Capture Screenshot Interval group and set the preferences as follows:

    Delay time for capture screenshot: Specifies the amount of time to wait before capturing a screenshot of the page.

  7. Expand the Object Tests group and set the preferences as follows:

    Date Format: Specifies the month, day, year, and time format. The Date Pattern follows standard Java SimpleDateFormat string conventions. The default value is MMM d, yyyy h:mm:ss a (month, day, year, hour, minutes, seconds, am/pm).

  8. Expand the Miscellaneous group and set the preferences as follows:

    Capture HTML: When selected, the page HTML will be captured.

    Capture screenshots: When selected, screenshots of the pages are captured during playback. Screenshots can be viewed by selecting a WaitForPage result in the Results view and then selecting the Screenshot tab in the Details view. Captured screenshots will increase the size of scripts when exported to zip files.

    Capture URLs: When selected, the page URL will be captured.

    Capture frames: When selected, the HTML frames on the page will be captured.

    Clear session cookies between iterations: When selected, session cookies are cleared from cache between playback iterations.

    Clear persistent cookies between iterations: When selected, persistent cookies are cleared from cache between playback iterations.

    Clear cache between iterations: When selected, pages are cleared from cache between playback iterations.

    Clear session cookies before playing back: When selected, session cookies are cleared from cache before playback.

    Clear persistent cookies before playing back: When selected, persistent cookies are cleared from cache before playback.

    Clear cache before playing back: When selected, pages are cleared from cache before playback.

    Log JavaScript event for actions: When selected, script playback creates a log of the Javascript events (such as onmouseover, onmousedown, click, etc.) fired on HTML elements. This is useful for troubleshooting scripts that do not playback properly pages that include Dynamic HTML(DHTML) using javascript.

    With Internet Explorer browsers, the log file is save to <installdir>\OpenScript\Oracle IE ToolBar\WebDOMToolBar*.log. With Fire Fox browsers, the logs can be accessed from the Tools menu. Select Error Console then Message.

    The Web Functional Test module API provides these API methods that can be added to the script Java Code, if necessary, to handle events that do not playback properly: web.element("path").fireEvent("eventName") and web.element.setSelectedJSElement().

    When cleared, no logs are created.

    Always launch a new browser when playing back a different script: When selected, script playback always launches a new browser when playing back a different script. When cleared, a script never reuses a browser launched by a previously run script.

  9. Click OK when finished.

5.3.2 Playing Back Web Functional Scripts

To play back Web Functional scripts:

  1. Start OpenScript.

  2. Open the Web Functional script to play back.

  3. Select Playback from the Script menu or click the toolbar button.

    You can view the progress of the script playback in the Console View. You can review the results of script playback in the Results View.

5.3.3 Playing Back Web Functional Scripts with Iterations

To play back Web Functional scripts with iterations:

  1. Start OpenScript.

  2. Open the Web Functional script to play back.

  3. Select Iterate from the Script menu or click the toolbar button.

  4. Select Use Databanks.

  5. Select which databank file to specify the settings for if more than one database is configured for the script.

  6. Specify the settings for the databank file.

  7. Select the Run no more than [ ] iterations option and set the iteration count to the desired number of playback iterations. See Section 4.5, "Playing Back Scripts With Iterations" for additional information about iteration settings.

  8. Click OK.

    You can view the progress of the script playback in the Console View. You can review the results of script playback in the Results View.

5.4 Modifying Scripts

Once a script has been created/recorded, you can make modifications to customize the script for your specific testing needs.

5.4.1 Path Editor Toolbar

Several dialog boxes used to add tests use a common toolbar for editing object paths. See Section 5.2.2, "Adding/Editing Object Identifiers" for additional information about adding or editing object identification paths.The toolbar options are as follows:

Path/Window: Specifies the path to the object to test. The options available on the object path toolbar are as follows:

  • Toggle between tree and text: Toggles the path between a tree view and a text view. In the tree view, you can add, edit or delete segments of the object path using the toolbar or use the Up and Down arrows to reorder segments of the object path. In the text view, you can edit the object path directly in the text box.

  • Add: Opens a dialog box for adding a new path segment to the object path. This toolbar button is only available when the path is in tree view.

  • Edit: Opens a dialog box for editing the attributes of the currently selected path segment in the object path. This toolbar button is only available when the path is in tree view.

  • Delete: Deletes the currently selected path segment from the object path. This toolbar button is only available when the path is in tree view.

  • Up: Moves the currently selected path segment up one level in the tree. This toolbar button is only available when the path is in tree view and the selected path segment is not the highest level segment.

  • Down: Moves the currently selected path segment up one level in the tree. This toolbar button is only available when the path is in tree view and the selected path segment is not the lowest level segment.

  • Capture object in browser: Opens a capture object dialog box and starts the capture mode. Navigate to the object to capture and use options in the capture dialog box to capture the object path.

  • View object path from Object Library: Opens a dialog box for viewing both the tree view and text view of the currently selected object path.

  • Select from Object Library: Opens a dialog box for selecting an object from a saved library.

  • Save to Object Library: Opens a dialog box for saving the current object to a library.

5.4.2 Adding Browser Navigation to a Script

To add a Browser Navigation to a Script:

  1. Record a Web Functional Test script.

  2. Select the script node where you want to add the navigation.

  3. Select the Script menu and then select Other from the Add sub menu.

  4. Expand the Web Actions node.

  5. Expand the Browser node and select Navigate.

  6. Click OK.

  7. Enter the object identification path for the object. You can use the Capture or Select menu options to capture or select an object path. See Section 5.4.1, "Path Editor Toolbar" for additional information about the Path Editing Toolbar.

  8. Enter the URL.

  9. Click OK. The navigate node is added to the script tree.

    In the Java Code view, the web.window(objectId).navigate method will be added to the script code:

    web.window(1, "/web:window[@index='0']").navigate("http://testserver2/fmstocks");
    

    The Browser web actions includes additional options for browser navigation such as Back, Forward, Close, Refresh, Wait for Page, etc. Additional browser actions have corresponding Java code methods:

    web.window(1, "/web:window[@index='0']").waitForPage("http://testserver2/fmstocks/", "Stocks", true, null)
    
    web.window("/web:window[@index='0']").close();
    
    web.window("/web:window[@index='0']").back();
    
    web.window("/web:window[@index='0']").forward();
    
    web.window("/web:window[@index='0']").refresh();
    
    web.window("/web:window[@index='0']").capturePage();
    
    web.window("/web:window[@index='0']").solve("MyVariable", "(.+?)", true, 1);
    
    web.window("/web:window[@index='0']").storeResponseTime("MyRespTime");
    
    web.window("/web:window[@index='0']").waitFor(10);
    
    web.window("/web:window[@index='0']").storeAttribute("MyAttribVar", "MyAttribute");
    
    

5.4.3 Adding Web Actions on Browser Objects

The Web Functional Test Module includes actions for Browser objects that can be added to a script.

To add Web actions on Browser objects to a script:

  1. Record a Web Functional Test script.

  2. Select the script node where you want to add the action.

  3. Select the Script menu and then select Other from the Add sub menu.

  4. Expand the Web Actions node.

  5. Expand an action node and select the action.

  6. Click OK.

  7. Enter the object identification path for the object. You can use the Capture or Select menu options to capture or select an object path. See Section 5.4.1, "Path Editor Toolbar" for additional information about the Path Editing Toolbar.

  8. Click OK. The action node is added to the script tree.

    In the Java Code view, a web.object(objectId).action() method will be added to the script code:

    web.button("/web:window[@index='0']
    
       /web:document[@index='0']
    
       /web:form[@index='0' 
    
         or @id='loginform' 
    
         or @name='loginform']
    
       /web:input_submit[@name='LoginButton' 
    
         or @value='Login' 
    
         or @index='0']").click()
    

    The Web Actions node includes actions for objects such as buttons, check boxes, dialogs, images, links, tables, etc. Other object actions have corresponding Java code methods:

    web.link("/web:window[@index='0']
    
       /web:document[@index='0']
    
       /web:a[@text='Open a new account.' 
    
         or @href='http://testserver2/fmstocks/_NewAccount.asp' 
    
         or @index='0']").click()
    

    or

    web.select("/web:window[@index='0']
    
       /web:document[@index='0']
    
       /web:form[@index='0']
    
       /web:select[(@id='namespace' 
    
         or @name='namespace' 
    
         or @index='0') 
    
         and multiple mod 'False']").selectOptionByText("[select product]");
    

    or

    web.clearSessionCookies();
    
    web.clearAllPersistentCookies();
    
    web.clearPersistentCookies("domain");
    
    web.clearCache("domain");
    
    

5.4.4 Adding Object Libraries to a Script

To add Object Libraries to a script:

  1. Open or create a Web Functional Test script project.

  2. Select the Script menu and then select Script Properties.

  3. Select the Script Assets category and select Object Libraries.

  4. Click Add.

  5. Specify the library file and alias:

    • If you have already created an Object library file, select the file in a repository.

      Note:

      Any scripts you plan to run, along with any associated assets, in the Oracle Load Testing application must be stored in a repository/workspace that can be accessed by the Oracle Load Testing Controller. If you create new repositories in OpenScript, you should also add the new repositories in Oracle Load Testing.
    • If you have not created a library file, enter a file name, and click OK. A new file will be created. When you record a Web Functional Test script, the browser actions will be automatically added to the object library file.

  6. Click OK. The Object Library file is added as a script test asset under the Object Libraries tree. Script test assets are referenced in the assets.xml file located in the script directory of the repository.

  7. Click OK.

  8. Record a Web Functional Test script to use the object library.

    The object identification paths for browser objects will be automatically added to the object library file during recording. You can open and edit the object library file using the Object Library Editor. Select Script Properties from the Script menu, select the Object Library Test Asset in the tree and click Open. The Object Library editor view opens in the Workbench with the objects and details included in the selected Object Library. You can add objects to and delete objects from the Object list. You edit the object attributes in the object string or in the tree hierarchy of the Details section. The tree hierarchy lets you move attributes up or down in the priority order.

  9. Save the script when finished.

5.4.5 Adding a Server Response Test

You can use Server Response Tests to report an error and/or abort the script if a Web page does not return back to the client within a specified time range.

To add a Server Response Test to a script:

  1. Record a Web Functional Test script.

  2. Expand the Run node.

  3. Select the script node where you want to add the Server Response test.

  4. Select the Script menu and then select Other from the Add sub menu.

  5. Expand the Web Tests group.

  6. Select Server Response Test and click OK.

  7. Enter the object identification path for the window. You can use the Capture or Select menu options to capture or select an object path. See Section 5.4.1, "Path Editor Toolbar" for additional information about the Path Editing Toolbar.

  8. Enter a name for the test.

  9. Enter the minimum and maximum time values.

  10. Set the Verify only, never fail option.

  11. Click OK to add the Server Response node to the script tree.

    In the Java Code view, the Server Response Test consists of the code executed in the web.window(objectId).verifyResponseTime() or web.window(objectId).assertResponseTime()method:

    web.window("/web:window[@index='0']").verifyResponseTime("MyserverResp", 10.0, 20.0);
    

    or

    web.window("/web:window[@index='0']").assertResponseTime("MyserverResp2", 10.0, 50.0);
    
    
    

    In the above code examples, verify means "do not stop on failure" and assert means "stop on failure".

5.4.6 Adding Text Matching Tests to a Script

To add a Text Matching Test to a Script:

  1. Open or create a Web Functional Test script project.

  2. Select the script node where you want to add the Text Matching Test.

  3. Select the Script menu and then select Other from the Add sub menu.

  4. Expand the Web Tests node.

  5. Select Text Matching Test.

  6. Click OK.

  7. Select the Look in location:

    All Browsers: When selected, the Text Matching Test looks for the text to match in all open browsers.

    Specified Browser: When selected, the Text Matching Test looks for the text to match by the browser ID specified in the Path.

    Specified Document: When selected, the Text Matching Test looks for the text to match in the document specified by the object ID in the Path.

  8. If you selected Specified Browser or Specified Document, enter the object identification path for the browser, document, or frame in the Path. You can use the Capture or Select buttons to capture or select an object path. See Section 5.4.1, "Path Editor Toolbar" for additional information about the Path Editing Toolbar

  9. Enter a name for the test.

  10. Enter the text string or Regular Expression to match or click the Substitute Variable icon to select a databank or script variable to find in the source.

    Note:

    The pound (#) character and double brace ({{ and }}) character sequences need to be escaped with a preceding pound (#) character if used in the Text Matching Test as a literal string (not a string specifying an OpenScript databank or script variable). For example, the pound character should be doubled (##) and double braces should be preceded by a pound character (#{{ and #}}).
  11. Select the source location that will be searched for the matching text:

    HTML Display Contents: Search the browser rendered text of the page.

    Raw HTML: Search HTML source of the page.

  12. Select the Pass when setting.

    Selected text is present: The test case passes if the Text to Match string is found in the selected source.

    Selected text is absent: The test case passes if the Text to Match string is not found in the selected source.

  13. Select the Match type.

    Exact: Matches the Text to Match string exactly.

    Regular Expression: Matches using the Regular Expression specified in Text to Match.

    Wildcard: Matches using the wildcard characters specified in Text to Match.

  14. Set the Verify only, never fail option.

  15. Click OK. The Text Matching Test node is added to the script tree.

    In the Java Code view, the web.assertText or web.document(specifiedDoc).assertText method will be added to the script code if the Verify only, never fail option is not selected:

    web.assertText("MyTextMatchTest", "Home", TextPresence.PassIfPresent, MatchOption.Exact)
    
    web.document("Main").assertText("MyTextMatchTest2", "Home", TextPresence.PassIfPresent, MatchOption.RegEx);
    

    In the Java Code view, the web.verifyText or web.document(specifiedDoc).verifyText method will be added to the script code if the Verify only, never fail option is selected:

    web.verifyText("MyTextMatchTest", "Home", TextPresence.PassIfPresent, MatchOption.Exact)
    
    web.document("Main").verifyText("MyTextMatchTest2", "Home", TextPresence.PassIfPresent, MatchOption.RegEx);
    
    

5.4.7 Adding Object Tests

The Web Functional Test Module includes an object test case for Browser objects that can be added to a script.

To add an object test to a script:

  1. Record a Web Functional Test script.

  2. Select the script node where you want to add the object test.

  3. Select the Script menu and then select Other from the Add sub menu.

  4. Expand the Web Tests node and select Object Test.

  5. Click OK.

  6. If necessary, select the Object Type.

  7. Enter the object identification path for the object. You can use the Capture or Select menu options to capture or select an object path. See Section 5.4.1, "Path Editor Toolbar" for additional information about the Path Editing Toolbar.

  8. Enter a test name.

  9. Select or clear the Verify only, never fail option.

  10. Select an Attribute/Value pair and specify the test details.

    Attributes: Shows the attributes of the selected object. Select an attribute and specify the test details.

    • Attribute: Shows the name of the attribute. When selected, the attribute is included in the object test. When cleared, the attribute is not included in the object test.

    • Value: Shows either the recorded value or the test criteria for the attribute depending upon which Display option is selected.

    • Enable All: Enables all properties for inclusion in the test criteria.

    • Disable All: Disables all properties for exclusion from the test criteria.

    • Add Row: Adds a new row to the table.

    • Display: Selects which values appear in the properties list.

      • Tests: When selected, the Value list shows the test criteria defined for each attribute.

      • Recorded Values: When selected, the Value list shows the recorded value for each attribute.

    Test Details: Specifies the test criteria for the selected attribute.

    • Recorded Value: Shows the recorded value of the attribute.

    • Enable: When selected, the attribute is included in the object test. When cleared, the attribute is not included in the object test.

    • Value Type: Specifies the data type to use as the test criteria for the attribute. The available options in the Operator list depend upon the selected value type to test: String, Boolean, Date, or Numeric.

    • Operator: Specifies the operator to use for the playback test criteria. The list of operators changes depending upon the selected Value Type.

      The following options are available for String values:

      • Exact: The test passes if the text or attribute value matches exactly the current value of the text string during playback of the script.

      • Wildcard: The test passes if the text or attribute value matches the current value of the Like operator pattern during playback of the script.

      • Regular Expression: The test passes if the text or attribute value matches the current value of the Regular Expression pattern during playback of the script.

      The following options are available for Numeric and Date values:

      • [Relational Operators]: Lists the relational operators. Select the type of comparison to use during playback of the script. If you select the Range operator, the Object Test adds a field for specifying the range. Specify the from-to range.

      The following option is available for Boolean values:

      • Equals: The test passes if the text or attribute value matches the True or False value specified in the Value field during playback of the script.

    • Value: Specifies the value to use for the test criteria for the attribute.

    • [Substitute Variable]: Opens a window for selecting a databank variable to substitute as the value to use for the test criteria for the attribute.

  11. Specify the test details for each Attribute/Value pair as required for the test.

  12. Click OK. The object test node is added to the script tree.

    In the Java Code view, a web.element(objectId).verifyAttributes method will be added to the script code:

    web.element(15, "/web:window[@index='0']
    
       /web:document[@index='0']
    
       /web:form[@index='0' 
    
         or @id='loginform' 
    
         or @name='loginform']
    
       /web:input_password[@name='password' or @index='0']").verifyAttributes(
         "MyObjectTest", web.attributes(
         web.attribute("index", "0", TestOperator.StringExact),
    
         web.attribute("tag", "INPUT", TestOperator.StringExact), 
    
         web.attribute("name", "password", TestOperator.StringExact), 
    
         web.attribute("value", "ta", TestOperator.StringExact), 
    
         web.attribute("type", "password", TestOperator.StringExact), 
    
         web.attribute("checked", "False", TestOperator.StringExact), 
    
         web.attribute("disabled", "False", TestOperator.StringExact)));
    
    

5.4.8 Adding Table Tests

The Web Functional Test Module includes a table test case for HTML tables that can be added to a script.

To add a table test to a script:

  1. Record a Web Functional Test script.

  2. Select the script node where you want to add the table test.

  3. Select the Script menu and then select Other from the Add sub menu.

  4. Expand the Web Tests node select Table Test.

  5. Click OK.

  6. If necessary, select the Object Type.

  7. Enter the object identification path for the object. You can use the Capture or Select menu options to capture or select an object path. See Section 5.4.1, "Path Editor Toolbar" for additional information about the Path Editing Toolbar.

  8. Enter a test name.

  9. Select or clear the Verify only, never fail option.

  10. Select a row and column cell and specify the test details.

    Test Details: Specifies the test to perform for each value. Select a value in the row and column list to set the details for that specific value.

    • Row: Shows the row number of the selected table value.

    • Column: Shows the column number of the selected table value.

    • Enable: When selected, the table value is included in the comparison test.

    • Recorded value: Shows the selected attribute's recorded value.

    • Value Type: Specifies the data type of the selected value: String, Numeric, Date, or Boolean.

    • Operator: Specifies how to compare the value. The Operator options change depending upon the selected value type. For relational operators, if you select the Range operator, a field is added for specifying the numeric or date range. Specify the from-to range.

    • Value: Specifies the value to test.

    • [Substitute Variable] - opens a dialog box for selecting the variable to use as the value to test.

  11. Specify the test details for each table cell as required for the test.

  12. Click OK. The table test node is added to the script tree.

    In the Java Code view, a web.table(objectId).assertCells or a web.table(objectId).verifyCells method will be added to the script code depending upon the Verify only, never fail setting:

    web.table(24, "/web:window[@index='0']
    
       /web:document[@index='0']
       /web:table[@index='6']").verifyCells("MyTableTest", web.cells(
         web.cell(1, 1, "Ticker ", TestOperator.StringExact),
         web.cell(1, 2, "Company ", TestOperator.StringExact),
         web.cell(2, 1, "ORCL ", TestOperator.StringExact),
    
         web.cell(2, 2, "Oracle Corporation ", TestOperator.StringExact)))
    
    

5.4.8.1 Testing Images in Tables

You can use the Table test to create tests that check for the existence of one or more images in a Web page table.

To add an image existence test to a script using a table test:

  1. Record a Web Functional Test script that has a Web page table with one or more images in the table.

  2. When the Web page table with the image is displayed, select the Script menu and then select Other from the Add sub menu.

  3. Expand the Web Tests node and select Table Test.

  4. Click OK.

  5. Click the Capture object in browser toolbar button. See Section 5.4.1, "Path Editor Toolbar" for additional information about the Path Editing Toolbar.

  6. Select the image in the Web page table and press the F10 key to capture the object path.

  7. Click OK. The Table Test dialog box opens with a web.table Object Type.

  8. Enter a test name.

  9. Select or clear the Verify only, never fail option.

  10. Select an table cell and specify the test details. The Table Test uses the text of the SRC=http://path/imageName for the image existence test.

  11. Specify the test details for each table cell as required for the test. For images, the value specifies the path and name of the image file. Other table cell values for the table may also be included depending upon the Web page source.

  12. Click OK. The table test node is added to the script tree.

    In the Java Code view, a web.table(objectId).assertCells or a web.table(objectId).verifyCells method will be added to the script code depending upon the Verify only, never fail setting:

    web.table(7,"/web:window[@index='0' or @title='MyImageTable']
     /web:document[@index='0']
     /web:table[@firstTableCell='http://my.com/img1.gif' or @index='28']")
     .assertCells("ImageTableTest",
       web.cells(web.cell(1, 1,"http://my.com/img2.gif", TestOperator.StringExact),
        web.cell(2, 1, "http://my.com/img3.gif", TestOperator.StringExact),
        web.cell(3, 1, "http://my.com/img4.gif", TestOperator.StringExact),
        web.cell(4 ,1, "http://my.com/img5.gif", TestOperator.StringExact)));
    
  13. Click the Stop toolbar button when finished recording.

5.4.9 Adding a Page Title Test

You can use Title Tests to report a page title error and/or abort the script if a Web page does not return back to the client a page with the expected title. The page title test compares the recorded page title to the title received on playback of the script.

To add a Title Test to a script:

  1. Record a Web Functional Test script.

  2. Expand the Run node.

  3. Select the script node where you want to add the Title test. Selecting the WaitForPage node will add the object identification path ID to the test automatically.

  4. Select the Script menu and then select Other from the Add sub menu.

  5. Expand the Web Tests group and select Title Test.

  6. Click OK.

  7. Select the Add to option:

    • Specific Page: When selected, the page title test will be added to the specified or currently selected page in the script.

    • All Pages in Script: When selected, a page title test will be added to each page in the script specifying the recorded title as the title to compare on playback.

  8. Enter the object identification path for the object. You can use the Capture or Select menu options to capture or select an object path. See Section 5.4.1, "Path Editor Toolbar" for additional information about the Path Editing Toolbar.

  9. Enter a name for the test.

  10. Enter the page title. If you selected the WaitForPage node the page title is added to the test automatically.

  11. Set the Verify Only, never fail option.

  12. Click OK to add the Page Title Test node to the script tree.

    In the Java Code view, the Page Title Test consists of the code executed in the web.window(objectId).verifyTitle() or web.window(objectId).assertTitle()method:

    web.window("/web:window[@index='0' or @title='Stocks']") 
      .verifyTitle("MyTitleTest", "Home");
    

    or

    web.window("/web:window[@index='0' or @title='Stocks']") 
      .assertTitle("MyTitleTest2", "Home");
    
    
    

    In the above code examples, verify means "do not stop on failure" and assert means "stop on failure".

5.4.10 Adding an HTML Test

You can use HTML Tests to report an HTML error and/or abort the script if a Web page does not return back to the client a page with the expected HTML. The HTML test compares the recorded HTML to the HTML received on playback of the script.

To add a HTML to a script:

  1. Record a Web Functional Test script.

  2. Expand the Run node.

  3. Select the script node where you want to add the HTML test. Selecting the WaitForPage node will add the object identification path ID to the test automatically.

  4. Select the Script menu and then select Other from the Add sub menu.

  5. Expand the Web Tests group and select HTML Test.

  6. Click OK.

  7. Select the Add to option:

    • Specific Document: When selected, the HTML test will be added to the specified or currently selected HTML document in the script.

    • All Documents in Script: When selected, am HTML test will be added to each HTML document in the script.

  8. Enter the object identification path for the object. You can use the Capture or Select menu options to capture or select an object path. See Section 5.4.1, "Path Editor Toolbar" for additional information about the Path Editing Toolbar.

  9. Enter a name for the test.

  10. Set the Verify Only, never fail option.

  11. Click OK to add the HTML Test node to the script tree.

    In the Java Code view, the HTML Test consists of the code executed in the web.document(objectId).verifyHTML() or web.document(objectId).assertHTML()method:

    web.document("/web:window[@index='0' or @title='Stocks']
      /web:document[@index='0']") 
       .verifyHTML("MyHTMLTest","e6306c5cf8f6697d9ba7bb2110888a50");
    

    or

    web.document("/web:window[@index='0' or @title='Stocks']
      /web:document[@index='0']") 
       .assertHTML("MyHTMLTest2","e6306c5cf8f6697d9ba7bb2110888a50");
    
    
    

    In the above code examples, verify means "do not stop on failure" and assert means "stop on failure".

If an HTML test fails on playback, you can select the HTML test result in the Results view and view the differences in the Comparison tab of the Details view.

5.4.11 Adding a Wait for Page

You can use the Wait for Page browser option to cause the script playback to wait until a page is returned by the server before continuing playback.

To add a Wait for Page command to a script:

  1. Record a Web Functional Test script.

  2. Expand the Run node.

  3. Select the script node where you want to add the Wait for Page node.

  4. Select the Script menu and then select Other from the Add sub menu.

  5. Expand the Web Actions group.

  6. Expand the Browser group.

  7. Select Wait For Page and click OK.

  8. Enter the document ID in XPath format.

  9. Select or clear the Wait for any page option.

  10. If you clear the Wait for any page option, specify the URL and Match option.

  11. Set the Timeout value.

  12. Click OK to add the Server Response node to the script tree.

    In the Java Code view, a web.window(objectId).waitForPage() method will be added to the script code:

    web.window(6, "/web:window[@index='0']").waitForPage("http://testserver2/fmstocks/home.asp", null, null)
    
    

5.4.12 Inspecting Object Paths

To inspect a Web object path:

  1. Record a Web Functional Test script.

  2. Select the Script menu and then select Inspect Path. OpenScript opens the capture mode. This dialog box lets you capture the object path for an object on a Web page.

    Path: Shows the Object Identification path of the object highlighted with the mouse cursor.

    The following options are available on the pulldown menu after you press F10 to capture an object path:

    • Capture Object: Opens a capture object dialog box and starts the capture mode. Navigate to the object to capture and use options in the capture dialog box to capture the object path.

    • View Object Path: Opens a dialog box for viewing the currently selected object path.

    • Save to Object Library: Opens a dialog box for specifying the Object Library in which to save the object path.

    Position: Shows the x, y coordinates for the entire screen. The upper left coordinate of entire screen is {0,0}. This position coordinate is used with Functional tests that include object types, such as Flash, where screen positions are required to perform mouse actions on the object. The position coordinates are used with the functional test methods, ft.mouseClick(), ft.mouseDown(), and ft.mouseUp().

    Offset: Shows the x, y coordinates relative to the currently highlighted object. The upper left coordinate of highlighted object is {0,0}. This offset coordinate is used with Web Functional tests that include object types, such as Flash, where screen positions are required to perform a mouse click on the object. The position coordinates are used with the Web functional test method, web.element().mouseClick().

  3. Navigate to the Web object and place the mouse cursor on the object.

  4. Press F10 to capture the path.

  5. Highlight the path with the mouse cursor and press the Ctrl+C keys to copy the path to the clipboard.

  6. Click OK when finished.

5.4.13 Setting Script Properties

To set script properties:

  1. Record a Web Functional Test script.

  2. Select the Script menu and then select Script Properties.

  3. Select the properties category.

  4. Specify the properties for the category.

  5. Click OK when finished.

5.4.14 Substituting Databank Variables

To substitute a databank variable for a query string parameter in a script:

  1. Record a Web Functional test script that has text string parameters.

  2. Expand the Run node.

  3. Expand the node containing text parameters.

  4. Right-click a text parameter node and select Properties from the shortcut menu.

  5. If you have already configured the script with one or more databanks, select the click the [Substitute Variable] icon and select the databank field to substitute for the text parameter from the desired databank file and click Finish.

  6. If you have not already configured the script with a databank, select Add new databank and click Next.

    1. Click the Browse button and select the databank file to use.

    2. Select the column (field name) to substitute for the text parameter and click Finish.

    In the Tree View, the databank variable appears in place of the recorded value as {{db.databankFileName.field,recordedValue}}.

    In the Java Code view, the databank variable appears as {{db.databankFileName.field,recordedValue}} in the web.text(objectId).setText method:

    web.text(1, "/web:window[@index='0']
    
       /web:document[@index='0']
    
       /web:form[@index='0']
    
       /web:input_text[@id='ticker' 
    
         or @name='ticker' 
    
         or @index='0']").setText("{{db.fmstocks_data.ticker,orcl}}")
    
    

5.4.15 Using the Web Functional Test Module API

The Web Functional Module includes a script Application Programming Interface (API) specific to Web DOM functional testing. The Web Functional Test Module recorder creates the Java code that corresponds to the Tree View and displays the Web Functional Test commands in the Java Code view using easy-to-understand function names. The Java Code view commands correspond to the Tree View and you can edit your scripts in either view.

You can use the Web Functional Test API to enhance recorded scripts with additional testing functionality. Commands that are specific to the Web Functional Testing Module are part of the "web" class. Additional functional test methods are available in the "ft" class. You can also leverage other commands from other enabled classes (services) or general Java commands in your scripts.

Some examples of the Web Testing Module API include:

  • Adding control statements

  • Adding think time

  • Launching and closing the Browser

  • Navigating to a URL

  • Performing actions on Web objects (click, double click, etc.)

  • Setting text fields

  • Waiting for a page to load

Many API methods can be added using the Web Functional Test Module Tree View. Additional methods can be added using the Java Code view. Use Ctrl-space in the Java Code view to open an Intellisense window listing available procedures and code examples. See the API Reference in the OpenScript help for additional programming information.

5.5 Editing Object Libraries

To edit an object library:

  1. Create a Web Functional Test script project.

  2. Add an Object Library to the script and record the Web application under test.

  3. Select the Load Object Library node in the script tree and then select Open Object Library from the right-click shortcut menu.

  4. If necessary, click the Object Library tab.

  5. Select an object in the Objects list.

  6. Edit the object attributes in the Details section.

    You can add objects to and delete objects from the Object list. You edit the object attributes in the object string or in the tree hierarchy of the Details section. The tree hierarchy lets you move attributes up or down in the priority order.

    You can click the libraryName.properties tab to view or edit the object/object attribute text strings in the object library file source.

  7. Select Save from the File menu or click the Save toolbar button to save changes to the object library file.