Viewing the Full Object Hierarchy
The Java Add-in enables you to view the full object hierarchy of each of the objects in your application in the Object Spy and Object Selection dialog boxes. In contrast to the recorded object hierarchy, the full object hierarchy shows you all of the parent objects associated with the clicked locations and, in some cases, the child objects of the clicked object.
The full object hierarchy enables you to view associated operations and properties of non-recorded objects in the Object Spy. When working with tests, you can also access non-recorded objects from the Object Selection dialog box that opens when using the Step Generator (tests only) or when inserting a checkpoint or output value step during a recording session.
The Object Spy and Object Selection dialog boxes enable you to view details, insert statements, or perform operations even for elements of an object (class components) that are not recorded, such as java.awt.Component. For example, you can access the edit box, drop-down list, and button elements of a combo box.
Creating Objects in Your Applet or Application (Advanced)
You can use the CreateObject method to create an instance of any Java object within your applet or application. The CreateObject method returns an object reference to the newly created Java object. For information on the syntax of this method, see the Java section of the HP QuickTest Professional Object Model Reference.
You can activate the methods of an object you create in the same way as you would activate the methods of any returned object from a prior call. Because the CreateObject method returns an object reference, there is no need to use the Object property when activating methods of the created object.
For example, you can use the CreateObject method to create a rectangle object. The return value is an object reference.
Set Rect = Browser("Periodic").Page("Periodic").JavaApplet("Periodic").JavaObject("Panel").CreateObject ("java.awt.Rectangle", 10, 20)
Note: The CreateObject method can be performed on any Java test object. The class loader of the Java test object on which the CreateObject method is performed is used to load the class of the newly created Java object.
It is recommended to use the CreateObject method on a Java test object from the same toolkit as the object you want to create. For example, to create a Swing/JFC object, use the CreateObject method on an existing Swing/JFC Java test object.
Working with Static Members
You can invoke any static method, or you can set or retrieve the value of any static property of a Java class using the GetStatics method. For information on the syntax of this method, see the Java section of the HP QuickTest Professional Object Model Reference.
GetStatics returns a reference to an object that can access static members of the specified class. The class loader of the Java test object on which the GetStatics method is performed is used to load the class specified as a parameter of the GetStatics method.
For example, to invoke the gc method of class.java.lang.System, which runs the garbage collector on the application, you can insert a statement similar to the following:
Browser("Browser").Page("Page").JavaApplet("mybuttonapplet.htm"). JavaObject("MyButton").GetStatics("java.lang.System").gc
To retrieve the value of the out property of the java.lang.System class, you can insert a statement similar to the following:
Set OutStream= Browser("Browser").Page("Page").JavaApplet("mybuttonapplet.htm"). JavaObject("MyButton").GetStatics("java.lang.System").out
To print a message to the Java console, you can insert a statement similar to the following:
Set OutStream= Browser("Browser").Page("Page").JavaApplet("mybuttonapplet.htm"). JavaObject("MyButton").GetStatics("java.lang.System").out
OutStream.println "Hello, World!"
Post a Comment