BrowserVerifyProperty Function

Action

This function verifies that a property of a DOM element has a specified value. 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 list of properties for the object.
  3. Verifies that property x has value y.
  4. If the verification fails, an error with the defined severity is raised.
注: Do not attempt to verify an attribute that is contained in the locator string.

Include file

BrowserAPI.bdh

Syntax

BrowserVerifyProperty( uTestObject       : in union,
                       sDomPropertyName  : in string,
                       vDomPropertyValue : in union,
                       nOptions          : in number optional,
                       nSeverity         : in number optional := SEVERITY_ERROR ): boolean;
Parameter Description
uTestObject The XPath locator or the handle to the DOM element.
sDomPropertyName The name of the property of the DOM element.
vDomPropertyValue The value of the property to be verified.
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)

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
    propertyValue : boolean;
  begin
    BrowserStart(BROWSER_MODE_DEFAULT, 800, 600);
    BrowserNavigate("http://demo.borland.com/TestSite/gwt/Showcase.html#CwCheckBox");
    // check Monday
    BrowserCheckBoxSelect("//SPAN[@hideFocus='0']/INPUT[@hideFocus='0']", CHECKBOX_CHECKED);
    // get the value of the checked property and print it
    BrowserGetProperty("//SPAN[@hideFocus='0']/INPUT[@hideFocus='0']", "checked", propertyValue);
    print(string(propertyValue));
    
    //verify that the property value is true
    BrowserVerifyProperty("//SPAN[@hideFocus='0']/INPUT[@hideFocus='0']", "checked", 
      true, VERIFY_EQUAL | VERIFY_CASE_SENSITIVE, SEVERITY_INFORMATIONAL);
  end TMain;