public final class WindowFinder extends Object
Looks up Frame
s and Dialog
s. Lookups are performed till the window of interest is found, or until the
given time to perform the lookup is over. The default lookup time is 5 seconds.
WindowFinder
is the "entry point" of a fluent interface to look up frames and dialogs. This example
illustrates finding a Frame
by name, using the default lookup time (5 seconds):
FrameFixture frame = WindowFinder.findFrame("someFrame").using(robot);
Where robot
is an instance of Robot
.
This example shows how to find a Dialog
by type using a lookup time of 10 seconds:
DialogFixture dialog = WindowFinder.findDialog(MyDialog.class).withTimeout(10000).using(robot);
We can also specify the time unit:
DialogFixture dialog = WindowFinder.findDialog(MyDialog.class).withTimeout(10, SECONDS
).using(robot);
This example shows how to use a GenericTypeMatcher
to find a Frame
with title "Hello":
GenericTypeMatcher<JFrame> matcher = new GenericTypeMatcher<JFrame>() { protected boolean isMatching(JFrame frame) { return "hello".equals(frame.getTitle()); } }; FrameFixture frame = WindowFinder.findFrame(matcher).using(robot);
Modifier and Type | Method and Description |
---|---|
static DialogFinder |
findDialog(Class<? extends Dialog> dialogType)
Creates a new
DialogFinder capable of looking up a Dialog by type. |
static DialogFinder |
findDialog(GenericTypeMatcher<? extends Dialog> matcher)
Creates a new
DialogFinder capable of looking up a Dialog using the provided matcher. |
static DialogFinder |
findDialog(String dialogName)
Creates a new
DialogFinder capable of looking up a Dialog by name. |
static FrameFinder |
findFrame(Class<? extends Frame> frameType)
Creates a new
FrameFinder capable of looking up a Frame by type. |
static FrameFinder |
findFrame(GenericTypeMatcher<? extends Frame> matcher)
Creates a new
FrameFinder capable of looking up a Frame using the provided matcher. |
static FrameFinder |
findFrame(String frameName)
Creates a new
FrameFinder capable of looking up a Frame by name. |
@Nonnull public static FrameFinder findFrame(@Nullable String frameName)
FrameFinder
capable of looking up a Frame
by name.frameName
- the name of the frame to find.@Nonnull public static FrameFinder findFrame(@Nonnull Class<? extends Frame> frameType)
FrameFinder
capable of looking up a Frame
by type.frameType
- the type of the frame to find.@Nonnull public static FrameFinder findFrame(@Nonnull GenericTypeMatcher<? extends Frame> matcher)
FrameFinder
capable of looking up a Frame
using the provided matcher.matcher
- the matcher to use to find a frame.@Nonnull public static DialogFinder findDialog(@Nullable String dialogName)
DialogFinder
capable of looking up a Dialog
by name.dialogName
- the name of the dialog to find.@Nonnull public static DialogFinder findDialog(@Nonnull Class<? extends Dialog> dialogType)
DialogFinder
capable of looking up a Dialog
by type.dialogType
- the type of the dialog to find.@Nonnull public static DialogFinder findDialog(@Nonnull GenericTypeMatcher<? extends Dialog> matcher)
DialogFinder
capable of looking up a Dialog
using the provided matcher.matcher
- the matcher to use to find a dialog.Copyright © 2014–2019 AssertJ. All rights reserved.