public class JFileChooserFinder extends ComponentFinderTemplate<JFileChooser>
JFileChooser
s. Lookups are performed till a file chooser is found,
or until the given time to perform the lookup is over. The default lookup time is 5 seconds.
This example illustrates finding a
by name, using the default lookup time (5
seconds):
JFileChooser
JFileChooserFixture fileChooser = JFileChooserFinder.findFileChooser().using(robot);
Where robot
is an instance of
.
Robot
This example shows how to find a
by type using a lookup time of 10 seconds:
JFileChooser
JFileChooserFixture fileChooser = JFileChooserFinder.findFileChooser().withTimeout(10000).using(robot);We can also specify the time unit:
JFileChooserFixture fileChooser = JFileChooserFinder.findFileChooser().withTimeout(10, SECONDS
).using(robot);
This examples shows how to find a
using a JFileChooser
:
GenericTypeMatcher
GenericTypeMatcher<JFileChooser> matcher = new GenericTypeMatcher<JFileChooser>() { protected boolean isMatching(JFileChooser fileChooser) { return fileChooser.getCurrentDirectory().getAbsolutePath().equals("c:\\temp"); } }; JFileChooserFixture fileChooser = JFileChooserFinder.findFileChooser(matcher).using(robot);
Modifier | Constructor and Description |
---|---|
protected |
JFileChooserFinder()
Creates a new
JFileChooserFinder . |
protected |
JFileChooserFinder(GenericTypeMatcher<? extends JFileChooser> matcher)
Creates a new
JFileChooserFinder . |
protected |
JFileChooserFinder(String name)
Creates a new
JFileChooserFinder . |
Modifier and Type | Method and Description |
---|---|
protected JFileChooser |
cast(Component c)
Casts the given
Component to . |
static JFileChooserFinder |
findFileChooser()
Creates a new
capable of looking up a . |
static JFileChooserFinder |
findFileChooser(GenericTypeMatcher<? extends JFileChooser> matcher)
Creates a new
capable of looking up a
using the given matcher. |
static JFileChooserFinder |
findFileChooser(String name)
Creates a new
capable of looking up a by
name. |
JFileChooserFixture |
using(Robot robot)
Finds a
by name or type. |
JFileChooserFinder |
withTimeout(long timeout)
Sets the timeout for this finder.
|
JFileChooserFinder |
withTimeout(long timeout,
TimeUnit unit)
Sets the timeout for this finder.
|
findComponentWith
protected JFileChooserFinder()
JFileChooserFinder
. This finder looks up a JFileChooser
by
type.protected JFileChooserFinder(String name)
JFileChooserFinder
.name
- the name of the FileChooser
to look for.protected JFileChooserFinder(GenericTypeMatcher<? extends JFileChooser> matcher)
JFileChooserFinder
.matcher
- specifies the search criteria to use when looking up a JFileChooser
.public static JFileChooserFinder findFileChooser()
JFileChooserFinder
capable of looking up a JFileChooser
.public static JFileChooserFinder findFileChooser(String name)
JFileChooserFinder
capable of looking up a JFileChooser
by
name.name
- the name of the file chooser to find.public static JFileChooserFinder findFileChooser(GenericTypeMatcher<? extends JFileChooser> matcher)
JFileChooserFinder
capable of looking up a JFileChooser
using the given matcher.matcher
- the given matcher.public JFileChooserFixture using(Robot robot)
JFileChooser
by name or type.using
in class ComponentFinderTemplate<JFileChooser>
robot
- contains the underlying finding to delegate the search to.JFileChooserFixture
managing the found JFileChooser
.WaitTimedOutError
- if a JFileChooser
could not be found.public JFileChooserFinder withTimeout(long timeout)
JFileChooser
to find should be found within the given
time period.withTimeout
in class ComponentFinderTemplate<JFileChooser>
timeout
- the number of milliseconds before stopping the search.IllegalArgumentException
- if the timeout is a negative number.public JFileChooserFinder withTimeout(long timeout, TimeUnit unit)
JFileChooser
to find should be found within the given
time period.withTimeout
in class ComponentFinderTemplate<JFileChooser>
timeout
- the period of time the search should be performed.unit
- the time unit for timeout
.NullPointerException
- if the time unit is null
.IllegalArgumentException
- if the timeout is a negative number.protected JFileChooser cast(Component c)
Component
to JFileChooser
.cast
in class ComponentFinderTemplate<JFileChooser>
c
- the given Component
.Component
, casted to JFileChooser
.Copyright © 2007-2013 FEST (Fixtures for Easy Software Testing). All Rights Reserved.