BrowserGetActiveWindow Function

Action

Returns the handle of the active browser window (tab).

Include file

BrowserAPI.bdh

Syntax

BrowserGetActiveWindow( sWindowName : string optional ): number;
Parameter Description
sWindowName Optional: This window name is used in TrueLogs and the Browser Application.

Whenever the window handle returned by BrowserWaitForNewWindow is passed to another window function, such as BrowserActivateWindow or BrowserCloseWindow, this window name is used for textual identification of the window.

Return value

  • The value of the window handle.

Example

benchmark SilkPerformerRecorder

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

dcluser
  user
    VUser
  transactions
    TMain           : 1;

dcltrans

  transaction TMain
  var
    mainWindow : number;
    newWindow  : number;
    check      : number;
   begin     
    BrowserStart(BROWSER_MODE_DEFAULT, 800, 600);    
    BrowserNavigate("http://demo.borland.com/TestSite/multiplewindows/multipleWindows.html");
    
    mainWindow := BrowserGetActiveWindow("main window");
    BrowserLinkSelect("//A[@name='window1']",  "Select, BODY (#1)");
    
    newWindow := BrowserWaitForNewWindow("new window");
    
    BrowserActivateWindow(mainWindow);
    check := BrowserGetActiveWindow();
    
    if (check <> mainWindow) then
      RepMessage("Window handles are different", SEVERITY_ERROR); 
    end;
  end TMain;