BrowserWaitForNewWindow Function

Action

Waits until a new browser window (tab) is created and returns the handle of this window (tab). The timeout value for retrieving a handle is defined in the Profile settings in the Object resolve timeout field. To define a custom timeout value, use the nTimeout parameter.

Include file

BrowserAPI.bdh

Syntax

BrowserWaitForNewWindow( in sWindowName : string optional,
                         in nTimeout    : union 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.

nTimeout Optional: The wait timeout in milliseconds. If not specified, the default timeout specified in the profile settings or set by BrowserSetOption(BROWSER_OPT_WAIT_TIMEOUT) will be used. When the timeout is reached, an error is thrown. Use the data type number for this parameter. The data type float is not allowed.

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;