BrowserFindAll Function

Action

Finds all DOM elements for a given locator.

Include file

BrowserAPI.bdh

Syntax

BrowserFindAll( in nHandle          : number,
                in sLocatorToSearch : string,
                out lHandles        : list,
                in nTimeout         : union optional ): boolean;
Parameter Description
nHandle The handle where the search should be started. Use HANDLE_DESKTOP to search the complete DOM hierarchy.
sLocatorToSearch An XPath expression that describes the DOM elements.
lHandles A list of handles in which the matching DOM elements will be returned.
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. Use the data type number for this parameter. The data type float is not allowed.

Return value

  • true if one or more DOM elements were found for the given locator
  • 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
    lList: list of number;
    nHandle: number;
    sText  : string;
  begin
    BrowserStart(BROWSER_MODE_DEFAULT, 800, 600);
    BrowserNavigate("http://demo.borland.com");
    
    // Find all list item (LI) tags on this page.
    BrowserFindAll(HANDLE_DESKTOP, "//LI", lList);
    // Print the result list of matching DOM elements.
    ListPrint(lList);
    // Get text of first item in result list and print it.
    ListGetAt(lList, 1, nHandle);
    BrowserGetText(nHandle, sText);
    print(sText);
  end TMain;