Querying Values of Object Properties

Components in the application-under-test, such as dialog boxes, command buttons, and labels, have associated pieces of information called properties. Properties have a name and a value. Here are some examples of why you may want to modify your script to access an object property:

You can retrieve the value of a property programmatically by calling the getProperty method, which has the following syntax:

Object getProperty(String propertyName);

The following example uses the getProperty method to test whether a value of a property is being captured and reproduced correctly. The call to getProperty retrieves the value of the text property associated with the ThankYouXLabel object.

  public class PropertyFetch extends PropertyFetchHelper
 {
    public void testMain (Object[] args)

    startApp("GetName");
-->   }

    checkSetName("Tony");
    checkSetName("Maria");

  // Window: Functional Tester GetName
    GetNameFrame().close();
 }

 public void checkSetName(String name)
 {

  // Window: Functional Tester GetName
  // User clicks on button for help
  helpgifButton().click();

  //Display input name
  InputWindow().inputKeys(name);
  OKButton().click();

  // Fetches value of text property
  String ThankyouX_text =

  (String)ThankyouXLabel().getProperty("text");

  // Compares text property with input name.
  // Pass or Fail logged based on the outcome.

  logTestResult("name test",

    ThankyouX_text.equals("Thank you "+name));

  OKButton2().click();

  }

 }

Functional Tester also supports a setProperty method, but do not use it unless you are sure of the result. This method calls internal methods that may violate the integrity of the application-under-test.

Terms of use | Feedback
(C) Copyright IBM Corporation 2002, 2004. All Rights Reserved.