The abstract class org.fest.swing.fixture.ContainerFixture provides shortcuts to look up GUI components inside the Container being tested. There are three overloaded versions of each shortcut method, each for each component lookup type (by name, type or GenericTypeMatcher.)
The following example uses a FrameFixture, a concrete implementation of ContainerFixture, to look up a "login" JButton by name, type and custom search criteria:
- by name:
- by type:
- custom search criteria (using a
GenericTypeMatcher):
Scope of component lookups
By default, only components that are showing on the screen can participate in component lookups (except for JMenuItem, which are not showing until they are selected.) To change the scope of component lookups, simply call the method componentLookupScope(ComponentLookupScope) in org.fest.swing.core.Settings. All instances of org.fest.swing.core.Robot contain their own Settings, which is returned by the method settings(). For more information about component lookup scope, please read ComponentLookupScope's Javadoc documentation.
Example:
This setting affects component lookup by name and type only. Creators of implementations of GenericTypeMatcher need to specify if lookup includes non-showing components or not.