TestObjects are the script-side interfaces for proxies and application under test (AUT) controls. A TestObject is a connection point between the test script and a ProxyObject that connects to the real object in the AUT. During recording, statements are recorded and objects are added to the Object Map. The script uses the information from the Object Map to construct and find TestObjects.
For example, if you record Button().click(), the Button() method finds an object that is based on the mapped properties and binds the TestObject to an object in the AUT. This binding is required to query information from the actual object, such as asking the button directly where it is currently located on the screen. Then the click() method is executed and the TestObject is unregistered, which releases the connection to the actual object in the AUT. Using TestObjects from the map in this manner manages the lifetime of the object automatically.
TestObjects are exposed to the scripting side based on which proxy it is mapped to. You must specify the proxy and TestObject mapping so that when a control is exposed to the script, the control is exposed as the TestObject that is specified in the mapping. You can create the mapping between a proxy and TestObject by overriding getTestObjectClassName() method on any proxy. If you want to change the TestObject that is mapped to a proxy, override the getTestObejctClassName() API to return the canonical name specified in the customization file.
- Role of a TestObject
TestObjects are wrapper classes to proxies for TestScripts. A control is exposed as a Java or C# object to TestScripts through TestObjects. TestObjects are implemented in both Java and C#, because Functional Tester supports using both Java and Visual Basic .Net as the test-script language. If you use Visual Basic .Net scripts, TestObjects that are implemented in C# are used. For Java scripts, TestObjects that are implemented using Java are used.
- Add a new TestObject
You can add a new TestObject when there are no TestObjects with the method that you want to expose for a control, available within the set of predefined TestObjects provided by Functional Tester. For example, you can expose any button control as GuiTestObejct() and operations such as click() and doubleClick() are defined as methods in it. You can create a new TestObject if you want to introduce a new method call such as myClick() which is not defined in any of the existing TestObjects.
- Mapping proxies to TestObjects
You can extend a proxy so that Functional Tester uses a different a TestObject to provide a suitable interface on the scripting side.