BrowserVerifyText Function

Action

Verifies that a DOM element has a specified caption. The logic of this function works as follows:

  1. Locates the object referred to in the locator string. If the object cannot be found, processing ends and an error with SEVERITY_ERROR is raised, regardless of the defined severity.
  2. Gets the value of the property textContents.
  3. Verifies that the value of property textContents has the specified value.
  4. If the verification fails, an error with the defined severity is raised.
Note: Do not call BrowserVerifyText() with a locator that contains the property textContents.

Include file

BrowserAPI.bdh

Syntax

BrowserVerifyText( uTestObject : in union,
                   sText       : in string,
                   nOptions    : in number optional,
                   nSeverity   : in number optional := SEVERITY_ERROR );
Parameter Description
uTestObject The XPath locator or the handle to the DOM element.
sText The caption that the element is expected to have.
nOptions Optional: Flagmask to configure the verification. Can be one of the following values:
  • Default: VERIFY_EQUAL
  • VERIFY_NOT_EQUAL
  • VERIFY_STARTS_WITH
  • VERIFY_ENDS_WITH
  • VERIFY_CONTAINS
  • VERIFY_CASE_SENSITIVE (available additionally to the above options)
  • VERIFY_IGNORE_WHITESPACE (available additionally to the above options)
nSeverity Optional: Severity of the error that is raised if the verification fails. Can be one of the following values:
  • SEVERITY_SUCCESS: Success; no error (numerical value: 0)
  • SEVERITY_INFORMATIONAL: Informational; no error (numerical value: 1)
  • SEVERITY_WARNING: Warning; no error (numerical value: 2)
  • SEVERITY_ERROR: (Default) Error; simulation continues (numerical value: 3)
  • SEVERITY_TRANS_EXIT: Error; the active transaction is aborted (numerical value: 4)
  • SEVERITY_PROCESS_EXIT: Error; the simulation is aborted (numerical value: 5)

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
  begin
    BrowserStart(BROWSER_MODE_DEFAULT, 800, 600);
    BrowserNavigate("http://demo.borland.com/TestSite/gwt/Showcase.html#CwBasicText");
    // set the text to 'Hello World!'
    BrowserTypeKeys("//INPUT[@id='gwt-debug-cwBasicText-textbox']", "Hello World!");
    
    //verify if the textfield has the expected text - case sensitive and ignoring whitespaces.
    //If the verification fails, an error will be raised
    BrowserVerifyText("//INPUT[@id='gwt-debug-cwBasicText-textbox']", "Hello World!",  
      VERIFY_CASE_SENSITIVE | VERIFY_IGNORE_WHITESPACE, SEVERITY_ERROR);
  end TMain;