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 may want to compare previous versions of a value to the current value and to do so would require a calculation (such as factoring in a depreciation rate).
Sometimes querying a property may return a reference to other objects. In cases like this, you might need to test the value of a property of the returned object. This kind of scenario cannot be handled through the user interface. See Unregistering References to Test Objects for more information.
You also might want to branch in your Functional Test script based on the current value of a 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.