Skip Headers
Oracle® Application Testing Suite OpenScript User's Guide
Version 9.10 for Microsoft Windows (32-Bit)

Part Number E15488-03
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

6 Using the HTTP Module

This chapter provides instructions on configuring and using the OpenScript HTTP Module, which tests Web-based applications by automating the underlying HTTP protocol traffic.

6.1 About the HTTP Module

The OpenScript HTTP Module is an application/protocol module that supports load testing of Web-based applications that communicate via http(s) protocol. OpenScript provides a flexible and easy-to-use scripting interface for both Technical Testers and Non-Technical Testers. The OpenScript HTTP Module enables script creation from both the code view and GUI view scripting interfaces.

The HTTP Module extends the OpenScript platform with HTTP Proxy recording and playback capabilities. The proxy recorder automatically captures Web page navigations and records them as tree view nodes (with the underlying code in the Code View) in the script. The HTTP Module also provides additional GUI script modification options for HTTP navigation.

6.1.1 Key Features of the HTTP Module

The HTTP module provides the following functionality:

  • Records HTTP protocol requests for playback automation. The requests can be generated by a Web browser (i.e. IE) or by a plug-in (i.e. AJAX XMLHTTP plug-in).

  • Plays back HTTP scripts to validate proper functionality. Playback runs interactively in the OpenScript user interface and is also supported in the Oracle Load Testing Agents (i.e. Java Agent).

  • Provides full script code view integration to support script generation for the HTTP Module. The commands include (but are not limited to) methods to generate GET requests, POST requests, correlation substitutions, validation, etc. The HTTP Module includes an additional API to support HTTP protocol code scripting.

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

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

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

6.2 Navigation Editing (Correlation)

The HTTP Module enables users to view and edit all recorded navigations and related parameters (headers, post data, etc.) in either the script GUI Tree view or Code View. It also enables them to view and edit any default correlation/parameterization of dynamic navigations and apply their own correlation to handle dynamic navigations.

6.2.1 Setting Correlation Preferences

To set correlation preferences:

  1. Start OpenScript.

  2. Select OpenScript Preferences from the View menu.

  3. Expand the OpenScript node and the Correlation category.

  4. Select HTTP.

  5. Select or clear the check boxes for defined rules.

  6. Select Add Library, Add Rule, or Edit Rule to define custom correlation rules.

  7. Click OK.

6.2.2 Adding Correlation Libraries

Selecting Add Library in the Correlation Rules Preferences opens the Add Library dialog box. This dialog box lets you specify a new correlation library for transforming dynamic data in recorded script URLs and related parameters (headers, post data, etc.) to variable names that will be recognized by the script playback engine (OpenScript or Oracle Load Testing). The dialog box has the following options:

  • Name: Specifies the name of the correlation library. After you define a library you can use the Add Rule button to specify the rules to include in the library. The name is required. You can also select Copy rules to copy correlation rules from an existing library.

  • Copy rules from existing library: Lets you copy correlation rules from an existing library to a new library.

    • Copy Rules: When selected, a list of existing correlation rule libraries will be enabled for copying.

    • Library: Lists the correlation rule libraries available for copying.

6.2.3 Adding and Editing Correlation Rules

Selecting Add Rule or Edit Rule in the Correlation Rules Preferences opens the Add Rule or Edit Rule dialog box. This dialog box lets you specify or edit a correlation rule for transforming dynamic data in recorded script URLs and related parameters (headers, post data, etc.) to variable names that will be recognized by the script playback engine (OpenScript or Oracle Load Testing). The dialog box has the following options:

  • Type: Specifies the type of correlation rule. The available Source and Target options change depending upon the rule type. The following rule types are available:

    • Client Set Cookie: This rule type automatically transforms web page cookie objects with dynamic data.

    • Correlate Cookie Header: This rule type automatically transforms web page cookie header objects with dynamic data.

    • Correlate Header: This rule type automatically transforms web page header objects with dynamic data.

    • Correlate Referer Header: This rule type automatically transforms web page referer header objects with dynamic data.

    • DOM Correlation: This rule type automatically transforms web page Document Object Model (DOM) objects with dynamic data.

    • Function/Text Substitution: This rule type lets you specify a used-defined function to replace a specific parameter or parameters.

    • Substitute Recorded Date: This rule type lets you specify a Regular Expression pattern to find and replace a date parameters with a variable value.

    • Variable Substitution: This rule type lets you specify a Regular Expression pattern to find and replace a specific parameter or parameters with a variable value.

    • XML DOM Correlation: This rule type automatically transforms XML page Document Object Model (DOM) objects with dynamic data.

  • Name: Specifies the name of the correlation rule. The name is required.

The following sections describe the rule types.

6.2.3.1 Client Set Cookie

When Client Set Cookie is selected, the Source and Target show the following options:

  • Source: Always cookies.

  • Target: Specifies which document object(s) to use as the target location of the transform.

    • Replace all locations: When selected, the correlation rule applies to any object matching the source criteria.

    • Replace specified location: When selected, the correlation rule applies only to the object matching the Location criteria.

    • Location: Specifies the cookie parameter(s) to which to apply the correlation rule using a Regular Expression. (See Variable Substitution Rules below for examples.)

6.2.3.2 Correlate Cookie Header

When Correlate Cookie Header is selected, the Source and Target show the following options:

  • Source: Always cookie header.

  • Target: Specifies which document object(s) to use as the target location of the transform.

    • Replace all locations: When selected, the correlation rule applies to any object matching the source criteria.

    • Replace specified location: When selected, the correlation rule applies only to the object matching the Location criteria.

    • Location: Specifies the cookie parameter(s) to which to apply the correlation rule using a Regular Expression. (See Variable Substitution Rules below for examples.)

6.2.3.3 Correlate Header

When Correlate Header is selected, the Source and Target show the following options:

  • Source: Always web page headers.

  • Target: Specifies which header object(s) to use as the target location of the transform.

    • Replace all locations: When selected, the correlation rule applies to any object matching the source criteria.

    • Replace specified location: When selected, the correlation rule applies only to the object matching the Location criteria.

    • Location: Specifies the header parameter(s) to which to apply the correlation rule using a Regular Expression. (See Variable Substitution Rules below for examples.)

6.2.3.4 Correlate Referer Header

When Correlate Referer Header is selected, the Source and Target show the following options:

  • Source: Always web page referer headers.

  • Target: Specifies which referer header object(s) to use as the target location of the transform.

    • Replace all locations: When selected, the correlation rule applies to any object matching the source criteria.

    • Replace specified location: When selected, the correlation rule applies only to the object matching the Location criteria.

    • Location: Specifies the referer header parameter(s) to which to apply the correlation rule using a Regular Expression. (See Variable Substitution Rules below for examples.)

6.2.3.5 DOM Correlation Rules

When DOM Correlation Rules is selected, the Source and Target show the following options:

  • Source: Specifies which document object(s) to substitute as dynamic data.

    • Links: When selected, web page link objects with dynamic data will automatically transformed to variable values.

    • Action: When selected, web page action objects with dynamic data will automatically transformed to variable values.

    • Input: When selected, web page input objects with dynamic data will automatically transformed to variable values.

    • TextArea: When selected, web page TextArea objects with dynamic data will automatically transformed to variable values.

    • JavaScript: When selected, web page JavaScript objects with dynamic data will automatically transformed to variable values.

    • Frame: When selected, web page Frame objects with dynamic data will automatically transformed to variable values.

    • Option: When selected, web page Option objects with dynamic data will automatically transformed to variable values.

  • Target: Specifies which referer header object(s) to use as the target location of the transform.

    • Replace all locations: When selected, the correlation rule applies to any object matching the source criteria.

    • Replace specified location: When selected, the correlation rule applies only to the object matching the Location criteria.

    • Location: Specifies the web page object(s)/parameter(s) to which to apply the correlation rule using a Regular Expression. (See Variable Substitution Rules below for examples.)

6.2.3.6 Function/Text Substitution Rules

When Function/Text Substitution Rules is selected, the Source and Target show the following options:

  • Source: Specifies the function name or text to use as the substitute for dynamic data.

    • Function/Text: Specifies the name of the function to use to search the source location. The following functions are available:.

      • {{@decode({{myVariable}})}}: Searches the source using the specified Target Regular Expression and replaces the data with the script variable {{@decode({{myVariable}})}}. The value is the encoded text string specified by the Target Regular Expression.

      • {{@decrypt({{myVariable}})}}: Searches the source using the specified Target Regular Expression and replaces the data with the script variable {{@decrypt({{myVariable}})}}. The value is the encrypted text string specified by the Target Regular Expression.

      • {{@deobfuscate({{myVariable}})}}: Searches the source using the specified Target Regular Expression and replaces the data with the script variable {{@deobfuscate({{myVariable}})}}. The value is the obfuscated text string specified by the Target Regular Expression.

      • {{@encode({{myVariable}})}}: Searches the source using the specified Target Regular Expression and replaces the data with the script variable {{@encode({{myVariable}})}}. The value is the text string specified by the Target Regular Expression.

      • {{@encrypt({{myVariable}})}}: Searches the source using the specified Target Regular Expression and replaces the data with the script variable {{@encrypt({{myVariable}})}}. The value is the text string specified by the Target Regular Expression.

      • {{@file({{myVariable}})}}: Searches the source using the specified Target Regular Expression and replaces the data with the script variable {{@file({{myVariable}})}}. The value is the text string contained in the file specified by myVariable or a hard coded path such as {{@file(c:\\OpenScript_Sample.txt)}}.

      • {{@getAndIncrement({{myVariable}},delta)}}: Searches the source using the specified Target Regular Expression and replaces the data with the script variable {{@getAndIncrement({{myVariable}}, delta)}}. The value is the numeric value specified by the Target Regular Expression. delta is the amount to increment the value by each time.

      • {{@hostip}}: Searches the source using the specified Target Regular Expression and replaces the data with the script variable {{@hostip}}. The value is the host IP address.

      • {{@hostname}}: Searches the source using the specified Target Regular Expression and replaces the data with the script variable {{@hostname}}. The value is the host name.

      • {{@iterationnum}}: Searches the source using the specified Target Regular Expression and replaces the data with the script variable {{@iterationnum}}. The value is the script playback iteration number.

      • {{@jstr({{myVariable}})}}: Searches the source using the specified Target Regular Expression and replaces the data with the script variable {{@jstr({{myVariable}})}}. The value is a serialized Java string that specifies a Hexadecimal length value followed by the string contained in myVariable in the format \00\09var_value.

      • {{@len({{myVariable}})}}: Searches the source using the specified Target Regular Expression and replaces the data with the script variable {{@len({{myVariable}})}}. The value is the length of the string contained in myVariable.

        Note:

        For @jstr, @file, and @len functions, myVariable is an OpenScript script variable defined using the http.solve or http.solveXpath methods. The variable name must be enclosed in double {{ }} braces within the function parenthesis. For example:

        {{@len({{myVariable}})}}

      • {{@obfuscate({{myVariable}})}}: Searches the source using the specified Target Regular Expression and replaces the data with the script variable {{@obfuscate({{myVariable}})}}. The value is the text string specified by the Target Regular Expression.

      • {{@random(max)}}: Searches the source using the specified Target Regular Expression and replaces the data with the script variable {{@random(max)}}. The value is the numeric value specified by the Target Regular Expression. The default minimum value is 0. max is the maximum value limit for the random number. The generated random number is a uniformly distributed pseudorandom integer value between 0 (inclusive) and max value (exclusive), drawn from this random number generator's sequence. For example, {{@random(2)}} will return a number between 0 (inclusive) and 2 (exclusive). The random value is an integer from the formula randomValue = min + m_random.nextInt(max - min), where m_random.nextInt uses the java.util.Random.nextInt method.

      • {{@random(min,max)}}: Searches the source using the specified Target Regular Expression and replaces the data with the script variable {{@random(min, max)}}. The value is the numeric value specified by the Target Regular Expression. min is the minimum value limit for the random number. max is the maximum value limit for the random number. The generated random number is a uniformly distributed pseudorandom integer value between min value (inclusive) and max value (exclusive), drawn from this random number generator's sequence. For example, {{@random(1,4)}} will return a number between 1 (inclusive) and 4 (exclusive). The random value is an integer from the formula randomValue = min + m_random.nextInt(max - min), where m_random.nextInt uses the java.util.Random.nextInt method.

      • {{@sessionname}}: Searches the source using the specified Target Regular Expression and replaces the data with the script variable {{@sessionname}}. The value is the script playback session number.

      • {{@timestamp}}: Searches the source using the specified Target Regular Expression and replaces the data with the script variable {{@timestamp}}. The timestamp value is the difference, measured in milliseconds, between the current time and Midnight, January 1, 1970 UTC.

      • {{@timestampsecs}}: Searches the source using the specified Target Regular Expression and replaces the data with the script variable {{@timestampsecs}}. The value is the current timestamp in seconds instead of milliseconds.

      • {{@today(MM/dd/yyyy)}}: Searches the source using the specified Target Regular Expression and replaces the data with the script variable {{@today(MM/dd/yyyy)}}. The value is the current date in month/day/year format.

      • {{@topLevelStepName}}: Searches the source using the specified Target Regular Expression and replaces the data with the script variable {{@topLevelStepName}}. The value is the top level step group name.

      • {{@urlEncode({{myVariable}})}}: Searches the source using the specified Target Regular Expression and replaces the data with the script variable {{@urlEncode({{myVariable}})}}. The value is the text string specified by the Target Regular Expression. For example, the string, 'the file "abc" is in \root\etc', would be encoded as: the+file+%22abc%22+is+in+%5Croot%5Cetc.

      • {{@vuid}}: Searches the source using the specified Target Regular Expression and replaces the data with the script variable {{@vuid}}. The value is the virtual user ID specified by the Target Regular Expression.

      • {{@xmlDecode({{myVariable}})}}: Searches the source using the specified Target Regular Expression and replaces the data with the script variable {{@xmlDecode({{myVariable}})}}. The value is the encoded text string specified by the Target Regular Expression.

      • {{@xmlEncode({{myVariable}})}}: Searches the source using the specified Target Regular Expression and replaces the data with the script variable {{@xmlEncode({{myVariable}})}}. The value is the text string specified by the Target Regular Expression.

  • Target: Specifies which referer header object(s) to use as the target location of the transform.

    • Replace all locations: When selected, the correlation rule applies to any object matching the source criteria.

    • Replace specified location: When selected, the correlation rule applies only to the object matching the Location criteria.

    • Location: Specifies the web page object(s)/parameter(s) to which to apply the correlation rule using a Regular Expression. (See Variable Substitution Rules below for examples.)

6.2.3.7 Substitute Recorded Date

When Substitute Recorded Date is selected, the Source and Target show the following options:

  • Source: Specifies the attribute to use as the substitute for dynamic data.

    • Attribute Name: for internal use only and should only be set to "value" (without quotations).

    • Date Pattern: Specifies the date pattern in the form M/dd/yyyy. The Date Pattern follows standard Java Date format string conventions. When correlating scripts, the time that the navigation was recorded is converted to a date using the specified Date Pattern. If the current date is found in a request, it is replaced with: {{@today(date_pattern)}}.

  • Target: Specifies which referer header object(s) to use as the target location of the transform.

    • Replace all locations: When selected, the correlation rule applies to any object matching the source criteria.

    • Replace specified location: When selected, the correlation rule applies only to the object matching the Location criteria.

    • Location: Specifies the referer header parameter(s) to which to apply the correlation rule using a Regular Expression. (See Variable Substitution Rules below for examples.)

6.2.3.8 Variable Substitution Rules

When Variable Substitution Rules is selected, the Source and Target show the following options:

  • Source: Specifies the attribute to use as the substitute for dynamic data.

    • Variable Name: Specifies the name of the variable to use as the substitute for dynamic data.

    • Pattern: Specifies the Regular Expression to use to locate the dynamic data to replace.

    • Error Message: Specifies an error message to report if the source data is not found on playback.

    • Source: Specifies where to search for the dynamic data to replace: HTML Display Contents, Raw HTML or Response Header.

    • Encoding: Specifies if encoding should be used for the search and the type.

  • Target: Specifies which referer header object(s) to use as the target location of the transform.

    • Replace all locations: When selected, the correlation rule applies to any object matching the source criteria.

    • Replace specified location: When selected, the correlation rule applies only to the object matching the Location criteria.

    • Location: Specifies the web page object(s)/parameter(s) to which to apply the correlation rule using a Regular Expression. Specify a regular expression to narrow down which part of a target request may be replaced with the correlated variable. All or part of a url, query string, and/or postdata may be substituted. Use ((.+?)) to indicate where the variable should be substituted.

      • The expression may be used to substitute a variable into a specific name=value pair. For example, to substitute the session ID in this post data: Post Data: sessionId=123456&color=blue.

        Specify the following expression: sessionId=((.+?)).

        Using the above expression, if the correlation rule's variable is found on a page and its value matches "123456", then the post data will become: sessionId={{correlationRuleVariableName,123456}}&color=blue.

      • If the name=value pair appears URL-encoded in the post data or query string, do NOT URL-encode the expression. For example, to substitute the "file/folder" parameter in this post data: Post Data: file%2Ffolder=folderXYZ%2FfileABC&session=ABC%2FDEF.

        Specify the following expression: file/folder=((.+?)).

      • If substituting a variable into a non-URL-encoded postdata or querystring, do not URL-encode the expression. For example, to substitute the "id" value of the following unencoded XML post data: Post Data: <xml><session id="12345"/></xml>.

        Specify the following expression: <session id="((.+?))"/>.

        Using the above expression, if the correlation rule's variable is found on a page and its value matches "12345", then the entire post data will become: <xml><session id="{{correlationRuleVariableName,12345}}"/></xml> .

      • If substituting a variable into a range of URL-encoded Name=Value pairs, then URL-encode the expression. For example, to replace all but the first parameter of the following URL-encoded query string data with one value: Query String: file=root%2Fdata.txt&sessionId=123%2Fxyz&color=blue.

        Specify the following expression: file=root%2Fdata.txt((.+?)).

        Using the above expression, if the correlation rule's variable is found on a page and its value matches "&sessionId=123%2Fxyz&color=blue", then the entire query string will become:

        file=root%2Fdata.txt{{correlationRuleVariableName,&sessionId=123%2Fxyz&color=blue}}

6.2.3.9 XML DOM Correlation Rules

When XML DOM Correlation Rules is selected, the Source and Target show the following options:

  • Source: Specifies all XML document object(s) to substitute as dynamic data.

  • Target: Specifies which referer header object(s) to use as the target location of the transform.

    • Replace all locations: When selected, the correlation rule applies to any object matching the source criteria.

    • Replace specified location: When selected, the correlation rule applies only to the object matching the Location criteria.

    • Location: Specifies the XML page object(s)/parameter(s) to which to apply the correlation rule using a Regular Expression. (See Variable Substitution Rules for examples.)

6.3 Recording Scripts

The OpenScript HTTP Module records parameters defined by each page of the Web application to a script which can then be played back, with parameters in the Web page filled in with values from a Databank file.

The HTTP Module records HTTP protocol requests generated by a Web browser for playback automation. The HTTP Recorder records Web browser events for playback correlation which allows users to correlate dynamic HTTP requests based on knowledge of the GUI events which generated the navigation (i.e. dynamic GET request originated from click on link "x").The HTTP Module provides a Record toolbar button that allows users to initiate the HTTP proxy recorder and captures Web page navigations to the script view. The toolbar includes start and stop recording toolbar buttons.

6.3.1 Setting HTTP Record Preferences

Before recording HTTP scripts, first set the HTTP record preferences.

  1. Start OpenScript.

  2. Select OpenScript Preferences from the View menu.

  3. Expand the OpenScript node, then expand the Record category.

  4. Select HTTP.

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

    • Setup - specifies the network settings for proxy recording.

      • Network Interface: enter or select the network IP address of the proxy server.

      • Port: specify the port to use on the proxy server.

      • Additional arguments: specify any additional command line arguments to use when starting the proxy server.

      • Maximum Download Size (MB): specify the file size for file downloads.

      • Only record requests originating from the local machine - when selected, only requests originating from the local machine are recorded by the HTTP proxy recorder.

    • Client-Side Digital Certificate File: enter the name of a .PFX-formatted digital certificate file or use the Browse button to select a file.

      • File: specifies the name of the PFX file. Enter the name or use the Browse to select the file from a drive and directory location.

      • Choose above pfx file to store: specifies the private-key password defined for the client certificate PFX file when the certificate was exported from Internet Explorer. Click Store and enter the private-key password for the client certificate.

    • SSL Version: specifies the SSL version to use.

      • SSL Version: select SSL version to use for the proxy server.

    • Close browser when stopping recorder: specify the browser options that will be used during HTTP recording.

      • Close browser: when selected, the browser closes automatically when recording is stopped.

    • Always Launch a new browser when starting recorder: Specify the browser options that will be used during HTTP recording.

      • Launch browser: When selected, the browser launches automatically when recording is started.

    • Error Handling: specifies the error handling options that will be used during HTTP recording as follows.

      • Record navigations that return error code 404: When selected, the HTTP recorder records navigations that return a Server Status Code 404: Not Found.

  6. Click the Proxy Settings tab and configure the default Proxy recorder settings as follows:

    • Chain Proxy: specifies if the OpenScript proxy is chained to another proxy.

      • Use Browser's proxy: when selected, the HTTP recorder uses the proxy configuration specified by the browser.

      • Use specified proxy: when selected, OpenScript uses the specified proxy.

        Use proxy configuration script: when selected, the specified configuration scripts will be used.

        Address: specify the URL to the JavaScript file containing the FindProxyForURL JavaScript function supplied by the system administrator for the intranet environment.

        Use proxy server: when selected, the specified proxy server will be used.

        Address: specify the network IP address of the proxy server to which to chain the OpenScript proxy.

        Port: specify the port to use on the chained proxy server.

    • Proxy Authentication: specifies the log in credentioals for authentication.

      • Username: specify the user name to use for authentication.

      • Password: specify the password to use for authentication.

  7. Click the URL Filters tab to create a new Proxy URL filter or to select a pre-defined filter.

    To use a pre-defined filter, select the checkbox for the filter in the list. Clear the checkbox to disable the filter.

    To create a new filter or edit an existing filter:

    • Click Add or Edit.

    • Specify the filter name.

    • Specify the URL filter wild card or Regular Expression pattern to match against. Wild card characters include the asterisk (*) to represent a string of characters and the question mark (?) to represent a single character.

    • Select what to apply the filter against as the value for Match:

      • Content type: When selected, the filter applies to the page content type.

      • URL: When selected, the filter applies to the page URL.

    • Select the type of filtering method to use as the value for Method:

      • Wild card: If selected, the filter uses wild card characters to filter the content.

      • Regular expression: If selected, the filter uses the regular expression provided to filter the content.

  8. Click OK when finished.

6.3.2 Recording a New HTTP Script

To create a new HTTP script, you essentially record the script.

  1. Start OpenScript.

  2. Set the HTTP Recording preferences if you haven't already.

  3. Select New from the File menu.

  4. Select HTTP Script.

  5. Click Next.

  6. Select the Repository and Workspace.

  7. Enter a script name.

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

  9. Select Record from the Script menu or click the arrow on the Record toolbar button and select Proxy Recorder.

  10. If you set the Launch browser option in the HTTP Record preferences, the browser automatically opens when you start recording with the HTTP Proxy recorder. If you did not set the Launch browser option, you will have to open a browser manually.

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

  12. Navigate the web site to record page navigations. The page navigations will be added to the Run node of the script tree.

  13. When finished navigating pages, stop the script by selecting Stop from the Script menu or clicking the Stop button on the OpenScript toolbar.

  14. If you set the Close browser option in the HTTP Record preferences, the browser automatically closes when you stop recording. If you did not set the Close browser option, you will have to close the browser manually.

  15. Expand the Run node of the script to view the page 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.

6.4 Playing Back Scripts

Once HTTP scripts have been recorded, you can play them back to validate functionality. Playback runs interactively in the OpenScript user interface and is also supported in the Oracle Load Testing.

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

6.4.1 Setting HTTP Playback Preferences

Before playing back scripts, you should set the playback preferences.

  1. Start OpenScript.

  2. Select OpenScript Preferences from the View menu.

  3. Expand the OpenScript node, then select the Playback category.

  4. Select HTTP Module.

  5. Expand the Proxy group and set the preferences as follows:

    • Proxy Host: The host name of the HTTP proxy server.

    • Proxy Port: The port to use on the proxy server.

    • Proxy Username: The use name to use for authentication.

    • Proxy Password: The password to use for authentication.

    • Non-Proxy Hosts: The host name of the non-proxy servers.

  6. Expand the Compression group and set the preferences as follows:

    • Enable GZIP: When selected, the GZIP compression format is enabled.

    • Enable Deflate: When selected, deflate is enabled.

  7. Expand the Headers group and set the preferences as follows:

    • Browser Emulation: The browser to emulate for script playback. By default the recorded browser is used.

    • Language: The language to use for script playback. The default is English.

    • HTTP Version: The HTTP version to use for script playback.

    • Accept String: The Accept string to use in the Request header for script playback.

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

    • Enable Keep Alive: If selected, keep alive is enabled on the connection.

    • Max Number of Keep Alive Requests: The maximum number of requests to make on a keep alive connection before closing it. Select Unlimited for an unlimited number of requests.

  9. Expand the SSL group to specify the default HTTP playback Secure Sockets Layer (SSL) settings:

    • SSL Version: The SSL version to use.

  10. Expand the Other group and set the preferences as follows:

    • Do not request URLs ending in: URLs ending with any of the specified patterns or file types will not be requested. Specify the ending pattern or file type separated by commas.

    • Cache Emulation: The type of user to simulate when playing back the script. This is useful for simulating different profiles of virtual users.

      A first time user places more of a load on the Web server because pages and image are not yet cached. A repeat user places less of a load on the server as only newer pages are requested and brought down from the Web server.

      Select one of the following options:

      • Do not request URLs ending in: Virtual users are considered to be using the Web site or application for the first time for each iteration so no cache is used. The cache is used during the iteration.

      • Do Not Cache: Select to not use the cache.

        Note: When using WinInet, selecting Do Not Cache has the same effect as selecting 1st Time as the Cache Emulation method. In this case, document cache is not created and not cleared.

      • 1st Time User: Virtual users are considered to be using the Web site or application for the first time for each iteration so no cache is used. The cache is used during the iteration.

      • Repeat User: Virtual users are considered to have visited or used the Web site or application previously. Pages and images are retrieved from the cache.

    • Enable Cookies: If selected, the virtual user profiles will use cookies. Use this setting if your Web application uses cookies to manage session and other context information.

    • Download Local Files: When selected, the Java Agent retrieves the requested local file contents.

    • Preserve Cookies Between Iterations: Used to preserve or automatically clear cookies added to the browser in the Run section between successive iterations of the Run section.

      Cookies added to the browser in the Initialize section will be preserved forever, unless explicitly removed in script code.

      Cookies added to the browser in the Run section will always be preserved between the final iteration of the Run section and the Finish section.

    • Preserve Connections Between Iterations: Used to preserve connections between OpenScript and the browser between successive iterations of the script.

    • Max Content Size (KB): Specifies the maximum number of KB to download from a server for a given request. The default value of this option is "Unlimited". However, the maximum Virtual User Display Size is set to 1024KB, which may cause content in the Details view to be truncated if the content size exceeds the Virtual User Display Size. You can configure the Maximum Virtual User Display Size by adding the following setting in the Additional Arguments field of the General Playback Preferences:

      -MAX_VUDATA_BYTES xxxxxxxx
      

      Where xxxxxxxx is the size in KB to set as the Maximum Virtual User Display Size. For example:

      -MAX_VUDATA_BYTES 10000000
      

      See Section 2.4.1, "General Playback Preferences" for additional information about specifying Additional Arguments.

  11. Expand the Download Manager group and set the preferences as follows:

    • Use Download Manager: When selected, the Download Manager is enabled during playback. When cleared, the Download Manager is not enabled during playback.

    • Ignored Resources (Use RegEx): Specifies the Regular Expression(s) string to use to ignore specific resources. For example, the expression Login_Banner(.+?) would not download resources such as Login_Banner1.gif and Login_Banner2.gif. Multiple Regular Expressions can be separated using a comma (,).

    • CSS Resource: When selected, css resources in <Link> tags are downloaded during playback. When cleared, css resources are not downloaded during playback.

    • Image Resource: When selected, image resources in <Img> tags, in the "background" attribute of a tag, or in <style> tags with "background:url" patterns are downloaded during playback. When cleared, image resources are not downloaded during playback.

    • Embeded Object Resource: When selected, object resources in <Embed> tags or in <Object> tags are downloaded during playback. When cleared, object resources are not downloaded during playback.

    • Script Resource: When selected, script resources in <Script> tags are downloaded during playback. When cleared, script resources are not downloaded during playback.

    • Applet Resources: When selected, applet resources in <Applet> tags are downloaded during playback. When cleared, applet resources are not downloaded during playback.

  12. Click OK when finished.

6.4.2 Playing Back HTTP Scripts

Once an HTTP script has been recorded, you can play it back.

  1. Start OpenScript.

  2. Open the HTTP script to play back.

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

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

    See"Viewing Script Playback Results" for more information.

6.4.3 Playing Back HTTP Scripts With Iterations

OpenScript allows repetitive playback of navigations in a script. The iterations can be performed with or without databanks.

  1. Start OpenScript.

  2. Open the HTTP script to play back.

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

  4. Set the iteration count to the desired number of playback iterations.

  5. Select which databank file to use, if desired.

    • Name: Lists the alias name(s) for the databank file(s).

    • Starting Row: The starting record for the databank. You can specify the starting row for the selected databank in the Databank Settings section.

    • Data: Shows the data in the specified starting row.

  6. Set the starting record for the selected databank in the Databank Settings section:

    • Name: Shows the alias name of the selected databank file.

    • Starting Record: The starting record for the selected databank. The starting record will be updated in the Databanks section.

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

6.4.4 Viewing Script Playback Results

To view HTTP script play back results:

  1. Start OpenScript.

  2. Open the HTTP script to play back.

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

  4. When playback is finished, click the Results view. If necessary, select Results from the View menu to open the Results View.

  5. In the Name column, expand the results node to view the results.

6.4.5 Resetting Encoding

The Reset Encoding menu option changes the character set used when displaying the recorded HTML. Use this option to reset the encoding for non-English web sites where the correct character encoding may not be set automatically.

To reset encoding:

  1. Start OpenScript.

  2. Open the HTTP script.

  3. Expand the HTTP script and select a navigation node.

  4. Right-click on the navigation node and select Reset Encoding from the shortcut menu.

  5. Enter the encoding value for the recorded HTML page and click OK.

6.4.6 Comparing Recorded/Playback Results

To compare HTTP script play back results with the recorded navigations:

  1. Start OpenScript.

  2. Switch to the Tester Perspective and make sure the Details View is open. If not, select Details from the View menu to open the Details View.

  3. Open the HTTP script to play back.

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

  5. When playback is finished, view the results. If necessary, select Results from the View menu to open the Results View.

  6. In the Name column, expand the results node to view the results.

  7. In the Name column, click a navigation node for a page.

  8. In the Detail View, click the Comparison tab.

  9. In the Comparison tab, select Content, Request Headers or Response Headers to view the Recorded and Playback text to compare in the lower panes.

6.4.7 Playing Back HTTP Scripts In Oracle Load Testing

Once recorded, you can play back HTTP scripts in Oracle Load Testing.

If OpenScript and Oracle Load Testing are on the same machine:

  1. Start Oracle Load Testing.

  2. Select the Repository and Workspace where the OpenScript scripts are located.

  3. Select the script to play back.

  4. Set the User Mode to Java Client.

  5. Configure the scenario parameters as required for the test.

  6. Run the scenario in the Autopilot mode.

If OpenScript and Oracle Load Testing are on the different machines:

  1. Select Export Script from the File menu.

  2. Select the additional files to export to a Zip file and click OK.

  3. Copy the exported Zip file to the Oracle Load Testing machine.

  4. Start Oracle Load Testing.

  5. Select Upload File from the Tools menu.

  6. Select OpenScript Zip as the file type.

  7. Enter the name and location of the exported OpenScript Zip file.

  8. Select the Repository and Workspace where the OpenScript scripts is to be uploaded.

  9. Click Upload to upload the file.

  10. In the Build Scenarios tab, select the script to play back.

  11. Set the User Mode to Java Client.

  12. Configure the scenario parameters as required for the test.

  13. Run the scenario in the Autopilot.

Note: Any external files, such as databanks files, must available to Oracle Load Testing (i.e. located in the path in specified in script file).

6.4.8 Posting Binary or XML File Data

To post Binary or XML File Data:

  1. Record an HTTP script as described in "Recording a New HTTP Script".

  2. Open the Java Code view.

  3. Use the following code to specify a binary data variable and the http.navigate() method to post the data:

  4. byte[] data = oracle.oats.utilities.FileUtil.readBytesFromFile("c:\\image.jpg");
    
    http.navigate(0, "http://www.mysite.com/", null, data, null, true);
    

    The same solution works for an XML file:

    byte[] data = oracle.oats.utilities.FileUtil.readBytesFromFile("c:\\file.xml");
    
    http.navigate(0, "http://www.mysite.com/", null, data, null, true);
    

If you want to store your binary or XML file inside the script itself:

  1. Switch to the Developer perspective.

  2. In the Navigator View, create a folder in the script project called "resources".

  3. Add your jpg or XML file into the new "resources" folder.

  4. Change the first line of the above code sample to this:

  5. byte[] data = getScriptPackage().getResourceFile("resources/yourfile.jpg").getData();
    

    By storing the file locally with the script, the file will always be available to the agent, even if it is run on a remote agent machine through Oracle Load Testing.

6.5 Modifying Scripts

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

6.5.1 Understanding the HTTP Module Script View

The default display for an HTTP proxy recorded script is the Tree View GUI in the Script View. The HTTP Recorder generates the Tree View and code based upon the Step Group preferences set in OpenScript. The default Step Group settings will generate Step Groups based upon page navigations in the HTTP web application.

Figure 6-1 Script Tree View

Image of the script tree view

Below each navigation will be child nodes for additional information about a page navigation, such as query strings and form action inputs. The right-click shortcut menu includes additional script modification options specific to the script generated using the HTTP Module.The Tree View is a graphical representation of the underlying code in the Code View. For example, "Page [4] Ticker List" in the above Tree View appears as Step Group and http.get method code in the Code View, as follows (line breaks and spacing added for clarity):

beginStep("[4] Ticker List", 3422);

{

   http.get(6, "http://testserver2/fmstocks/{{LINK_1_3,TickerList.asp}}", 

        http.querystring(http.param("ticker", "ter"), 

             http.param("company", "")), 

             null, true, "ASCII", "ASCII");

}

endStep();

Changes made in the Tree View are automatically updated in the Code View. Changes made in the Code View are automatically updated in the Tree View. The HTTP Module includes an API with HTTP protocol-specific methods. The commands include (but are not limited to) methods to generate GET requests, POST requests, correlation substitutions, validation, etc.

6.5.2 Using Script Variables

OpenScript scripts use variables to pass dynamic data between navigations. The navigation can be in step groups or another code sequence. You can use the Tree view and Script menu options to add custom variables to a script or code them manually using the Code view. The HTTP Proxy recorder also defines variables when recording. The following example shows how the HTTP Proxy recorder's default settings record Step Groups, navigations and variables for form inputs and links.

The script is a three page script. the first page is a login page. The second page is the page returned after login which includes links to other pages. The page in the script is the page returned by a click on a link.

Step Group 1 (beginStep("[1] Stocks", 0);) gets the page navigation and form input parameters. The http.solveXpath method assigns the input values to script variables using XPaths (for example, ".//INPUT[@name='login']/@value") to find the input value in the page source.

beginStep("[1] Stocks", 0);

{

  http.get(2, "http://testserver2/fmstocks/", null, null, true, "ASCII", "ASCII");

  {

  http.solveXpath("FORMACTION_0", ".//FORM[@name='loginform']/@action",

      "default.asp", 0);

  http.solveXpath("INPUT_0", ".//INPUT[@name='login']/@value", "ta496", 0);

  http.solveXpath("INPUT_1", ".//INPUT[@name='password']/@value", "ta", 0);

  http.solveXpath("INPUT_2", ".//INPUT[@name='LoginButton']/@value", "Login", 0);

  }

}

endStep();

beginStep("[2] Home", 3246);

{

   http.post(4, "http://testserver2/fmstocks/{{FORMACTION_0,default.asp}}",

      null,       http.postdata(http.param("login", "{{INPUT_0,ta496}}"),

      http.param("password", "{{INPUT_1,ta}}"), 

      http.param("LoginButton", "{{INPUT_2,Login}}")), 

      null, true, "ASCII", "ASCII");

  {

  http.solveXpath("LINK_1_3", ".//A[text()='research a company']/@href",

     "TickerList.asp", 0);

  }

}

endStep();

beginStep("[3] Ticker List", 1703);

{

   http.get(13, "http://testserver2/fmstocks/{{LINK_1_3,TickerList.asp}}", null,

      null, true, "ASCII", "ASCII");

}

endStep();

In step Group 2 (beginStep("[2] Home", 3264);), the page navigation uses the variables defined in Step Group 1 to pass the data values as parameters to the http.post method. The he http.solveXpath method assigns links HREF values to variables using XPaths.

beginStep("[1] Stocks", 0);

{

   http.get(2, "http://testserver2/fmstocks/", null, null, true, "ASCII",

       "ASCII");

   {

      http.solveXpath("FORMACTION_0", ".//FORM[@name='loginform']/@action",

          "default.asp", 0);

      http.solveXpath("INPUT_0", ".//INPUT[@name='login']/@value", "ta496", 0);

      http.solveXpath("INPUT_1", ".//INPUT[@name='password']/@value", "ta", 0);

      http.solveXpath("INPUT_2", ".//INPUT[@name='LoginButton']/@value", 

        "Login", 0);

   }

}

endStep();

beginStep("[2] Home", 3246);

{

  http.post(4, "http://testserver2/fmstocks/{{FORMACTION_0,default.asp}}",

     null,      http.postdata(http.param("login", "{{INPUT_0,ta496}}"),

          http.param("password", "{{INPUT_1,ta}}"), 

          http.param("LoginButton", "{{INPUT_2,Login}}")), 

          null,  true, "ASCII", "ASCII");

  {

   http.solveXpath("LINK_1_3", ".//A[text()='research a company']/@href",

   "TickerList.asp", 0);

  }

}

endStep();

beginStep("[3] Ticker List", 1703);

{

   http.get(13, "http://testserver2/fmstocks/{{LINK_1_3,TickerList.asp}}", 

      null, null, true, "ASCII", "ASCII");

}

endStep();

In Step Group 3 (beginStep("[3] Ticker List", 1703);), the page navigation uses a variable defined in Step Group 2 to pass the data values as parameters to the http.get method.

beginStep("[1] Stocks", 0);

{

   http.get(2, "http://testserver2/fmstocks/", null, null, true, "ASCII",

     "ASCII");

   {

     http.solveXpath("FORMACTION_0", ".//FORM[@name='loginform']/@action",

       "default.asp", 0);

     http.solveXpath("INPUT_0", ".//INPUT[@name='login']/@value", "ta496", 0);

     http.solveXpath("INPUT_1", ".//INPUT[@name='password']/@value", "ta", 0);

     http.solveXpath("INPUT_2", ".//INPUT[@name='LoginButton']/@value", 

         "Login", 0);

   }

}

endStep();

beginStep("[2] Home", 3246);

{

   http.post(4, "http://testserver2/fmstocks/{{FORMACTION_0,default.asp}}",

      null,      http.postdata(http.param("login", "{{INPUT_0,ta496}}"),

     http.param("password", "{{INPUT_1,ta}}"), 

     http.param("LoginButton", "{{INPUT_2,Login}}")), 

        null, true, "ASCII", "ASCII");

  {

   http.solveXpath("LINK_1_3", ".//A[text()='research a company']/@href",

      "TickerList.asp", 0);

  }

}

endStep();

beginStep("[3] Ticker List", 1703);

{

   http.get(13, "http://testserver2/fmstocks/{{LINK_1_3,TickerList.asp}}", 

      null, null, true, "ASCII", "ASCII");

}

endStep();

6.5.3 Adding a Variable to a Script

The following describes how to add a variable to a script. A regular expression is used to search a specified location for a value to set for the variable.

  1. Open or create a script project.

  2. Select the script node in which you want to add the variable.

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

  4. Expand the Variable node and select Variable.

  5. Enter the variable name.

  6. Enter the variable value.

  7. Click OK. The Set: variableName = value node is added to the script tree.

  8. In the Java Code view, the getVariables().set("varName", "value"); method will be added to the script code.

6.5.4 Adding a Solve XPath to a Script

To add a SolveXpath to a script:

  1. Open or create a script project.

  2. Select the script node where you want to add the XPath value.

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

  4. Expand the Variable node and select Solve XPath.

  5. Enter the variable name.

  6. Enter the XPath to use to search for the value for the variable.

  7. Enter the Result index value to use for the variable method.

  8. Click OK. The SolveXpath: name node is added to the script tree.

  9. In the Java Code view, the http.solveXpath(); method will be added to the script code:

    http.solveXpath("var_MyDomVar", ".//INPUT[@name='login']/@value", "ta610", 0);
    
    
    Example:
    
    http.solveXpath("FORMACTION_0", ".//FORM[@name='loginform']/@action", "default.asp", 0);
    
    
    getLogger().info("Form Name: {{FORMACTION_0}}");
    
    

6.5.5 Finding a Variable in a Script

To find a variable in a script:

  1. Open or create a script.

  2. Right-click on a post data or query string parameter containing {{ }} syntax and select Find Variable Source.

The variable referenced inside the {{ }} will be selected in the script tree node.

If more than one variable exists inside the given parameter, OpenScript will display a dialog box from which to pick which variable to find.

6.5.6 Deleting Variables from a Script

Deleting a variable from the tree view causes references to the variable using {{ }} notation in any string in the script to be reverted to their recorded values. Variable references in the Java code are also reverted.

To delete a variable from a script:

  1. Open or create a script.

  2. Right-click on a post data or query string parameter containing {{ }} syntax and select Delete.

The variable referenced inside the {{ }} syntax will be reverted to its recorded value.

To delete similar variables from a script:

  1. Open or create a script.

  2. Right-click on a post data or query string parameter containing {{ }} syntax and select Delete all type_ Variables. This menu option appears for any variables whose name is prefixed with a word followed by an underscore (_) character.

All variables of type_ referenced inside the {{ }} syntax will be reverted to their recorded values.

6.5.7 Adding Authentication to a Script

To add authentication to an HTTP script:

  1. Record an HTTP script as described in "Recording a New HTTP Script".

  2. Select the Run node.

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

  4. Select the Authentication node and click OK.

  5. Enter the URL to access for authentication.

  6. Enter a username.

  7. Enter the password for the user. Passwords are encrypted using the Base-64 Crypt algorithm.

  8. Click OK to add the Authentication node to the script tree.

  9. In the Java Code view, the Authentication consists of the code executed in the http.addAuthentication procedure:

    http.addAuthentication("http://testserver2", "username", decrypt("KRT|J|xJPDP"));
    
    

6.5.8 Adding Text Matching Tests to a Script

You can use Text Matching Tests to report an error and/or abort the script if a single HTTP request does not match the Text Matching Test criteria.

To add a Text Matching Test to an HTTP script:

  1. Record an HTTP script as described in "Recording a New HTTP Script".

  2. Expand the Run node.

  3. Select the HTTP navigation node where you want to add the Text Matching test.

  4. Select the Script menu and then select Text Matching Test from the Add menu.

  5. Enter a name for the test.

  6. Enter tthe 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 #}}).
  7. 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.

    • Response Header: Search the page Response Header.

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

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

  10. Set the Verify only, never fail option.

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

    In the Java Code view, the http.assertText method will be added to the script code if the Verify only, never fail option is not selected:

    http.assertText("MyTextMatchTest", "Home", TextPresence.PassIfPresent, MatchOption.Exact)
    
    
    
    

    In the Java Code view, the http.verifyTextmethod will be added to the script code if the Verify only, never fail option is selected:

    http.verifyText("MyTextMatchTest", "Home", TextPresence.PassIfPresent, MatchOption.Exact)
    
    

6.5.9 Adding Server Response Tests to a Script

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

To add a Server Response Test to an HTTP script:

  1. Record an HTTP script as described in "Recording a New HTTP Script".

  2. Expand the Run node.

  3. Select the HTTP navigation 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. Select Server Response Test from the Validation group.

  6. Enter a name for the test.

  7. Enter the minimum and maximum time values.

  8. Enter any error message text to log if the test fails.

  9. Set the Stop Iteration on Failure option.

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

6.5.10 Substituting Databank Variables

During playback, the parameters in the Web page are filled with values from the Databank file. However, you can substitute a databank variable for a query string parameter in an HTTP script.

  1. Record an HTTP script as described in "Recording a New HTTP Script" that has query string parameters.

  2. Expand the Run node.

  3. Expand the node containing query string parameters.

  4. Right-click a query string parameter node and select Substitute Variable from the shortcut menu.

    • If you have already configured the script with one or more databanks, select the databank field to substitute for the query string parameter from the desired databank file and click Finish.

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

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

      • Select the column (field name) to substitute for the query string parameter and click Finish.

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

In the Java Code view, the databank variable appears as {{databankFileName.field,recordedValue}} in the http.querystring(http.param() parameter of the http.get method:

http.get(6, "http://testserver2/fmstocks/TickerList.asp", 

       http.querystring(http.param("ticker", "{{fmstocks_data.ticker,ter}}"), 

       http.param("company", "")), 

       null, true, "ASCII", "ASCII");

6.5.11 Substituting Post Data Variables

To substitute a variable for a Post Data parameter in an HTTP script:

  1. Record an HTTP script that has Post Data parameters.

  2. Expand the Run node.

  3. Expand the node containing Post Data parameters.

  4. Right-click a Post Data parameter node and select Substitute Variable from the shortcut menu.

    • If you have already defined custom variables in the script, select the variable name to substitute for the Post Data parameter and click Finish.

    • If you have not already defined custom variables in the script, select Create new script variable and click Next.

      The Search for Value panel lists the navigation(s) that contain the post data value. If there are more than one navigation that contain the post data value, select the navigation were you want to substitute a variable. When you select a navigation, the data for that navigation appears below with the specific source highlighted along with a suggested Regular Expression.

      • Specify the Regular Expression to use for the substitute variable for the Post Data parameter and click Next.

      • Click Test to verify the Regular Expression locates the correct data value to substitute.

      • If the Regular Expression locates the correct data value to substitute, click Next to continue. If the Regular Expression does not return the correct data value, modify and test the Regular Expression until the desired data value is located and click Next to continue.

      • Enter a name for the substitute variable.

      • If you want to add the variable as a variable rule in a correlation library, click Add to library and specify the rule information. If not, click Finish to insert the substitute script variable into the script

    In the Tree View, the script variable appears in place of the recorded value as {{variableName,recordedValue}}.

    In the Java Code view, the script variable appears as variableName,Regular Expression parameters in the http.solve method:

    http.solve("MY_VAR", "<INPUT id=login name=login value=\"(.+?)\">", null, false, Source.Html, 0);
    
    

6.5.12 Adding a Cookie to a Script

To add a cookie to a script:

  1. Open or create a script project.

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

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

  4. Expand the Cookie node and select Add Cookie.

    This dialog box lets you add a cookie to a script.

  5. Enter a valid cookie string.

    • Cookie String: Specifies the cookie string to add

    • Cookie String Charset: Specifies the character set to use for the cookie string

  6. Click OK. The Cookie node is added to the script tree.

  7. In the Java Code view, the http.addCookie method will be added to the script code:

    http.addCookie("cookieString", "charset");
    
    
    Example:
    
    
    http.addCookie("username=testCookie", "ASCII");
    
    java.util.List <Cookie> cookies = http.getBrowser().getCookieJar().getAllCookies();
    
    for (Cookie cookie : cookies) {
    
       getLogger().info(cookie.getUrl());
    
       getLogger().info(cookie.getCookieString());
    
       }
    
    

6.5.13 Removing a Cookie From Script

To remove a cookie from a script:

  1. Open or create a script project.

  2. Select the script node where you want to place the remove cookie node.

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

  4. Expand the Cookie node and select Remove Cookie.

  5. Enter the cookie string to remove.

  6. Click OK. The Remove Cookie node is added to the script tree.

  7. In the Java Code view, the http.removeCookie method will be added to the script code:

    http.removeCookie("cookieString");
    
    

6.5.14 Adding a User Agent to a Script

To add a user agent to a script:

  1. Open or create a script project.

  2. Select the script node where you want to add the user agent.

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

  4. Expand the HTTP node and select Set User Agent.

  5. Enter the user agent details.

  6. Click OK. The user agent node is added to the script tree.

  7. In the Java Code view, the http.setUserAgent("agent"); method will be added to the script code:

    http.setUserAgent("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727)");
    
    

6.6 Adding Navigation

The HTTP Module allows you to view and edit all recorded navigations and related parameters (headers, post data, etc.) in either the script GUI Tree view or the Code View. It also enables you to view and edit any default correlation/parameterization of dynamic navigations and apply your own correlation to handle dynamic navigations.

6.6.1 Understanding Navigation Editing (Correlation)

You can use the Navigation Editing GUI View to configure the navigations you want to parameterize and the correlation rules you want to apply. The GUI allows viewing and editing properties for different types of navigations (for both Web/HTTP applications and non-Web/HTTP applications) and data inputs.

The Display & Editing for Recorded Navigations view includes recorded navigations and any navigation parameters like headers, etc. It also provides a mechanism for users to edit/add/delete navigations including dynamic parameter sources/targets.

Figure 6-2 Display & Editing for Recorded Navigations view

Image of Recorded Navigations view
Description of "Figure 6-2 Display & Editing for Recorded Navigations view"

The Display & Editing for Correlation Rules Library & Editing view includes a list of all default correlation rules included in the module(s), listed by application type. It also provides a mechanism for adding, editing or deleting correlation rules.

Figure 6-3 The Display & Editing for Correlation Rules Library & Editing view

HTTP Module correlation preferences.
Description of "Figure 6-3 The Display & Editing for Correlation Rules Library & Editing view"

You can specify the navigations you want to parameterize and the data source you want to drive the inputs from through navigation editing commands in the code view. These commands map to the navigation editing GUI view.

beginStep("[2] Home", 3266);

{

   http.post(4, "http://testserver2/fmstocks/{{FORMACTION_0,default.asp}}", 

        null,         http.postdata(http.param("login", "{{INPUT_0,ta616}}"), 

             http.param("password", "{{INPUT_1,ta}}"), 

             http.param("LoginButton", "{{INPUT_2,Login}}")), 

             null, true, "ASCII", "ASCII");

             {

             http.solveXpath("LINK_1_3", ".//A[text()='research a

                  company']/@href", "TickerList.asp", 0);

             http.solveXpath("LINK_1_2", ".//A[text()='Logout']/@href",

                  "logout.asp", 0);

             }

}

endStep();

6.6.2 Adding HTTP Get Navigation

To add an HTTP Get Navigation to an HTTP script:

  1. Record an HTTP script as described in "Recording a New HTTP Script".

  2. Select the Run node.

  3. Select the Script menu, then select HTTP Get Navigation from the Add sub menu.

  4. On the Base URL tab, specify the following:

    • Path: The base URL path to use for the navigation.

    • Request charset: The character set to use for the request.

    • Response charset: The character set to use for the response.

    • Encode strings: When selected, control and special characters in string are encoded to the Character entity references. When cleared, control and special characters in string are not encoded.

  5. On the Query String tab, use the Add button to add the requested name/value pairs to the Base URL. Note that you can use the Up and Down buttons to move the selected query string parameter up or down one place in the search order.

  6. On the Headers tab, use the Add button to add name/value pairs and actions to the Base URL.

  7. Click OK to add the HTTP Get Navigation node to the script tree.

  8. In the Java Code view, the HTTP Get Navigation consists of the code executed in the http.Get method (line breaks and spacing added for clarity):

    http.Get(1, "http://testserver2",
    
           http.querystring(http.param("QueryString1", "QueryValue1"),
    
                http.param("QueryString2", "QueryValue2"),
    
                       http.param("QueryString3", "QueryValue3")),
    
           http.headers(http.header("HeaderString1", "HeaderValue1NoActions",
    
                        Header.HeaderAction.Add),
    
           http.header("HeaderString2", "HeaderValue2SetifNotSet",
    
                        Header.HeaderAction.SetIfNotSet),
    
           http.header("HeaderString3", "HeaderValue3ApplytoAll",
    
                        Header.HeaderAction.GlobalAdd),
    
           http.header("HeaderString4", "HeaderValue4BothActions",
    
                        Header.HeaderAction.GlobalSetIfNotSet)),
    
           false, "ASCII", "ASCII");
    
    

6.6.3 Adding HTTP Post Navigation

To add an HTTP Post Navigation to an HTTP script:

  1. Record an HTTP script as described in "Recording a New HTTP Script".

  2. Select the Run node.

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

  4. Select the HTTP Post Navigation node and click OK.

  5. On the Base URL tab, specify the following:

    • Path: The base URL path to use for the navigation.

    • Request charset: The character set to use for the request.

    • Response charset: The character set to use for the response.

    • Encode strings: When selected, control and special characters in string are encoded to the Character entity references. When cleared, control and special characters in string are not encoded.

  6. On the Query String tab, use the Add button to add the requested name/value pairs to the Base URL. Note that you can use the Up and Down buttons to move the selected query string parameter up or down one place in the search order.

  7. On the Post Data tab, use the Add button to add name/value pairs to the Base URL.

  8. On the Headers tab, use the Add button to add name/value pairs and actions to the Base URL.

  9. Click OK to add the HTTP Post Navigation node to the script tree.

  10. In the Java Code view, the HTTP Post Navigation consists of the code executed in the http.Post method (line breaks and spacing added for clarity):

    http.Post(12, "http://testserver2",
    
         http.querystring(http.param("QueryString1", "QueryValue1"),
    
                      http.param("QueryString2", "QueryValue2"), 
    
                      http.param("QueryString3", "QueryValue3")), 
    
         http.postdata(param("PostString1", "PostValue1"), 
    
                      http.param("PostString2", "PostValue2"), 
    
                      http.param("PostString3", "PostValue3")), 
    
         http.headers(http.header("HeaderString1", "HeaderValue1NoActions",
    
                             Header.HeaderAction.Add), 
    
                      http.header("HeaderString2", "HeaderValue2SetifNotSet",
    
                             Header.HeaderAction.SetIfNotSet), 
    
                      http.header("HeaderString3", "HeaderValue3ApplytoAll",
    
                             Header.HeaderAction.GlobalAdd), 
    
                      http.header("HeaderString4", "HeaderValue4BothActions",
    
                             Header.HeaderAction.GlobalSetIfNotSet)), 
    
         true, "ASCII", "ASCII");
    
    

6.6.4 Adding an HTTP Multipart Post Navigation

To add an HTTP Multipart Post Navigation to an HTTP script:

  1. Record an HTTP script as described in "Recording a New HTTP Script".

  2. Select the Run node.

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

  4. Expand the HTTP Multipart Navigation node and select the Multipart Post Navigation node and click OK.

  5. On the Base URL tab, enter the following:

    • Path: The base URL path to use for the navigation.

    • Boundary: Specify the boundary to use to identify parts of a multipart form input navigation (file navigations). The boundary is used within the Content-Type: multipart/form-data; boundary="" response sent by the user agent. The specified boundary should not occur in any of the file data.

    • Request charset: The character set to use for the request.

    • Response charset: The character set to use for the response.

    • Encode strings: Select this option so that control and special characters in string are encoded to the Character entity references. When cleared, control and special characters in string are not encoded

  6. On the Query String tab, use the Add button to add name/value pairs to the Base URL.

  7. On the Post Data tab, use the Add button to add postdata to the Base URL. You can specify standard Postdata name/value pairs or postdata files. If you select File, specify the path, filename, and content type for each postdata file parameter.

  8. On the Headers tab, use the Add button to add name/value pairs and actions to the Base URL.

  9. Click OK to add the HTTP Multipart Post Navigation node to the script tree.

  10. In the Java Code view, the HTTP Multipart Post Navigation consists of the code executed in the http.multipartPost method (line breaks and spacing added for clarity):

    http.multipartPost(13, "http://testserver2", 
    
            http.querystring(http.param("QueryString1", "QueryValue1"), 
    
                        http.param("QueryString2", "QueryValue2"), 
    
                        http.param("QueryString3", "QueryValue3")), 
    
            http.postdata(http.param("PostDataString1", "PostDataValue1Standard"), 
    
                        http.param("PostDataString2", "PostDataValue2FilePath",
    
                              "PostDataValue2FileName", "ASCII"), 
    
                        http.param("PostDataString3",
    
                          "C:\\Oracle\\OFT\\DataBank\\fmstocks_data.csv",
    
                          "C:\\Oracle\\OFT\\DataBank\\fmstocks_data.csv", "CSV")),
    
            http.headers(http.header("HeaderString1", "HeaderValue1NoActions",
    
                              Header.HeaderAction.Add), 
    
                        http.header("HeaderString2", "HeaderValue2IfNotSet",
    
                              Header.HeaderAction.SetIfNotSet), 
    
                        http.header("HeaderString3", "HeaderValue3ApplytoAll",
    
                              Header.HeaderAction.GlobalAdd), 
    
                        http.header("HeaderString4", "HeaderValue4Both",
    
                              Header.HeaderAction.GlobalSetIfNotSet)), 
    
            "boundary", false, "ASCII", "ASCII");
    
    

6.6.5 Adding an HTTP XML Post Navigation

To add an HTTP XML Post Navigation to an HTTP script:

  1. Record an HTTP script as described in "Recording a New HTTP Script".

  2. Select the Run node.

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

  4. Expand the XML Post Navigation node and select the XML Post Navigation node and click OK.

  5. On the Base URL tab, specify the following:

    • Path: The base URL path to use for the navigation.

    • Request charset: The character set to use for the request.

    • Response charset: The character set to use for the response.

    • Encode strings: When selected, control and special characters in string are encoded to the Character entity references. When cleared, control and special characters in string are not encoded.

  6. On the Query String tab, use the Add button to add the requested name/value pairs to the Base URL. Note that you can use the Up and Down buttons to move the selected query string parameter up or down one place in the search order.

  7. On the Post Data tab, enter the XML post data to add to the Base URL.

  8. On the Headers tab, use the Add button to add name/value pairs and actions to the Base URL.

  9. Click OK to add the HTTP XML Post Navigation node to the script tree.

  10. In the Java Code view, the HTTP XML Post Navigation consists of the code executed in the http.xmlPost method (line breaks and spacing added for clarity):

    http.xmlPost(0, "http://xmltest2", 
    
            http.querystring(http.param("xmlQueryString1", "xmlQueryValue1"), 
    
                      http.param("xmlQueryString2", "xmlQueryValue2"), 
    
                      http.param("xmlQueryString3", "xmlQueryValue3")),  
    
                             "xmlPostDataString", 
    
            http.headers(http.header("xmlHeaderString1", "xmlHeaderValue1NoAction",
    
                               Header.HeaderAction.Add), 
    
                      http.header("xmlHeaderString2", "xmlHeaderValue2IfNotSet",
    
                               Header.HeaderAction.SetIfNotSet), 
    
                      http.header("xmlHeaderString3",
    
                       "xmlHeaderValue3ApplytoAll", Header.HeaderAction.GlobalAdd),
    
                      http.header("xmlHeaderString4", "xmlHeaderValue4Both",
    
                               Header.HeaderAction.GlobalSetIfNotSet)), 
    
            false, "ASCII", "ASCII");
    
            
    
    

6.6.6 Using the HTTP Module API

The Web Functional Module includes a script Application Programming Interface (API) specific to Web HTTP protocol testing. The HTTP Module recorder creates the Java code that corresponds to the Tree View and displays the HTTP 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 HTTP API to enhance recorded scripts with additional testing functionality. Commands that are specific to the HTTP Module are part of the "http" class. You can also leverage other commands from other enabled classes (services) or general Java commands in your scripts.

Some examples of the HTTP Module API include:

  • Adding authentication

  • Adding and removing cookies

  • Adding HTTP navigation (Get and Post)

  • Adding HTTP Multipart Post navigation

  • Adding HTTP Multipart name/value pairs

  • Adding name/value pairs

  • Adding XML Post navigation

  • Setting the user agent

Many API methods can be added using the HTTP Module Tree View. Additional methods can be added using the Java Code view.