JavaScript Functions > Alphabetical Listing of Web Functions > web.submitForm

web.submitForm

Submits a form.

Example Action Functions

Syntax

web.submitForm( {object} );

JavaScript Object

{
    stepName: "<string>",
    action: "<string>",
    frame: "<string>",
    targetFrame: "<string>",
    resourceByteLimit: <number>,
    userAgent: "<string>",
    ordinal: <number>,
    snapshot: "<string>",
    hiddenFields: [{name:"<string>" ,value|encryptedValue:"<string>",namePrefix:"<string>", nameSuffix:"<string>"}],
    itemData: [{name:"<string>", value|encryptedValue:"<string>"}],
    extraRes: [{url:"<string>", referer:"<string>"}]
}
Property Name
Description
stepName The step name.
action The ACTION attribute of the FORM element. The ACTION attribute specifies the address (URL) to be used to carry out the action of the form.
frame The name of the frame in which you recorded the operation. The name of the frame is the value of the name attribute of the FRAME element.
targetFrame See targetframe
userAgent See userAgent
ordinal See ordinal
resourceByteLimit See resourceByteLimit
hiddenFields

Optional.

name: The name attribute within an INPUT element of the field. It is the name of the field as it appears on the Web page.

NAMEPFX and NAMESFX are the prefix and suffix of the name attribute within an INPUT element of a field. They identify an INPUT element when the name is dynamic but has a fixed prefix and suffix. The name attribute is the name of the field as it appears on the Web page.

itemData Data items help identify a form. A form is identified by both data items and attributes. name is the name attribute within an INPUT element of the field. It is the name of the field as it appears on the Web page.
extraRes Resources to be downloaded, for example, .gif and .jpg images. Only inserted when the recording option for these resources is set at "Record within the current script step". This is the default setting.

Return Values

Not applicable

Parameterization

You can use standard LoadRunner parameterization with all string values in JavaScript objects.

General Information

The web.submitForm function is an action function that submits a form. (Each Web action Function in a script causes the browser to display a new Web page or frame. All Web action functions can be recorded by VuGen.) The web.submitForm function may be executed only in the context of a previous operation.

VuGen tries to uniquely identify each form by recording only the data fields. If this is insufficient for unique identification, VuGen records the action attribute. If this is still insufficient for unique identification, VuGen records the ordinal attribute, and not the action attribute.

web.submitForm is recorded only when VuGen is in HTML–based recording mode (see VuGen's Recording Options).

When web.submitForm is recorded, "name" and "value" are generally recorded for items in the itemData section. If you do not wish the recorded value to appear in the script, you can encrypt it. Change the word "Value" to "EncryptedValue", and substitute the encrypted value for the recorded value. For example:

Change:

name:"grpType", value:"radRoundtrip"

to:

name:"grpType", EncryptedValue:"409e41ebf102f3036b0549c799be3609"

To get the encrypted value, copy the recorded value. Then run Start > Programs > LoadRunner > Tools > password Encoder. Paste the value into the password field, and click Generate. The encrypted string appears in the Encoded string box. Click the Copy button, then paste the encrypted string into the script, overwriting the recorded value.

Another option for encrypting the value is to convert the entire value string to an lr.decrypt call. Select the entire string between quote marks, not including the quote marks themselves. Right-click in the selected string and choose the Encrypt stringoption. The output looks like:

name="grpType", EncryptedValue:lr.decrypt("40d176c46f3cf2f5fbfaa806bd1bcee65f0371858163")

Changing the Header

The HTTP header can be modified to pass additional information about the request to the server. For example, using HTTP headers you can allow other content types in the response such as compressed files, or you can request a Web page only on certain conditions. To modify the HTTP header in the request see web.addHeader. To modify all subsequent requests, see web.addAutoHeader.

Example

web.submitForm(
    {
        name : 'Correlation_ASP_welcome.asp', 
        snapshot : 't5.inf', 
        itemData : 
            [
                {
                    name : 'first_field_name', 
                    value : 'param1'
                },
                {
                    name : 'first_sessionid_large', 
                    value : '<OFF>'
                },
                {
                    name : 'use_2_fields', 
                    value : 'yes'
                },
                {
                    name : 'second_field_name', 
                    value : 'praram2'
                },
                {
                    name : 'second_sessionid_large', 
                    value : '<OFF>'
                },
                {
                    name : 'first_sessionid_change_rate', 
                    value : 'three_times'
                },
                {
                    name : 'second_sessionid_change_rate', 
                    value : 'three_times'
                },
                {
                    name : 'use_links_forms', 
                    value : 'links_only'
                },
                {
                    name : 'form_method_is', 
                    value : 'GET'
                },
                {
                    name : 'cookie_correlation', 
                    value : '<OFF>'
                },
                {
                    name : 'frames_requested', 
                    value : '<OFF>'
                },
                {
                    name : 'frame_target', 
                    value : 'frame'
                },
                {
                    name : 'frameset_or_iframe', 
                    value : 'use_frameset'
                }
            ]
    }
);