WebVerifyContent Function

Action

Parses the HTML response and counts the appearance of the specified content with the provided string. If the verification condition is not met, an error is raised; the severity of this error can be specified. The appearance count of the specified content can be retrieved by an optional out-parameter. If this parameter is provided, a subsequent low-level web function will not return until the request has finished. If it is omitted, a subsequent low-level web function will not wait for the completion of the request. If the verified request is a cache hit or a conditional cache hit, the content is not verified, an informational message is displayed, and the optional out parameter retrieves a -1. If the bForceLoad parameter is set to true the page must not be found in the cache and has to be requested; the result is provided under all circumstances.

When verifying/parsing an HTML page that consists of multiple frames, you can specify which frame document to verify/parse by specifying the sFrame parameter. By default, all HTML documents of the HTML page are scanned. This applies to HTML pages that are retrieved through a page-level command like WebPageUrl or WebPageLink.

It is important to know that all parsing and verification functions must be specified before the Web API call for which the response data should be parsed/verified. You can specify multiple parse/verification functions before a Web API call. The order of the parse/verification functions is not relevant (Exception: WebParseDataBound and WebVerifyDataBound using the flag WEB_FLAG_SYNCHRON).

注: This function is obsolete. It can still be used, although it's recommended to use the WebVerifyHtml function instead.

Include file

WebAPI.bdh

Syntax

WebVerifyContent( in    sContent     : string,
                  in    nAppearance  : number optional,
                  in    sFrame       : string optional,
                  in    nModeCompare : number optional,
                  in    nSeverity    : number optional := SEVERITY_ERROR,
                  in    bForceLoad   : boolean optional,
                  inout nResult      : number optional ) : boolean;

Return value

  • true if the parsing modifier could be created successfully

  • false otherwise

Parameter Description
sContent String to compare with the parsed HTML content.
nAppearance Value to which the actual appearance of the specified content string is compared (see nModeCompare)(optional). If this parameter is omitted, the specified string must appear at least once to fulfill the verification rules.
sFrame Frame where the content string is to be searched for (optional). If this parameter is omitted the whole page is scanned.
nModeCompare

Specifies how the compare operation is performed. Can be a combination of the following values:

WEB_VER_FLAG_CASE_SENSITIVE
If this flag is set the string compare operation is case sensitive.
WEB_VER_FLAG_CONTENT_EQUAL
The verification succeeds if the actual appearance is equal to nAppearance.
WEB_VER_FLAG_CONTENT_GREATER (default)
The verification succeeds if the actual appearance is greater than nAppearance.
WEB_VER_FLAG_CONTENT_SMALLER
The verification succeeds if the actual appearance is smaller than nAppearance.
nSeverity Optional: Severity of the error that is raised if the verification fails. Can be one of the following values:
  • SEVERITY_SUCCESS: Success; no error (numerical value: 0)
  • SEVERITY_INFORMATIONAL: Informational; no error (numerical value: 1)
  • SEVERITY_WARNING: Warning; no error (numerical value: 2)
  • SEVERITY_ERROR: (Default) Error; simulation continues (numerical value: 3)
  • SEVERITY_TRANS_EXIT: Error; the active transaction is aborted (numerical value: 4)
  • SEVERITY_PROCESS_EXIT: Error; the simulation is aborted (numerical value: 5)
bForceLoad If this parameter is true, the page has to be loaded (no cache hit possible).
nResult If a variable is provided, it will receive the number of appearances of the specified content string (optional).

Example

dcltrans
  transaction TMain
  var
    nResult: number;
  begin
    WebVerifyContent("Begin");
    WebPageUrl("http://mycompany.com/");
    WebVerifyContent("Begin");
    WebVerifyContent("Shop", 2, 0, WEB_VER_FLAG_CONTENT_EQUAL);
    WebUrl("http://mycompany.com/Shop/default.htm");
    WebVerifyContent("Html", 3, "Right", WEB_VER_FLAG_CONTENT_SMALLER,
                     SEVERITY_ERROR, true, nResult);
    WebPageUrl("http://mycompany.com/frame/framea.html");
    Print(string(nResult));
  end TMain;