BrowserDlgVerifyDownloadSize Function

Action

Adds a download command to the dialog command storage that checks the size of the downloaded file. The file to be downloaded must be declared beforehand with the BrowserDlgVerifyDownloadSize function. The function must be called before the download starts. Multiple verifications can be applied to a single download command to ensure that the resulting file size lies in between certain bounds. During recording, you can add a BrowserDlgVerifyDownloadSize function by checking the Verify size of download checkbox in the save file dialog.

注: This function only works with Internet Explorer.

Include file

BrowserAPI.bdh

Syntax

BrowserDlgVerifyDownloadSize( in uExpectedSize : number,
                              in nOptions      : number optional := VERIFY_SIZE_EQUAL,
                              in nSeverity     : number optional := SEVERITY_ERROR      ): boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
uExpectedSize The file size used for the verification
nOptions Describes how the actual size is compared to the expected size:
  • VERIFY_SIZE_EQUAL
  • VERIFY_SIZE_LARGER_THAN
  • VERIFY_SIZE_SMALLER_THAN

If this parameter is omitted, a check for equality is performed.

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)

Example

benchmark SilkPerformerRecorder

use "Kernel.bdh"
use "BrowserAPI.bdh"

dcluser
  user
    VUser
  transactions
    TMain           : 1;

dcltrans
  transaction TMain
  var
    wnd1 : number;
  begin
    BrowserStart(BROWSER_MODE_DEFAULT, 800, 600);
    BrowserNavigate("http://demo.borland.com/TestSite/common_main.asp#Download", 
      "Navigate_http://demo.borland.com/TestSite/common_main.asp#Download (#1)");
    wnd1 := BrowserGetActiveWindow("wnd1");
    BrowserSetOption(BROWSER_OPT_FILEDOWNLOAD_SAVEFILE, FILEDOWNLOAD_SAVEFILE_SAVELAST);
    BrowserDlgDownload("SmallFile.exe");
    BrowserDlgVerifyDownloadSize(200, VERIFY_SIZE_LARGER_THAN | VERIFY_SIZE_EQUAL); // actual file must contain 200 Bytes or more
    BrowserClick("//A[@textContents='Small File']", BUTTON_Left, "Click, A, textContents=Small File (#1)");
    BrowserDlgStop();
  end TMain;