web.submitForm

Submits a form.

ExampleAction 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
stepNameThe step name.
actionThe ACTION attribute of the FORM element. The ACTION attribute specifies the address (URL) to be used to carry out the action of the form.
frameThe 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.
targetFrameSee targetframe
userAgentSee userAgent
ordinalSee 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.

itemDataData 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.
extraResResources 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 Professional 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 encode (mask) it. Change the word "Value" to "EncryptedValue", and substitute the encoded value for the recorded value. For example:

Change:

name:"grpType", value:"radRoundtrip"

to:

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

To get an encoded value for later use, copy the value. Then go to Windows Start menu > Password Encoder. Paste the value into the Password field, and click Generate. The masked string appears in the Encoded String box. Click Copy and paste the masked string into a parameter for later use, or assign the value to a string variable.

Another option for encoding the value is to convert the entire value string to an lr.unmask call. Select the entire string between quote marks, not including the quote marks themselves. Right-click in the selected string and select Mask String. The output looks like:

name="grpType", EncryptedValue:lr.unmask("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'
                }
            ]
    }
);