Steer Java Swing Controls

Java Swing Modules are created by using either Tosca XScan or Tosca Recorder (see chapter "Create TestCases with the Recorder").

Right-click onto a Module folder, or use the dynamic menu Modules and select Scan->Application. For further details on how to proceed, see also chapter "Scan Modules".

Tosca XScan identifies JavaFX specific controls within Java Swing applications. You can steer them as described in chapter "Steer JavaFX Controls".

The following standard controls can be steered as described in chapter "Steering Controls":

* You cannot create structured list items.

The chapter below describes how to steer Java Swing specific controls.

Tosca allows controls to be steered which are located outside the visible area of your test application, provided that they are positioned within the scrollable area (ScrollPane). Upon test execution, the system automatically jumps to the according control.

ListView

ListViews are steered as described in chapter "Listbox".

In the example below, the entry Julia is selected from the ListView IvTestListView.

Selecting a ListView item

This example verifies whether the entry Matthew exists in the ListView IvTestListView:

Verifying the ListView item

Java Spinner

Spinners are represented by a spinner control and two buttons.

The Tosca Java Swing Engine 3.0 supports the following spinner types:

  • ListItem Spinner: allows you to select a text.

  • Number Spinner: allows you to select a number.

  • Date Spinner: allows you to select a date.

For further details on how to steer spinner control contents, refer to chapter "TextBox".

To switch the items within the spinner upwards or downwards, steer buttons as described in chapter "Button".

In the example below, the engine steers the ListItem spinner control listSpinnerString:

ListItem spinner in the application

This example uses the ActionMode Verify to verify whether the item Apple is selected:

Verifying a value

In the example below, the engine steers the ListItem spinner control listSpinnerString via the button Spinner.nextButton.

The example uses the value {Click} and the ActionMode Input to click on the upwards button in order to select the subsequent item.

Selecting the next item

The spinner control provides specific properties in addition to the general TBox properties, depending on the used spinner type.

NumberSpinner

NumberSpinners allow you to select numbers from a pre-defined range.

The following properties can be additionally verified for NumberSpinners:

Property

Description

Maximum

Maximum value that can be selected in the spinner

Minimum

Minimum value that can be selected in the spinner

StepSize

The number interval used in the spinner

The maximum value allowed for the NumberSpinner numberSpinner is written to the buffer Max.

The value of the property Maximum is assigned to the buffer Max along with the ActionMode Buffer.

Buffering a property

DateSpinner

The following properties can additionally be verified for DateSpinners:

Property

Description

Start

The earliest possible date that is available

End

The latest possible date that is available

CalendarField

The time interval to increase or reduce the date value

The value of the DateSpinner dateSpinner is modified by entering a new value.

The TestStepValue dateSpinner receives the value 03.03.85 00:00 and the ActionMode Input.

Entering a value

ProgressBar

ProgressBars are steered as described in chapter "Progress Bar/Indicator".

PushButton

PushButtons are steered as described in chapter "Button".

ToggleButton

ToggleButtons are steered as described in chapter "Button".

Use the property Selected to verify the status of a ToggleButton.

In this example, the engine verifies whether the ToggleButton SingleToggleButton is selected in the test application:

Verifying the Selected status of a ToggleButton

ToolBar

Java Swing ToolBars can be scanned with Tosca XScan and they are identified as Menu. Controls in ToolBars are identified via the according control type and they can be scanned and steered either as embedded or individual controls.

Control steering is performed by entering either the name of a ToolBar button or the name of the embedded control.

In the example shown below, the engine selects the button of the value ToolBarButton1 from the ToolBar buttonToolBar:

Selecting a control from the ToolBar

This example verifies whether the entry Item3 is selected in the ComboBox toolBarComboBox of the ToolBar buttonToolBar:

Verifying a control in the ToolBar

Close the Java security message

Depending on the security settings of your machine, Java Runtime Environment opens the security message below upon the initial start of a Java application or every time the application is started. The Java security message can also appear after updating Java Runtime Environment.

Java security message

You can steer the Java security message with the Module Java Security Information, which is part of the Standard subset.

To ensure that the Java Engine 3.0 executes your TestCase accurately and regardless of whether the Java security message appears, you have to use the Module in one of the following places:

In this example, you close the Java security message and start the Java application.

Steer the Java security message