WebPageSubmit Function

Action

Queries the currently active page for the specified HTML form. If the form is found, the function submits the form to the Web server by means of the HTTP POST method and reads the response page. If the retrieved document is of content type HTML, it is parsed and embedded documents are requested. This function also supports multi-part file upload (RFC1867-compliant file upload).

The form value pairs of the parsed HTML base are used to provide data for the subsequent submission. This way hidden fields, for example, session ids, are automatically taken from the HTML form and submitted to the server. These default values may be overwritten by using a form identifier declared in the dclform section. The submission method, GET or POST, is defined by the HTML form. If it is missing, the GET method will be used.

WebPageSubmit() recognizes automatically form and form entry.

A file that is to be uploaded must be specified by a name-value pair in the following way:
"filename" := "<name of the input tag>;<file name>;<content type>";

Form identification rules are listed herein, ordered by priority:

  • HTML forms to be queried are identified by a name:

    <form name="form1" action="data2html.asp">
      <input type=hidden name="cantfind" value="#b21334a45">
      <input type=text name=ShoeSize value=44>
    </form>
  • The “value” attribute of the submit button:

    <form name="form1" action="data2html.asp">
      <input type="submit" value=Insert>
    </form>
  • The image used for submission may provide an “alt” attribute:

    <form name="form1" action="data2html.asp">
      <input type="image" src=box5.gif alt="PostBox">
    </form>

In the case of a changing HTML form name, you can refer to the HTML form by number. All forms are numbered sequentially throughout the Web page.

Include file

WebAPI.bdh

Syntax

WebPageSubmit( in sHtmlForm   : string allownull,
               in formSubmit  : form,
               in sTimer      : string optional,
               in nHtmlFormNo : number optional,
               in sFrame      : string optional,
               in hContext    : number optional): boolean;

Return value

  • true if the form is found and submitted successfully

  • false otherwise

Parameter Description
sHtmlForm The name of the HTML form to search for in the currently active Web page, or if the hContext parameter is not omitted to search for in the specified context. Set this parameter to NULL if a name is not available or if you want to identify the HTML form only by its number.
formSubmit Form identifier used in the dclform section. The expanded form is added to the body of the request. The Content-Length and Content-Type header are added automatically.
sTimer Name of the timer used for page measurements (optional). If this parameter is omitted, no measurements are performed.
nHtmlFormNo Number of the Web form in the Web page (optional). If sHtmlForm is NULL, the number specifies the n-th form in the page. If sHtmlForm specifies a name, the number specifies the n-th form with the given name.
sFrame The name of the frame the document is assigned to (optional). If this parameter is provided, the form is searched only within this frame document.
hContext Context, stored by a prior call of the WebPageStoreContext function, where to search for the form (optional). If this parameter is omitted the form is searched in the actual page and all stored contexts.

Example

dcltrans
  transaction TMain
  var
    hContext: number;
  begin
    WebPageUrl("http://lab3/shopit/", "ShopIt - Greetings");
    WebPageStoreContext(hContext);
    WebPageLink("Join the experience!", "ShopIt - New Visitor");
    WebPageSubmit("Continue", CONTINUE001, "ShopIt - Main menu");
    WebPageLink("Products", "ShopIt - Products");
    WebPageLink(NULL, "ShopIt - Product", 3);
    WebPageSubmit("Search", SEARCH001, "ShopIt - Search", 0, NULL, hContext);
  end TMain;

dclform
  CONTINUE001:
    "name"            := "jack",
    "New-Name-Button" := "Continue";
  SEARCH001:
    "search"          := "boot";

Example (for file upload)

 transaction TMain
  var
  begin
    WebPageUrl("http://demowebsite/conn_main.asp", "SilkPerformer Internet Compliancy Tests - Connectivity - Main");
 
    ThinkTime(37.7);
    WebPageSubmit("Submit", SUBMIT001, "Upload"); // Form 8
 
    ThinkTime(12.7);
    WebPageLink("Back", "SilkPerformer Internet Compliancy Tests - Connectivity - Main (#1)"); // Link 1
  end TMain;

dclform
  SUBMIT001:
    "filename" := "my_file;Math.jar;application/x-zip-compressed" <ENCODE_NONE> , // changed
    "submit"   := "" <USE_HTML_VAL> ; // unchanged, value: "Submit"