WebVerifyHtmlTitle Function

Action

Parses the <TITLE> tag of the HTML response and compares its content with the provided string. If it does not match, an error is raised. The severity of this error can be specified. The verification result can be retrieved by an optional out-parameter. A subsequent low-level web function will not return a value until the request has finished. If a page consists of more than one HTML document, the sub frames that are checked for the title can be specified with the nDocNum parameter.

When verifying/parsing an HTML page that consists of multiple frames (HTML documents), you can specify which frame document to verify/parse by specifying the nDocNum parameter. By default (1) the top document (e.g. a frameset) is 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 verification feature can be enabled/disabled globally (Profile Settings / Web / Verification / HTML / Title verification).

Note: This function can be added automatically to your script using the visual verification functionality of TrueLog Explorer.

Include file

WebAPI.bdh

Syntax

WebVerifyHtmlTitle( in  sVerify   : string,
                    in  nOptions  : number optional,
                    in  nDocNum   : number optional,
                    in  nSeverity : number optional := SEVERITY_ERROR,
                    out bSuccess  : boolean optional );
Parameter Description
sVerify String to compare with the parsed title.
nOptions

(optional)

WEB_FLAG_CONTAINS
The actual parsed HTML title must contain the specified string. Otherwise the verification fails.
WEB_FLAG_CONTAINS_NOT
The actual parsed HTML title must not contain the specified string. Otherwise the verification fails.
WEB_FLAG_IS_DIFFERENT
The actual parsed HTML title must not be equal to the specified string. Otherwise the verification fails.
WEB_FLAG_EQUAL
The actual parsed HTML title must be equal to the specified string. Otherwise the verification fails. If none of the above 3 flags are specified, the WEB_FLAG_EQUAL flag is used.
WEB_FLAG_CASE_SENSITIVE
If this flag is set the string compare operation is case sensitive.
WEB_FLAG_IGNORE_WHITE_SPACE
If this flag is set all white spaces are ignored.
WEB_FLAG_RULE
Specify this flag to perform the verification on every subsequent web function. Verification functions with this flag are usually located in the TInit transaction. Call WebCancelAllRules() to disable all verification rules.
Note: The option WEB_FLAG_RULE should only be used in the INIT transaction or in combination with the WebCancelAllRules function!
nDocNum Specifies the document to check the title for (optional). The default (1) specifies the top document (e.g. a frameset).
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)
bSuccess If a variable is provided, it will receive the result of the verification (optional).

Example

dcltrans
  transaction TMain
  var
    bResult: boolean;
  begin
    WebVerifyHtmlTitle("Silk Performer Test Site");
    WebPageUrl("http://mycompany.com/");
    WebVerifyHtmlTitle("ShopIt - Greeting",
WEB_FLAG_CASE_SENSITIVE, 1, SEVERITY_WARNING, bResult);
    WebUrl("http://mycompany.com/Shop/default.htm");
    if not bResult then
      print("Verification failed");
    end
    WebVerifyHtmlTitle("FrameA", 0, 1); // base frameset
verification
    WebVerifyHtmlTitle("Buy It", 0, 3); // second frame
    WebPageUrl("http://mycompany.com/frame/framea.html");
  end TMain;