JavaSwing Example (english)

Aus ExpeccoWiki

Wechseln zu: Navigation, Suche

The JavaSwing-Plugin allows for Java programs and applications to be tested with expecco.

In the following example, different printer settings of OpenOffice Writer (text editor) are to be tested. Using expecco, the paper format is supposed to be set to both portrait to landscape format. Then, for each format, a sample is to be printed. This cycle shall be repeated an arbitrary number of times.

To create this test, first launch the target application (OpenOffice Writer*):.

Open OfficeWriter en.png


start the JavaBridge executable and create a new empty testsuite in expecco. The JavaBridge provides access to all JavaSwing components on the host on which it executes; in this example, we start the bridge on the localhost, but in theory, this could be any host in your network. Actually, you could even start multiple bridges on multiple hosts, in case you have to create a test scenario spanning multiple applications on different hosts simultaneously.

Then, import the JavaSwing building blocks library, which contains functions to interact with the application:

JSwing-Lib-Import en.png


finally, launch the JavaSwing-Plugin JS-Start Plugin.png and set up a connection to JavaBridge ('localhost') in the pop-up window JavaBrowser. When connected, this jBrowser displays a tree of all components of all JavaSwing applications.

JBridge-connect en.png


Then, create a new compound block named "Printer test" and drag the elementary block "connect to localhost" from the JavaSwing library into it. Likewise, drag a "execute" elementary block and connect it to the first block ("connect to localhost"). Enter the designated JavaBridge by using (1) for the host and (2) for the bridgeID, in this case "localhost".

Expecco - connect and execute en.png


You will find the path to the pop-up window "Page..." in the JavaBrowser (on the left). All menu items are listed logically and partitioned, whereas the application's item structure (here: OpenOffice Writer) remains.

JBrowser - seite en.png


All actions allowed by an element can be polled via the "Actions" tab. The designated and - in this case only - feasible action is "click".

JBrowser - actions en.png


Via the dialog window "Verify Path" and by clicking "Copy Path" you can copy the Path to the according element in the cache and paste it to the "Path"-Pin of the elementary block in expecco (copy & paste).

JBrowser - verify en.png


After clicking "File >> Reload" an opened dialog window in "OpenOffice Writer" appears as a separate Tree in the JavaBrowser.

JBrowser - dialog en.png


This is followed by a check if portrait or landscape format is set up (1). The new format is set up against the output data (2).

Expecco - Formatabfrage en.png


That followed, there is a simple printing loop with a separated Delay block (in order to await printing). You can find the printing command under "Panel >> Direct print" in the Java browser. This command is also executed by means of a simple execute block.

Expecco - Drucken en.png


Finally, the entire test at a glance:

Expecco - Druckertest en.png


  1. Set up a connection to JavaBridge.
  2. The dialog window "Page..." in OpenOffice Writer opens.
  3. The alignment value "portrait format" is read out.
  4. If the value is "1", the format is changed to landscape format, and vice versa (value: "0" --> portrait format).
  5. The printing command is executed in the toolbar, idle time is 30 seconds (until printing is completed).
  6. After this, the test is being repeated.


______________

* Please check if the related application is configured correctly. The Java feature "accessibility support" must be enabled.

Meine Werkzeuge