web.submitData

Performs an "unconditional" or "contextless" form submission.

ExampleAction Functions

Syntax

web.submitData( {object} ); 

JavaScript Object

{
    stepName: "<string>",
    action: "<string>",
    method: "<string>",
    encType: "<string>",
    recContentType: "<string>",
    encodeAtSign: "<string>",
    targetFrame: "<string>",
    referer: "<string>",
    mode: "<string>",
    userAgent: "<string>",
    snapshot: "<string>",
    itemData: [{"name":"<string>","value|encryptedValue":"<string>",
            "file":"<string>","contentType":"<string>","filePath":"<string>",
            "contentTransferEncoding":"<string>"}],,
    extraRes: [{url:"<string>",referer:"<string>"}]
}
Property Name Description
stepName The name of the step, as it appears in the graphical script.
action The HTTP address of the action to perform when submitting the data.
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. You can also specify action/sfx, which indicates to search the form using the suffix of the action.
methodThe form submission method: POST or GET (default: POST).
encTypeThe encoding method used.
recContentTypeThe content type, for example, text/html.
encodeAtSignEncode the "@" sign as in its ASCII representation. The possible values are Yes or No.
targetFrameThe name of the frame containing the current link or resource. Click targetframe for more information.
refererThe URL of the referring web page. The page that referred to the current page. If the location was explicitly expressed, this attribute is omitted.
modeThe Recording Level: HTML or HTTP. Click Recording Level / mode (Web) for more information.
userAgentIdentifies a component other than the browser that will execute the step, for example, an ActiveX component running under the browser. This user agent header is sent for the requests made by the step. No check is made to confirm that the user agent argument matches the browser's user-agent runtime setting. Non-browser steps do not affect the emulated browser context, nor do they build a new context from the result.
itemData The data fields used to define the form submission. Because the request is contextless, the list of data fields includes all hidden fields. The rules of data encoding for submission of forms apply. For a list of the possible entries in the list, see Item Data below in this topic.
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 generated by non–HTML mechanisms in the web page.

Return Values

Not applicable

Parameterization

The following argument(s) can be parameterized using standard parameterization: action, method, List of Data Fields

General Information

The web.submitData function is an action function that performs an "unconditional" or "contextless" form submission. (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.) This function allows you to generate GET and POST requests as made by the HTML forms. You do not need to have a form context to execute this request.

web.submitData is recorded only when VuGen is in either the url–based recording mode, or in the HTML–based recording mode with the A script containing explicit urls only option checked (see VuGen's Recording Options).

The method indicates how the data of the form is sent to the server, whether as a query within the url (GET), or as a request body (POST).

This function is generated when VuGen is set to record a web session in HTTP (all requests from the server) recording mode. VuGen also records a web.submitData statement whenever a form is submitted and it is unable to generate a web.submitForm statement.

Examples of non–HTML–generated resources are .gif and .jpg images. The extraRes property is only inserted when the recording option for these resources is set at Record within the current script step. This is the default setting. See the Virtual User Generator Help Center (select the relevant version).

The HTTP header can be modified to pass additional information about the request to the server. Using HTTP headers you can, for example, 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, or to modify all subsequent requests see web.addAutoHeader.

The encType attribute specifies a Content Type to be specified as the value of the "Content–Type" request header. It indicates the encoding type (either url–encoding or multi–part) to be used for generating an HTTP request from other arguments. Use one of the following:

  • "encType=application/x–www–form–urlencoded"

  • "encType=multipart/form–data" (any "; boundary=" is silently ignored)

  • "encType=" (an empty string, indicating that no "Content–Type" request header is to be generated).

An encType specification silently overrides any web.addHeader or web.addAutoHeader settings for "Content–Type". If encType is omitted, any applicable web.add[Auto]Header setting is used. If there is none, "method=POST", "application/x–www–form–urlencoded" is used. If method is not POST, no "Content–Type" request header is generated.

Item Data

The possible entries in the ItemData section are:

  • name - The form field name. For example: "name=name_of_files"

  • value - The value in the Content-Disposition parameter of the multipart message. For example: "Value=c:/dummy/dummy.doc"

    encryptedValue - The value in the Content-Disposition parameter of the multipart message, encoded. See below in this topic.

  • file - Whether the message content is a file. For example: "File=Yes"

  • contentType - The value in the contentType parameter of the multipart message (for example: "contentType=text/special"). contentType, a file type specifier, is needed in the ItemData section in cases where the encType is a multipart/form–data file upload. contentType is passed as one value of a data clause in the itemData section where "File=Yes" is specified, and applies only to the file in the same clause.

  • filepath- The path to the uploaded file, for example, "Filepath=stub.txt". The path can be relative (recommended) or absolute. If relative, the path is based on the path specified in the Value entry. Backslashes must be escaped. Filepath is passed as one value of a data clause in the itemData section where "File=Yes" is specified.

  • contentTransferEncoding - The value in the Content-Transfer-Encoding parameter of the multipart message (for example, "ContentTransferEncoding=html/text"). ContentTransferEncoding is passed as one value of a data clause in the itemData section where "File=Yes" is specified.

Normally, a "Content–Type" entity header is generated in the request body according to the extension of the uploaded file. For example:

–––––––––––––––––––––––––––––7d025e2b16b064e\r\n Content–Disposition: form–data; name="uploaded_file"; filename="D:\\temp\\a.txt"\r\n Content–Type: text/plain\r\n \r\n

However, especially for non–browser applications, content type based on the file type may not be correct. To override it, contentType can be specified. Specifying an empty value will cause the Content–Type header not to be included for this file.

When the uploaded file is empty, "application/x–unknown–content–type" is used regardless of the file extension. Explicitly specifying contentType, empty or not, overrides this mechanism.

No attempt is made to check whether the specified contentType is recognized or valid.

When web.submitData 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", ENDITEM,

to:

"name=grpType", "EncryptedValue=409e41ebf102f3036b0549c799be3609", ENDITEM,

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 covert the entire value string to an lr.unmask call. Select an entire string between quote marks, not including the quote marks. Right-click and select Mask String. The output looks like:

"name=grpType", lr.unmask("40d176c46f3cf2f5fbfaa806bd1bcee65f0371858163"), ENDITEM,

Example

web.submitData(
    {
        name : 'Correlation_ASP_welcome.asp', 
        action : 'http://kalimanjaro/Correlation_ASP_Project/Correlation_ASP_welcome.asp', 
        method : 'GET', 
        encType : '', 
        targetFrame : '', 
        recContentType : 'text/html', 
        referer : 'http://kalimanjaro/Correlation_ASP_Project/Correlation_ASP_setup.asp', 
        snapshot : 't5.inf', 
        mode : 'HTML', 
        itemData : 
            [
                {
                    name : 'first_field_name', 
                    value : 'param1'
                },
                {
                    name : 'use_2_fields', 
                    value : 'yes'
                },
                {
                    name : 'second_field_name', 
                    value : 'praram2'
                },
                {
                    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 : 'frame_target', 
                    value : 'mainframe'
                },
                {
                    name : 'frameset_or_iframe', 
                    value : 'use_frameset'
                }
            ]
    }
);