Skip to end of metadata
Go to start of metadata

All FEST Fixtures can simulate user input using a mouse. This simulation is not limited to send events to implementations of MouseListener. FEST provides true mouse input, at the operating system level. For example, simulating a user moving the mouse will result in the mouse pointer moving to a specified location.

Simple Click

The method click() can simulate a user clicking a GUI component once, using the left mouse button. The following code listing shows how to simulate a user clicking the button with name "connect":

The following are alternative (and more verbose) ways to click a component once, using the left mouse button:

Right-Click

The method rightClick() can simulate a user clicking a GUI component once, using the right mouse button. The following code listing shows how to simulate a user right-clicking the text field with name "username":

The following are alternative (and more verbose) ways to click a component once, using the right mouse button:

Double-Click

The method doubleClick() can simulate a user double-clicking a GUI component, using the left mouse button. The following code listing shows how to simulate a user double-clicking the label with name "configure":

The following is an alternative (and more verbose) way to double-click a component, using the left mouse button:

Click Using Specific Button, Once

The method click(MouseButton) can simulate a user clicking a GUI component, using the specified mouse button. The following code listing shows how to simulate a user clicking the check box with name "include" using the middle mouse button:

Click Using Specific Button, Many Times

The method click(MouseClickInfo) can simulate a user clicking a GUI component, using the specified mouse button, many times. The following code listing shows how to simulate a user clicking three times the radio button with name "monthly" using the left mouse button:

2 Comments

  1. Am new to GUI-based testing, but am impressed with FEST.  As a suggestion, it would have been easier to work through the "Getting Started" example if the code for "MyFrame" had been listed in full and the connection between the components and their testing made clear.  Also, there is a typo in "Simulating Mouse Input" where "import static org.fest.swing.fixture.MouseClickInfo.leftButton;"
    should be "import static org.fest.swing.core.MouseClickInfo.leftButton;"  Again, this looks to be quite a useful toolkit.  Thank you!

  2. Hi Mark!

    Thanks a lot for the kind comments about FEST, and for taking the time to provide feedback. I truly appreciate it! (smile)

    I fixed the typo. I'll be adding the missing code listings this week (I've been a little busy lately.)

    Cheers,
    -Alex