TestComplete provides you with access to individual objects of JavaFX applications and to their internal methods. The following sections describe how you can access these native methods from your tests:
About Accessing Native Methods
TestComplete identifies individual GUI objects in JavaFX applications and provides special methods and properties for automating various operations over these objects, getting object data, checking an object's state and so on. However, if these predefined properties and methods are insufficient for your testing needs, you can use native methods of JavaFX objects to complete the desired tasks. These are the same methods that are available for use in the tested application’s source code, as well as custom methods implemented by the application developers. This way, you can perform almost any operation in the tested JavaFX application, even those that cannot be performed via the application’s GUI.
The Object Browser marks objects of JavaFX applications with the glyph. To view native members available for a JavaFX object, use the Object Spy or Object Browser in the Advanced view mode. Note that TestComplete gives access to private, protected and public methods of JavaFX applications’ objects. In the Object Browser, native methods of JavaFX objects are displayed under the Java category (see Important Notes for details):
For more information on how to refer to objects in JavaFX applications, see Addressing Objects in JavaFX Applications.
Calling Native Object Methods
When testing a JavaFX application, you can call its object methods from your tests.
To call an object’s method from script code, you use the dot operator "
." (in VBScript, JScript, Python and DelphiScript projects) or the square bracket notation
[" "] (in C++Script and C#Script projects) to specify the method name after the object name.
For example, in script code you can call the native
requestFocus method of a JavaFX button as follows:
If a native method has the same name as the test object method provided by TestComplete, the native method can be accessed via the
NativeJavaFXObjectproperty. For example, you can access the native
validatemethod of a JavaFX application’s form as follows:
If the object contains overloaded methods (methods with the same name but different parameters and they return value types), TestComplete appends indexes to method names in order to distinguish them. For example,
GetMousePosition_2(). To determine which index-suffixed method name corresponds to which overloaded method, examine the method’s parameter list in the Object Spy, Object Browser or Code Completion.
The leading underscore ( _ ) in method names is replaced with the character z. For example, a method named
__reset()is accessed as
z_reset(), and so on.