Most of the time, you will start with a Panel or a Window instance representing a given panel or the whole application. In order to test your system, you will first need to retrieve the UISpec4J components representing the displayed buttons, tables or trees that let you interact with the application and check its status.

To this end, the Panel class provides a set of getXxx() methods, for instance getButton(), getTree(), etc.:

public void MyFunctionalTestCase extends UISpecTestCase {
  public void test() {
    Window mainWindow = getMainWindow();
    mainWindow.getMenuBar().getMenu("File").getSubMenu("Open...").click();
    ...
    assertTrue(mainWindow.getTree().contentEquals(...));
    ...
    mainWindow.getButton("Apply").click();
  }

Each getXxx() method comes in three flavors:

For all three signatures, two exceptions will be thrown: ComponentNotFoundException if nothing was found, and ComponentAmbiguityException if several matches were found.

NB: It is possible to add getXxx() methods for other components than those shipped with UISpec4J. Please refer to the extension mechanism documentation for further details.