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 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 tabs and set the preferences. See Section 2.5.7, "Web Functional Test Preferences" for descriptions of the Record Preferences settings.

  6. 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. See Section 5.5, "Editing Object Libraries" and Section 5.4.4, "Adding Object Libraries to a Script" for additional information.

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.

    Note:

    Make sure the browser zoom setting is set to 100%. Record and playback of functional test scripts at other zoom settings is not supported and may not work correctly.
  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 groups and set the preferences. See Section 2.4.9, "Web Functional Test Preferences" for descriptions of the Playback Preferences settings.

  6. 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.2.4, "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 Open Object Library from the File menu, select the Object Library .properties file 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 object library and 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)))
    

    or

    web.table(24, "/web:window[@index='0']
       /web:document[@index='0']
       /web:table[@index='6']").assertCells("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']")
     .verifyCells("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)));
    

    or

    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 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 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 an XML Test

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

To add an XML test to a script:

  1. Record a Web Functional Test script.

  2. Navigate to a URL for an XML file.

  3. Expand the Run node.

  4. Select the script node where you want to add the XML test. Selecting the WaitForPage node will show the file in the Details view with tabs for Screenshot XML, XML tree, and DOM Tree. The XML tab shows the content of the XML file. The XML Tree tab shows the content of the XML file in tree format with the attributes and elements for each node. The DOM Tree tab show the HTML representation of the XML.

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

  6. Expand the Web Tests group and select XML Test.

  7. Click OK.

  8. Enter a name for the test.

  9. Set the Verify Only, never fail option.

  10. If necessary, select the Object Type: web.XMLDocument.

  11. Enter the window path. 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.

  12. Select an XML node to test in the XML tree and enable or disable the test for the node by selecting or clearing the check box. The XML tree has the following navigation toolbar options:

    • Filter disabled items: Clears unselected items from view in the XML test dialog box.

    • Next enabled node: Moves the selection pointer to the next enabled node in the XML tree.

    • Previous enabled node: Moves the selection pointer to the previous enabled node in the XML tree.

  13. Select an XML node to test and select the Tests attributes for each selected XML node.

    Tests: Shows the attributes of the selected XML node. Select an attribute and specify the test details.

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

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

    • Enable All: Opens a menu for selecting which types of XML or attributes to enable all.

    • Disable All: Opens a menu for selecting which types of XML or attributes to disable all.

    • Display: Selects which values appear in the Test Detail section.

      • 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.

  14. If necessary, expand the Test Details section and edit the details for the selected XML node.

    Test Details: Specifies the test details for the select XML node in the tree:

    • Recorded Value: Shows the recorded value for the selected XML node.

    • Attribute: Shows the attribute name of the selected XML node.

    • Value Type: Specifies the data value type of the selected XML node.

    • Operator: Specifies the test operator to use for the selected XML node.

    • Expected Value: Specifies the value to compare to the recorded value for the selected XML node.

  15. Click OK to add the XML Test node to the script tree.

    In the Java Code view, the XML Test consists of the code executed in the web.xmlDocument(objectId).verifyXML() or web.xmlDocument(objectId).assertXML()method:

    web.xmlDocument(5, "/web:window[@index='0' or 
      @title='http://myServer/myFile.xml']
      "/web:document[@index='0']")
      .verifyXML("XMLTest", web.nodeTests());
    

    or

    web.xmlDocument(5, "path").verifyXML("testXML",
      web.nodeTests(web.node("/root").attrCountTest("0", TestOperator.IntEqual),
       web.node("/root").childCountTest("2", TestOperator.IntEqual), 
       web.node("/root/testNode[2]").attrTest("id", "testNode2",
         TestOperator.StringExact), 
       web.node("/root/testNode[2]").attrCountTest("1", TestOperator.IntEqual), 
       web.node("/root/testNode[2]").childCountTest("2", TestOperator.IntEqual), 
       web.node("/root/testNode[2]/testSubNode[1]").attrTest("id","testSubNode1", 
         TestOperator.StringExact),
       web.node("/root/testNode[2]/testSubNode[1]").attrCountTest("1", 
         TestOperator.IntEqual), 
       web.node("/root/testNode[2]/testSubNode[1]");.childCountTest("0", 
         TestOperator.IntEqual)));
    

    or

    web.xmlDocument(5, "/web:window[@index='0' or 
      @title='http://myServer/myFile.xml']
      "/web:document[@index='0']")
      .assertXML("XMLTest", web.nodeTests());
    

    or

    web.xmlDocument(5, "path").assertXML("testXML",
      web.nodeTests(web.node("/root").attrCountTest("0", TestOperator.IntEqual),
       web.node("/root").childCountTest("2", TestOperator.IntEqual), 
       web.node("/root/testNode[2]").attrTest("id", "testNode2",
         TestOperator.StringExact), 
       web.node("/root/testNode[2]").attrCountTest("1", TestOperator.IntEqual), 
       web.node("/root/testNode[2]").childCountTest("2", TestOperator.IntEqual), 
       web.node("/root/testNode[2]/testSubNode[1]").attrTest("id","testSubNode1", 
         TestOperator.StringExact),
       web.node("/root/testNode[2]/testSubNode[1]").attrCountTest("1", 
         TestOperator.IntEqual), 
       web.node("/root/testNode[2]/testSubNode[1]");.childCountTest("0", 
         TestOperator.IntEqual)));
    

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

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

5.4.12 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.13 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.14 Using the Object Details View

The Object Details view provides options for viewing the attributes and values for the objects selected in the browser connected to the view. The Object Details view is available for Functional tests.

To view object details:

  1. Create a Functional Test script.

  2. Select the View menu and then select Object Details. OpenScript opens the Object Details view for capturing and viewing objects in the Document Object Model. This dialog box lets you connect to a browser, capture the object path for an object on a Web page.

    The following toolbar buttons are available in the Object Details view:

    • Refresh Tree - refreshes the Object Details tree pane.

    • Find a node to inspect by selecting in browser - starts the capture mode for selecting the Web page object in the browser. Highlight the object in the browser and press F10 to select it and show the attributes in the Object Details View.

    • Connect to browser/Disconnect from browser - connects or disconnects the Object Details View to the browser. The Object Details View must be connected to the browser to capture objects.

  3. Click the Connect to Browser toolbar button. A new browser opens.

  4. Navigate to the page containing the object you wish to view. The tree view loads the DOM tree for the page in the browser.

    The following options are available in the Object Details view:

    • Module: Selects the type of OpenScript module. The objects in the tree view change to the specific module type. For example, the Web module shows the HTML DOM tree. The ADF module shows the ADF object tree.

    • Find: Provides search capabilities to locate specific text in the Object Details. Type the text to find and click Next or Previous to locate the attributes and values within the tree.

    • Partial Match: When selected the Next or Previous search will match partial text strings specified in Find. When cleared, the Next or Previous search will match the entire Find string.

    • Next: Searches down the tree for the next object that matches the Find string.

    • Previous: Searches up the tree for the previous object that matches the Find string.

    • Tree pane: Shows the Document Object Model (DOM) tree of a Web application, the ADFUIComponents tree of an ADF page, and the Forms element tree of a forms application. You can use the Find/Next/Previous options to locate objects in the tree or use the Find a node to inspect by selecting in browser toolbar button to locate the object by selecting it in the connected browser. The right-click shortcut menu includes the following options for working with the object selected in the tree:

      • View Object Path: Opens a dialog box showing the full path of the object.

      • Add Object Test: Opens the Object Test dialog for defining an object test for the object selected in the tree.

      • Add Table Test: Opens the Table test dialog box for defining a table test for the table object selected in the tree. This option is only available for table objects.

      • Save to Object Library: Opens the Save to Object Library dialog box for saving the object path to an object library.

    • Attribute: Shows the attribute name of the object selected in the tree.

    • Value: Shows the value of the object attribute selected in the tree.

  5. Use the Find/Next/Previous options to locate objects in the tree or use the Find a node to inspect by selecting in browser toolbar button to locate the object by selecting it in the connected browser.

    If you use the Find a node to inspect by selecting in browser toolbar button, highlight the object you wish to view in the browser and press F10. The tree view expands and selects the object.

  6. Use the tree view shortcut menu to view the object path, add tests, or save the object path to an Object Library.

  7. Select the Disconnect from Browser toolbar button when finished.

5.4.14.1 Viewing the Object Path

To view the path for an object:

  1. Open the Object Details view and select an object in the tree.

  2. Right-click on the object and select View Object Details. The View Object Details dialog box has the following option:

    • Path: Shows the path of the object. Click the toolbar button to switch between the tree view and the XPath view.

5.4.14.2 Adding an Object Test

To add an object test:

  1. Open the Object Details view and select an object in the tree.

  2. Right-click on the object and select Add Object Test. The Object Test dialog box opens for defining an object test for the object selected in the tree. See Section 5.4.7, "Adding Object Tests" for additional information about defining an Object Test.

5.4.14.3 Adding a Table Test

To add a table test:

  1. Open the Object Details view and select a Table object in the tree.

  2. Right-click on the object and select Add Table Test. The Table Test dialog box opens for defining a table test for the table object selected in the tree. This option is only available for table objects. See Section 5.4.8, "Adding Table Tests" for additional information about defining a Table Test.

5.4.14.4 Saving an Object Path to an Object Library

To save an object path to an object library:

  1. Open the Object Details view and select an object in the tree.

  2. Right-click on the object and select Save to Object Library. The Save to Object Library dialog box opens for saving the object path to an object library. The Save to Object Library dialog box has the following options:

    • Object Library: Lists the saved object libraries where the selected path can be saved.

    • New: Opens a dialog for specifying a new Object Library file.

    • Name: Specifies a name for the object path.

    • Description: Specifies a description for the object path.

  3. Select the library where you want to save the path or create a new library.

  4. Enter a new name and description.

  5. Click OK.

5.4.15 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.16 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.

  7. Select the database type and click Next.

    For CSV File databanks:

    1. Select the repository and folder then select the databank file to use.

    2. Click Next.

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

    For database databanks:

    1. Select the Database Driver to use and specify the database connection information. The URL will be populated with the connection information.

    2. Specify the Username andPassword authentication for the database.

    3. Specify the database Query to use to retrieve the databank columns and data from the database.

    4. Specify the alias name to use for the databank.

    5. Click Test to verify the connection to the database.

    6. Click Next.

    7. 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.17 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 Open Object Library from the File menu.

  4. Select the libraryName.properties file and click Open.

  5. If necessary, click the Object Library tab.

  6. Select an object in the Objects list. The Objects list section has the following toolbar buttons:

    Sort the paths alphabetically - sorts the object XPaths alphabetically.

    Add: Adds a new object to the list. After adding a new object, specify the name and object identification path in the Details section.

    Delete: Deletes an object from the object list. A confirmation message appears.

    Inspect Path: Starts the object capture mode and opens a browser for selecting the object path to capture.

  7. 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.

    Details: Specifies the name and object identification path segments and attributes for the selected object in the object list.

    • Name: Specifies the name of an object. A name is required for each object. The name is used in the script code to reference the object path in the object library. For example, an object in the Object Library named web_window_0 may have a path defined as follows:

      /web:window[@index='0' or @title='Home']"
      

      In the script code, the object path in an Object Library is referenced using the script variable format {{obj.libraryName.objectName}}. For example, a script navigation command references an object path in an Object Library as follows:

      web.window(44, "{{obj.MyObjLib.web_window_0}}")
        .navigate("http://myServer/home");
      
    • Description: Specifies any description for the object. A description is optional.

    • Path: Specifies the full object identification path segments and attributes that the Web Functional Test Module uses to identify an object on a Web page during play back of a script. The following toolbar buttons are available for working with object paths:

      • Toggle between tree and text: Toggles the Path editor between tree view mode and text mode. In tree view mode, the object path is represented as tree hierarchy. Use the toolbar buttons to add, edit, or delete path attributes in the tree hierarchy or the change the priority order of the attributes. Click the arrows next to the path segments to expand and collapse specific tree segments. When fully collapsed, a path tree may appear as follows:

        web:window
        web:document
        web:form
        web:input_submit
        

        When full expanded, a path tree may appear as follows:

        web:window
          @index='0'            or
          @title='Stocks'
        web:document
          @index='0'
        web:form
          @id='loginform'       or
          @name='loginform'     or
          @index='0'
        web:input_submit
          @name='LoginButton'   or
          @value='Login'        or
        @index='0'
        

        Select a path segment or attribute in the tree and click the Edit toolbar button or double-click on a path segment to open the edit dialog box.

        In text mode, the object path is represented as an XPath text string as follows:

        /segment[@attr1='value' and|or @attr2='value' and|or @attrN='value'] /nextsegment[...]/segmentN[...]
        

        The following example XPath shows the full path to a Submit Input button of a Web form:

        /web:window[@index='0' or @title='Stocks']/web:document
        [@index='0']/web:form[@id='loginform' or @name='loginform' or 
        @index='0']/web:input_submit[@name='LoginButton' or @value='Login'
        or @index='0']
        

        You can edit the object XPath text directly in the edit box. The edit box includes an auto-complete feature that lists available options to select when editing an object path. Typing the / (forward slash) character opens the list of path segments available for selection. Typing the @ character opens the list of path attributes available for selection. Typing additional text narrows down the list of available selections to only those matching the text entered.

      • Add: Opens a dialog box for adding a path segment or attribute to the object identification tree.

      • Edit: Opens a dialog box for changing the value of the object path segment or attribute selected in the tree.

      • Delete: Deletes the selected object path segment or attribute from the tree.

      • Up: Moves the selected object path segment or attribute up in the tree hierarchy. This button is only active if the object path segment or attribute is able to be moved up in the tree hierarchy.

      • Down: Moves the selected object path segment or attribute down in the tree hierarchy. This button is only active if the object path segment or attribute is able to be moved down in the tree hierarchy.

      • View Full Path: Opens a dialog box for viewing the full object path.

    • Use a different path for identifying the object during record time: When selected, a secondary path editing box opens for specifying the object path to use when recording a script. The object path specified is used only when recording a script and can include Regular Expression, Wildcard and Exact matching for specific path segments and attributes.

    • Record Path: Specifies the full object identification path and attributes that the Web Functional Test Module recorder uses to identify an object on a Web page. The Recorded Path toolbar buttons are the same as the Path toolbar button except for View Full Path. The object path specified is used only when recording a script and can include Regular Expression, Wildcard, and Exact matching for specific path segments and attributes. Specify the Match type to use for the Record Path path segments and attributes.

    • Match: Specifies the matching type to use the record time object identification path segments and attributes. Regular Expression and Wildcard matching can only be used for Record object identification paths.

      • Exact: When selected, the object identification matches the full path exactly as specified.

      • RegEx: When selected, the object identification matches using Regular Expression matching. Edit the path segments and attributes to include a Regular Expression where you want to use Regular Expression matching.

      • Wildcard: When selected, the object identification matches using Wildcard matching. Use ? (question mark) to match single characters or * (asterisk) to match multiple characters. Edit the path segments and attributes to include a Wildcard where you want to use Wildcard matching.

    You can click the libraryName.properties tab to view or edit the object/object attribute text strings in the object library file source. The basic format of a object/object attribute text string is as follows:

    objectName=path
    

    objectName can be any user-defined name. This name corresponds to the Name specified in the Details section of an object in the library. objectName can also include names that specify the match option and recorded path strings for specific objects.

    path is an XPath formatted string. path can also include the match option and recorded path strings for specific objects.

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