| Modifier and Type | Method and Description |
|---|---|
void |
cleanUp()
Cleans up any used resources (keyboard, mouse, open windows and
ScreenLock) used by this Robot. |
void |
cleanUpWithoutDisposingWindows()
Cleans up any used resources (keyboard, mouse and
ScreenLock) used by this Robot. |
void |
click(Component c)
Simulates a user clicking once the given AWT or Swing
Component using the left mouse button. |
void |
click(Component c,
MouseButton button)
Simulates a user clicking once the given AWT or Swing
Component using the given mouse button. |
void |
click(Component c,
MouseButton button,
int times)
Simulates a user clicking the given mouse button, the given times on the given AWT or Swing
Component. |
void |
click(Component c,
Point where)
Simulates a user clicking at the given position on the given AWT or Swing
Component. |
void |
click(Component c,
Point where,
MouseButton button,
int times)
Simulates a user clicking the given mouse button, the given times at the given position on the given AWT or Swing
Component. |
void |
click(Point where,
MouseButton button,
int times)
Simulates a user clicking the given mouse button, the given times at the given absolute coordinates.
|
void |
close(Window w)
Simulates a user closing the given AWT or Swing
Window. |
void |
doubleClick(Component c)
Simulates a user double-clicking the given AWT or Swing
Component. |
void |
enterText(String text)
Simulates a user entering the given text.
|
JPopupMenu |
findActivePopupMenu() |
ComponentFinder |
finder() |
void |
focus(Component c)
Gives input focus to the given AWT or Swing
Component. |
void |
focusAndWaitForFocusGain(Component c)
Gives input focus to the given AWT or Swing
Component and waits until the Component has focus. |
ComponentHierarchy |
hierarchy() |
boolean |
isActive()
Indicates whether this
Robot is active. |
boolean |
isDragging()
Indicates whether the robot is currently in a dragging operation.
|
boolean |
isReadyForInput(Component c)
Indicates whether the given AWT or Swing
Component is ready for input. |
void |
jitter(Component c)
Makes the mouse pointer show small quick jumpy movements on the given AWT or Swing
Component. |
void |
jitter(Component c,
Point where)
Makes the mouse pointer show small quick jumpy movements on the given AWT or Swing
Component at the given
point. |
void |
moveMouse(Component c)
Simulates a user moving the mouse pointer to the center of the given AWT or Swing
Component. |
void |
moveMouse(Component c,
int x,
int y)
Simulates a user moving the mouse pointer to the given coordinates relative to the given AWT or Swing
Component. |
void |
moveMouse(Component c,
Point p)
Simulates a user moving the mouse pointer to the given coordinates relative to the given AWT or Swing
Component. |
void |
moveMouse(int x,
int y)
Simulates a user moving the mouse pointer to the given coordinates.
|
void |
moveMouse(Point p)
Simulates a user moving the mouse pointer to the given coordinates.
|
void |
pressAndReleaseKey(int keyCode,
int... modifiers)
Type the given key code with the given modifiers.
|
void |
pressAndReleaseKeys(int... keyCodes)
Simulates a user pressing and releasing the given keys.
|
void |
pressKey(int keyCode)
Simulates a user pressing given key.
|
void |
pressModifiers(int modifierMask)
Presses the appropriate modifiers corresponding to the given mask.
|
void |
pressMouse(Component c,
Point where)
Simulates a user pressing the left mouse button on the given AWT or Swing
Component. |
void |
pressMouse(Component c,
Point where,
MouseButton button)
Simulates a user pressing the given mouse button on the given AWT or Swing
Component. |
void |
pressMouse(MouseButton button)
Simulates a user pressing a mouse button.
|
void |
pressMouse(Point where,
MouseButton button)
Simulates a user pressing the given mouse button on the given coordinates.
|
ComponentPrinter |
printer() |
void |
releaseKey(int keyCode)
Simulates a user releasing the given key.
|
void |
releaseModifiers(int modifierMask)
Releases the appropriate modifiers corresponding to the given mask.
|
void |
releaseMouse(MouseButton button)
Releases the given mouse button.
|
void |
releaseMouseButtons()
Releases any mouse button(s) used by the robot.
|
void |
requireNoJOptionPaneIsShowing()
Ensures that there is no
JOptionPane showing, and potentially blocking GUI tests. |
void |
rightClick(Component c)
Simulates a user right-clicking the given AWT or Swing
Component. |
static Robot |
robotWithCurrentAwtHierarchy()
Creates a new
Robot that has access to all the AWT and Swing Components in the AWT hierarchy. |
static Robot |
robotWithCurrentAwtHierarchyWithoutScreenLock() |
static Robot |
robotWithNewAwtHierarchy()
Creates a new
Robot with a new AWT hierarchy. |
static Robot |
robotWithNewAwtHierarchyWithoutScreenLock() |
void |
rotateMouseWheel(Component c,
int amount)
Moves the mouse pointer over to the given AWT or Swing
Component and rotates the scroll wheel on
wheel-equipped mice. |
void |
rotateMouseWheel(int amount)
Rotates the scroll wheel on wheel-equipped mice.
|
Settings |
settings() |
JPopupMenu |
showPopupMenu(Component invoker)
Shows a
JPopupMenu. |
JPopupMenu |
showPopupMenu(Component invoker,
Point location)
Shows a
JPopupMenu at the given coordinates. |
void |
showWindow(Window w)
Safely display an AWT or Swing
Window with proper EDT synchronization. |
void |
showWindow(Window w,
Dimension size)
Safely display an AWT or Swing
Window with proper EDT synchronization. |
void |
showWindow(Window w,
Dimension size,
boolean pack)
Safely display an AWT or Swing
Window with proper EDT synchronization. |
void |
type(char character)
Types the given character.
|
void |
waitForIdle()
Wait for an idle AWT event queue.
|
@Nonnull public static Robot robotWithNewAwtHierarchy()
Robot with a new AWT hierarchy. The created Robot will not be able to access any AWT
and Swing Components that were created before it.Robot.@Nonnull public static Robot robotWithNewAwtHierarchyWithoutScreenLock()
@Nonnull public static Robot robotWithCurrentAwtHierarchy()
Robot that has access to all the AWT and Swing Components in the AWT hierarchy.Robot.@Nonnull public static Robot robotWithCurrentAwtHierarchyWithoutScreenLock()
@Nonnull public ComponentPrinter printer()
@Nonnull public ComponentFinder finder()
@RunsInEDT public void showWindow(@Nonnull Window w)
RobotWindow with proper EDT synchronization. This method blocks until the
Window is showing and ready for input.showWindow in interface Robotw - the window to display.@RunsInEDT public void showWindow(@Nonnull Window w, @Nonnull Dimension size)
RobotWindow with proper EDT synchronization. This method blocks until the
Window is showing and ready for input.showWindow in interface Robotw - the window to display.size - the size of the window to display.@RunsInEDT public void showWindow(@Nonnull Window w, @Nullable Dimension size, boolean pack)
Robot
Safely display an AWT or Swing Window with proper EDT synchronization. This method blocks until the
Window is showing. This method will return even when the window is a modal dialog, since the show method is
called on the event dispatch thread (EDT.) The Window will be packed if the pack flag is set, and set to
the given size if it is non-null.
Modal dialogs may be shown with this method without blocking.
showWindow in interface Robotw - the window to display.size - the size of the window to display. A null value indicates that the window does not need to be
resized.pack - flag that indicates if the window should be packed or not. By packed we mean calling w.pack().@RunsInEDT public void close(@Nonnull Window w)
RobotWindow.@RunsInEDT public void focusAndWaitForFocusGain(@Nonnull Component c)
RobotComponent and waits until the Component has focus.focusAndWaitForFocusGain in interface Robotc - the Component to give focus to.@RunsInEDT public void focus(@Nonnull Component c)
RobotComponent. Note that the Component may not yet have
focus when this method returns.@RunsInEDT public void cleanUp()
RobotScreenLock) used by this Robot.@RunsInEDT public void cleanUpWithoutDisposingWindows()
Robot
Cleans up any used resources (keyboard, mouse and ScreenLock) used by this Robot. This method
does not dispose any open windows.
Note: The preferred method to use to clean up resources is Robot.cleanUp(). Using
Robot.cleanUpWithoutDisposingWindows() may leave many windows open after each test. Use it on very special
cases. Please read bug 138 for
more details.
cleanUpWithoutDisposingWindows in interface Robot@RunsInEDT public void click(@Nonnull Component c)
RobotComponent using the left mouse button.@RunsInEDT public void rightClick(@Nonnull Component c)
RobotComponent.rightClick in interface Robotc - the Component to click on.@RunsInEDT public void click(@Nonnull Component c, @Nonnull MouseButton button)
RobotComponent using the given mouse button.@RunsInEDT public void doubleClick(@Nonnull Component c)
RobotComponent.doubleClick in interface Robotc - the Component to click on.@RunsInEDT public void click(@Nonnull Component c, @Nonnull MouseButton button, int times)
RobotComponent.@RunsInEDT public void click(@Nonnull Component c, @Nonnull Point where)
RobotComponent.@RunsInEDT public void click(@Nonnull Point where, @Nonnull MouseButton button, int times)
Robot@RunsInEDT public void click(@Nonnull Component c, @Nonnull Point where, @Nonnull MouseButton button, int times)
RobotComponent.public void pressModifiers(int modifierMask)
Robotjava.awt.event.InputEvent.pressModifiers in interface RobotmodifierMask - the given mask.InputEventpublic void releaseModifiers(int modifierMask)
Robotjava.awt.event.InputEvent.releaseModifiers in interface RobotmodifierMask - the given mask.InputEvent@RunsInEDT public void moveMouse(@Nonnull Component c)
RobotComponent.@RunsInEDT public void moveMouse(@Nonnull Component c, @Nonnull Point p)
RobotComponent.@RunsInEDT public void moveMouse(@Nonnull Component c, int x, int y)
RobotComponent.public void moveMouse(@Nonnull Point p)
Robotpublic void moveMouse(int x,
int y)
Robotpublic void pressMouse(@Nonnull MouseButton button)
RobotpressMouse in interface Robotbutton - the mouse button to press.public void pressMouse(@Nonnull Component c, @Nonnull Point where)
RobotComponent.pressMouse in interface Robotc - the Component to click on.where - the given coordinates, relative to the given Component.public void pressMouse(@Nonnull Component c, @Nonnull Point where, @Nonnull MouseButton button)
RobotComponent.pressMouse in interface Robotc - the Component to click on.where - the given coordinates, relative to the given Component.button - the mouse button to press.public void pressMouse(@Nonnull Point where, @Nonnull MouseButton button)
RobotpressMouse in interface Robotwhere - the position where to press the given mouse button.button - the mouse button to press.@RunsInEDT public void releaseMouse(@Nonnull MouseButton button)
RobotreleaseMouse in interface Robotbutton - the mouse button to release.@RunsInEDT public void releaseMouseButtons()
RobotreleaseMouseButtons in interface Robotpublic void rotateMouseWheel(@Nonnull Component c, int amount)
RobotComponent and rotates the scroll wheel on
wheel-equipped mice.rotateMouseWheel in interface Robotc - the given Component.amount - number of "notches" to move the mouse wheel. Negative values indicate movement up/away from the user,
while positive values indicate movement down/towards the user.public void rotateMouseWheel(int amount)
RobotrotateMouseWheel in interface Robotamount - number of "notches" to move the mouse wheel. Negative values indicate movement up/away from the user,
while positive values indicate movement down/towards the user.@RunsInEDT public void jitter(@Nonnull Component c)
RobotComponent.@RunsInEDT public void jitter(@Nonnull Component c, @Nonnull Point where)
RobotComponent at the given
point.@RunsInEDT public void enterText(@Nonnull String text)
RobotComponent that has input focus.@RunsInEDT public void type(char character)
RobotComponent that
has input focus.@RunsInEDT public void pressAndReleaseKey(int keyCode, @Nonnull int... modifiers)
Robotjava.awt.event.InputEvent masks.pressAndReleaseKey in interface RobotkeyCode - the code of the key to press.modifiers - the given modifiers.@RunsInEDT public void pressAndReleaseKeys(@Nonnull int... keyCodes)
RobotpressAndReleaseKeys in interface RobotkeyCodes - one or more codes of the keys to press.KeyEvent@RunsInEDT public void pressKey(int keyCode)
Robot@RunsInEDT public void releaseKey(int keyCode)
RobotreleaseKey in interface RobotkeyCode - the code of the key to release.KeyEvent@RunsInEDT public void waitForIdle()
Robotjava.awt.Robot.waitForIdle(), which may have events on the queue when it returns. Do NOT
use this method if there are animations or other continual refreshes happening, since in that case it may never
return.waitForIdle in interface Robotpublic boolean isDragging()
RobotisDragging in interface Robottrue if the robot is currently in a dragging operation, false otherwise.@RunsInEDT @Nonnull public JPopupMenu showPopupMenu(@Nonnull Component invoker)
RobotJPopupMenu.showPopupMenu in interface Robotinvoker - the Component to invoke the JPopupMenu from.JPopupMenu.@RunsInEDT @Nonnull public JPopupMenu showPopupMenu(@Nonnull Component invoker, @Nonnull Point location)
RobotJPopupMenu at the given coordinates.showPopupMenu in interface Robotinvoker - the Component to invoke the JPopupMenu from.location - the given coordinates for the JPopupMenu.JPopupMenu.@RunsInCurrentThread public boolean isReadyForInput(@Nonnull Component c)
Indicates whether the given AWT or Swing Component is ready for input.
Note: This method is accessed in the current executing thread. Such thread may or may not be the event dispatch thread (EDT.) Client code must call this method from the EDT.
isReadyForInput in interface Robotc - the given Component.true if the given Component is ready for input, false otherwise.ActionFailedException - if the given Component does not have a Window ancestor.@RunsInEDT @Nullable public JPopupMenu findActivePopupMenu()
findActivePopupMenu in interface RobotJPopupMenu or null, if no pop-up is currently showing.@RunsInEDT public void requireNoJOptionPaneIsShowing()
RobotJOptionPane showing, and potentially blocking GUI tests.requireNoJOptionPaneIsShowing in interface Robot@Nonnull public ComponentHierarchy hierarchy()
public boolean isActive()
RobotRobot is active. Being "active" means that Robot.cleanUp() has not been called
yet.Copyright © 2014 AssertJ. All rights reserved.