Steer Java SWT Controls

Java SWT 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".

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

The chapter below describes how to steer Java SWT 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.

Editable ComboBox

Editable ComboBoxes are ComboBoxes that allow any number of entries to be added.

In the example below, the value test value is entered into the editable ComboBox BorderCCombo.

Test application - Editable ComboBox

Editable ComboBox - Entering a test value

ExpandBar

ExpandBars are steered as described in chapter "TabControl".

When a control ise steered in a scrollable ExpandBar that is not visible, the control is scrolled into view and then steered.

In the example below, the system selects the controls RadioButton1 and Checkbox from inside the scrollable ExpandBar SWTExpandBar.

Selecting a control from a scrollable ExpandBar

ListView

ListViews are steered as described in chapter "Listbox".

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

Selecting a ListView item

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

Verifying the ListView item

TabControl

TabControls are identified as TabFolders and CTabFolders, and they are steered as described in chapter "TabControl".

User simulations only work on tabs that are shown on the screen.

In this example, the engine selects Tab2 from the tfolTabFolder TabFolder.

Single-line TabFolder - Input

CTabFolders can be closed by using the steering parameter UserSimulation on the according Tab Item. The user simulation is carried out with the ActionMode Input and the value {CLOSE}.

In this example, the engine closes Tab3 from the CTabFolder TabControl.

Multiline CTabFolder- Input

PopUp Menu

You can steer PopUp Menus or context menus with the Module Any SWT Window, which is part of the Standard subset.

To steer PopUp Menus with the Any SWT Window Module, you need to open a single Java SWT window that has a context menu.

This example selects the entry Exit which is located in the PopUp Menu Context Menu under the entry File.

To do so, you first have to perform a right-click by using the click operation {RIGHTCLICK} on the main tab of the Java SWT application. This opens the PopUp Menu.

Then select the entry Exit from the PopUp Menu.

Selecting an entry from a PopUp Menu

Steer PopUp Menus in multiple JavaSWT windows

You can steer PopUp Menus when multiple windows are opened by uniquely identifying the required window with a TechnicalID.

Follow the steps below to create a Module with a TechnicalID that uniquely identifies the window to be steered:

  1. In Tosca, load the Any SWT Window Module from the Standard subset.

  2. Right-click on the Any SWT Window Module and select Copy from the context menu. You can also left-click on the Module and select Copy from the dynamic menu Modules. Alternatively, you can use the keyboard shortcut Ctrl + C.

  3. Select the target folder into which the Module should be pasted.

  4. Right-click on the folder and select Paste from the context menu. You can also left-click on the folder and select Paste from the dynamic menu Modules. Alternatively, you can use the keyboard shortcut Ctrl + V.

  5. Right-click on the copy of the Any SWT Window Module and select Rescan from the context menu.

  6. Scan the Java SWT application window that you want to use for steering by using Tosca XScan. For further details on how to proceed, see also chapter "Scan Modules".

    Tosca automatically updates the TechnicalID of the Module upon rescanning.

ProgressBar

ProgressBars are scanned with Tosca XScan.

The following ActionModes can be used with ProgressBars:

ActionMode

Description

Verify

This verifies the status of the progress.

WaitOn

The system waits until a specific value has been reached.

This example verifies whether the status of the progress bar shows 10:

Verifying the progress status

In the example below, the engine waits until the value of the progressBar shows 100 before it continues with the test execution:

Engine waits until the progress bar shows 100%

PushButton

PushButtons are steered as described in chapter "Button".

Scale

Scales are steered as described in chapter "Slider".

Spinner

Spinners are steered as described in chapter "TextBox".

The example below verifies whether the value of the Spinner SWTSpinner is set to 55.

Verifying the value of a Spinner

Spinners that are read-only can only be steered with the ActionMode Input when the steering parameter UserSimulation is set to false and the SendKeys or Keypress command is used in combination with further keyboard commands to select the buttons of the control (see chapter "Keyboard commands").

In this example, the value of the read-only Spinner ReadOnlySpinner below is increased by one.

Read-only Spinner in a Java SWT application

First, the Spinner is selected with the click operation {CLICK}. Then, the value is increased with the keyboard command {SENDKEYS["{UP}"]}, which selects the up arrow of the control.

Setting the value of a read-only Spinner

Spinners have a numeric minimum and maximum value that starts at 0. You can add the minimum and maximum values to the properties of the Spinner while scanning with Tosca XScan. In the XScan window under the Representation properties, select the respective properties Min and Max. Upon saving the Module, these properties are shown as TechnicalID Params in the Properties tab of the Spinner control.

If you want to steer a Spinner with a value that lies outside of the minimum and maximum range, Tosca resets the value to one that lies within the valid range.

This example shows a Spinner with a minimum value Minimum of 0 and a maximum value Maximum of 100.

Maximum and Minimum TechnicalID Params of a Java SWT Spinner

StyledTextEditBox

StyledTextEditBoxes can be single-line, multiline or read-only and they are steered as described in chapter "TextBox".

For read-only StyledTextEditBoxes, only the following ActionModes can be used:

ActionMode

Value

Description

Input

{CLICK}

Clicks on the read-only StyledTextEditBox.

Verify

<value>

Verifies the content of the StyledTextEditBox.

The example below verifies whether the value of the StyledTextEditBox ReadOnly StyledTextEditBox is This is a read-only text field.

Verifying the content of a read-only StyledTextEditBox

ToolBar

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.

You can steer Buttons and Buttons with a dropdown menu in ToolBars as embedded controls by entering their name into the ToolBar control. All other controls are steered as individual controls.

In the example below, the engine selects the button ToolbarButton from the ToolBar SWTToolBar.

Selecting a Button from the ToolBar

This example enters the text Example 2 into the TextBox ToolBarTextBox from the ToolBar SWTToolBar.

Entering text into a TextBox in a ToolBar

TreeView

TreeViews are steered as described in chapter "TableTree".

Closing the Java security message

Upon starting a Java application, Java Runtime Environment can open a security message depending on your security settings. You can close this message in Tosca as described in chapter "Close the Java security message".