BrowserSetOption Function

Action

Sets a BrowserEngine option.

Include file

BrowserAPI.bdh

Syntax

BrowserSetOption( sOption : in string,
                  vValue  : in union ): boolean;
Parameter Description
sOption The BrowserEngine option. Can be one of the following values:
  • BROWSER_OPT_WAIT_TIMEOUT: Defines a timeout in milliseconds. Silk Performer waits to resolve an element until it is found or the timeout is reached. The default timeout is 5000 ms.
  • BROWSER_OPT_SYNC_TIMEOUT: Defines a timeout in milliseconds after which the synchronization aborts. Synchronization normally waits until the browser is in an idle state. If this state is not achieved, synchronization aborts after the defined timeout. The default timeout is 300000 ms.
  • BROWSER_OPT_SYNC_MODE: Defines the synchronization mode:
    • SYNC_MODE_AJAX: The AJAX mode synchronization waits for the browser to be in a kind of idle state, which is especially useful for AJAX applications or pages that contain AJAX components. Using the AJAX mode eliminates the need to manually script synchronization functions, which eases the script creation process dramatically. This automatic synchronization is also the basis for a successful record and replay approach.
    • SYNC_MODE_HTML: Using the HTML mode ensures that all HTML documents are in an interactive state. With this mode, you can test simple Web pages.
  • BROWSER_OPT_FILEDOWNLOAD_SAVEFILE: Defines if downloaded files, triggered by BrowserDlgDownload, should be saved from the Internet Explorer cache to the results directory:
    • FILEDOWNLOAD_SAVEFILE_SAVENONE: Files are not copied from the cache to the results directory.
    • FILEDOWNLOAD_SAVEFILE_SAVELAST: Files are copied from the cache to the results directory. If a version of the file already exists it gets replaced, so only the last downloaded file is saved in the results directory.
    • FILEDOWNLOAD_SAVEFILE_SAVEALL: All downloaded files are copied from the cache to the results directory. A timestamp is added to the filename so that all filenames are unique.
    If the BROWSER_OPT_FILEDOWNLOAD_SAVEFILE option is not specified, all downloaded files are copied from the browser cache to the results directory for Try Script runs, and for load test runs and find baseline runs no files are copied to the results directory. It is recommended not to copy any files to the results directory for load test runs, as this could result in huge amounts of data being saved on the local disk, and this data will also need to be copied from the agent machines to the controller.
  • BROWSER_OPT_FILEDOWNLOAD_BEGIN_TIMEOUT: Defines a timeout in milliseconds. The BrowserDlgStop call waits for a download to begin until this timeout is reached before returning an error. If this value is not specified, the default value of 20 seconds is applied.
  • BROWSER_OPT_LEGACY_INPUT_MODE: Set this parameter to true to turn off the automatic native replay. This state is also referred to as the legacy input mode. The legacy input mode is turned on by default for all project profiles created using Silk Performer 9.0 or earlier.
vValue The new value for the selected option. See sOption description for details.

Return value

  • true if successful

  • false otherwise

Example

benchmark SilkPerformerRecorder

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

dcluser
  user
    VUser
  transactions
    TInit           : begin;
    TMain           : 1;

var

dclrand

dcltrans
  transaction TInit
  begin
  end TInit;

  transaction TMain
  var
    nWaitTimeout : number;
  begin
    BrowserStart(BROWSER_MODE_DEFAULT, 800, 600);
    
    // get the wait timeout and print it
    BrowserGetOption(BROWSER_OPT_WAIT_TIMEOUT, nWaitTimeout);
    print(string(nWaitTimeout));
    // set the wait timeout to a new value
    BrowserSetOption(BROWSER_OPT_WAIT_TIMEOUT, 6000);
    // revert it back to the old setting
    BrowserSetOption(BROWSER_OPT_WAIT_TIMEOUT, nWaitTimeout);
  end TMain;