BrowserReset Function

Action

Resets the browser state (cookies, cache and history).

注: BrowserStart also resets the browser state.

Include file

BrowserAPI.bdh

Syntax

BrowserReset( nMode : in number optional ): boolean;
Parameter Description
nMode Optional: Configures virtual user behaviour and browser visibility. The following constants may be used:
  • BROWSER_MODE_DEFAULT: Uses the profile settings.
  • BROWSER_MODE_DISPLAY_VISIBLE: Shows the browser window of each virtual user.
  • BROWSER_MODE_DISPLAY_INVISIBLE (default): Runs the browsers of the virtual users in hidden mode (does not apply for Try Script runs).
  • BROWSER_MODE_USERBEHAVIOR_DISABLE: Disables resetting the browser at end of transaction.
  • BROWSER_MODE_USERBEHAVIOR_FIRST_TIME: Clears virtual user browser state. Overrides the profile settings.
  • BROWSER_MODE_USERBEHAVIOR_REVISITING: Resets the non-persistent session, but does not delete the persistent cookies, cache, and history. Overrides the profile settings.

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
    sHost : string;
    nPort : number; 
  begin 
    BrowserStart(BROWSER_MODE_USERBEHAVIOR_REVISITING, 800, 600);
    
    // get the standard host name & port and print them
    BrowserGetStandardHost(sHost, STRING_COMPLETE, nPort); 
    print("Standardhost: '"+sHost+"'");
    print("Port: '"+string(nPort)+"'");
    // set the standard host name to demo.borland.com and port to 80
    BrowserSetStandardHost("demo.borland.com",80);
    // navigate to demo.borland.com on port 80
    BrowserNavigate("http://standardhost");
    // set the standard host name to www.google.com and port to 80
    BrowserSetStandardHost("www.google.com");
    // reset the browser state
    BrowserReset(BROWSER_MODE_USERBEHAVIOR_FIRST_TIME);
    // navigate to www.google.com
    BrowserNavigate("http://standardhost");
    
    // revert to previous state
    BrowserSetStandardHost(sHost, nPort);
  end TMain;