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. This topic provides 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 yourOrderHasBeenReceivedYourOr object.



import resources.QueryingObjectHelper;

import com.rational.test.ft.*;
import com.rational.test.ft.object.interfaces.*;
import com.rational.test.ft.object.interfaces.SAP.*;
import com.rational.test.ft.object.interfaces.siebel.*;
import com.rational.test.ft.script.*;
import com.rational.test.ft.value.*;
import com.rational.test.ft.vp.*;

/**
 * Description   : Functional Test Script
 * @author Administrator
 */
public class QueryingObject extends QueryingObjectHelper
{
	/**
	 * Script Name   : QueryingObject
	 * Generated     : Jul 19, 2006 2:31:56 PM
	 * Description   : Functional Test Script
	 * Original Host : WinNT Version 5.1  Build 2600 (S)
	 * 
	 * @since  2006/07/19
	 * @author Administrator
	 */
	public void testMain(Object[] args) 
	{
		startApp("ClassicsJavaA");
		
		// Frame: ClassicsCD
		placeOrder().click();
		
		// Frame: Member Logon
		ok().click();
		
		// Frame: Place an Order
		cardNumberIncludeTheSpacesText().click(atPoint(28,6));
		placeAnOrder().inputChars("1234123412341234");
		expirationDateText().click(atPoint(9,2));
		placeAnOrder().inputChars("12/12");
		placeOrder2().click();
		
		//Waiting for Object 
		yourOrderHasBeenReceivedYourOr().waitForExistence();
		
		//Querying the Object
		String confirmationText = (String)yourOrderHasBeenReceivedYourOr().getProperty("text");
		logTestResult(confirmationText, confirmationText.startsWith("Your order has"));
		
		yourOrderHasBeenReceivedYourOr().click();
		ok2().click();
		
		// Frame: ClassicsCD
		classicsJava(ANY,MAY_EXIT).close();
	}
}

Rational® 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.