public class GuiTestObject extends TestObject implements IFocusable, INativeWindow, IClickable, IKeyable
Modifier | Constructor and Description |
---|---|
protected |
GuiTestObject(JtfObjectHandle handle,
Desktop desktop)
Creates a new GuiTestObject with a JtfObjectHandle.
|
Modifier and Type | Method and Description |
---|---|
void |
click()
Clicks on the object.
|
void |
click(int button)
Clicks on the object.
|
void |
click(int button,
Point pos)
Clicks on the object.
|
void |
click(int button,
Point pos,
ModifierKey modifiers)
Clicks on the object.
|
void |
doubleClick()
Double-clicks a mouse button on the object.
|
void |
doubleClick(int button)
Double-clicks a mouse button on the object.
|
void |
doubleClick(int button,
Point pos)
Double-clicks a mouse button on the object.
|
void |
doubleClick(int button,
Point pos,
ModifierKey modifiers)
Double-clicks a mouse button on the object.
|
Color |
getBackground()
Gets the background color of the GUI object.
|
String |
getFont()
Gets the font type of the GUI object.
|
Color |
getForeground()
Gets the foreground color of the GUI object.
|
int |
getNativeHandle()
Gets the native window handle for the object.
|
boolean |
isEnabled()
Gets whether the GUI object is enabled.
|
boolean |
isFocused()
Return whether the control has focus.
|
boolean |
isVisible()
Gets whether the object is visible.
|
void |
mouseMove()
Moves the pointer to the specified location in the object.
|
void |
mouseMove(Point pos)
Moves the pointer to the specified location in the object.
|
void |
pressKeys(String keys)
Presses (but does not release) a set of keys or mouse buttons.
|
void |
pressKeys(String keys,
boolean ensureFocus)
Presses (but does not release) a set of keys or mouse buttons.
|
void |
pressMouse()
Presses (but does not release) a mouse button in the object.
|
void |
pressMouse(int button)
Presses (but does not release) a mouse button in the object.
|
void |
pressMouse(int button,
Point pos)
Presses (but does not release) a mouse button in the object.
|
void |
pressMouse(int button,
Point pos,
ModifierKey modifiers)
Presses (but does not release) a mouse button in the object.
|
void |
releaseKeys(String keys)
Releases a set of keys or mouse buttons.
|
void |
releaseKeys(String keys,
boolean ensureFocus)
Releases a set of keys or mouse buttons.
|
void |
releaseMouse()
Releases a mouse button.
|
void |
releaseMouse(int button)
Releases a mouse button.
|
void |
releaseMouse(int button,
Point pos)
Releases a mouse button.
|
void |
releaseMouse(int button,
Point pos,
ModifierKey modifiers)
Releases a mouse button.
|
void |
setBackground(Color background)
Sets the background color of the GUI object.
|
void |
setEnabled(boolean enabled)
Sets whether the GUI object is enabled.
|
void |
setFocus()
Gives focus to the control.
|
void |
setFont(String font)
Sets the font type of the GUI object.
|
void |
setForeground(Color foreground)
Sets the foreground color of the GUI object.
|
void |
setVisible(boolean visible)
Sets whether the object is visible.
|
void |
typeKeys(String keys)
Sends a set of keystrokes to the object.
|
void |
typeKeys(String keys,
int delay)
Sends a set of keystrokes to the object.
|
void |
typeKeys(String keys,
int delay,
boolean ensureFocus)
Sends a set of keystrokes to the object.
|
void |
typePasswordKeys(String keys)
Types an encrypted password into an object, for example a text field.
|
void |
typePasswordKeys(String keys,
int delay)
Types an encrypted password into an object, for example a text field.
|
void |
typePasswordKeys(String keys,
int delay,
boolean ensureFocus)
Types an encrypted password into an object, for example a text field.
|
captureBitmap, captureBitmap, exists, exists, generateLocator, getChildren, getDynamicMethodList, getParent, getPropertyList, getRect, getRect, getText, getValue, highlightObject, highlightObject, highlightObject, invokeMethods, textCapture, textCapture, textClick, textClick, textClick, textClick, textClick, textClick, textExists, textExists, textExists, textExists, textExists, textRectangle, textRectangle, textRectangle, textRectangle, textRectangle, waitForChildDisappearance, waitForChildDisappearance, waitForDisappearance, waitForDisappearance, waitForObject, waitForObject, waitForProperty, waitForProperty
equals, exists, find, find, findAll, findAll, getCustomTypeName, getDesktop, getHandle, getLocator, getProperty, getTypeName, hashCode, imageClick, imageClick, imageClick, imageClick, imageClick, imageClick, imageClickFile, imageClickFile, imageClickFile, imageClickFile, imageClickFile, imageClickFile, imageExists, imageExists, imageExists, imageExistsFile, imageExistsFile, imageExistsFile, imageRectangle, imageRectangle, imageRectangle, imageRectangleFile, imageRectangleFile, imageRectangleFile, invoke, preventFinalLocator, setProperty, toString
protected GuiTestObject(JtfObjectHandle handle, Desktop desktop)
handle
- the handle that identifies the GuiTestObjectdesktop
- the desktop on which this object livespublic void click()
Sample Usage
For example, in order to click on a certain position within a control, type the following:
control.click (MouseButton.LEFT, new Point(244, 16));
The following example uses the left mouse button to click in the center of the control:
control.click ();
click
in interface IClickable
public void click(int button)
Sample Usage
For example, in order to click on a certain position within a control, type the following:
control.click (MouseButton.LEFT, new Point(244, 16));
The following example uses the left mouse button to click in the center of the control:
control.click ();
click
in interface IClickable
button
- the mouse button to press. Values include: 1=left, 2=right,3=center,...public void click(int button, Point pos)
Sample Usage
For example, in order to click on a certain position within a control, type the following:
control.click (MouseButton.LEFT, new Point(244, 16));
The following example uses the left mouse button to click in the center of the control:
control.click ();
click
in interface IClickable
button
- the mouse button to press. Values include: 1=left, 2=right,3=center,...pos
- the coordinates (relative to the object) at which to clickpublic void click(int button, Point pos, ModifierKey modifiers)
Sample Usage
For example, in order to click on a certain position within a control, type the following:
control.click (MouseButton.LEFT, new Point(244, 16));
The following example uses the left mouse button to click in the center of the control:
control.click ();
click
in interface IClickable
button
- the mouse button to press. Values include: 1=left, 2=right,3=center,...pos
- the coordinates (relative to the object) at which to clickmodifiers
- the modifierpublic void doubleClick()
doubleClick
in interface IClickable
public void doubleClick(int button)
doubleClick
in interface IClickable
button
- the mouse button to press. Values include: 1=left, 2=right,3=center,...public void doubleClick(int button, Point pos)
doubleClick
in interface IClickable
button
- the mouse button to press. Values include: 1=left, 2=right,3=center,...pos
- the coordinates (relative to the object) at which to clickpublic void doubleClick(int button, Point pos, ModifierKey modifiers)
doubleClick
in interface IClickable
button
- the mouse button to press. Values include: 1=left, 2=right,3=center,...pos
- the coordinates (relative to the object) at which to clickmodifiers
- the modifierpublic boolean isFocused()
isFocused
in interface IFocusable
public void mouseMove()
mouseMove
in interface IClickable
public void mouseMove(Point pos)
mouseMove
in interface IClickable
pos
- the coordinates (relative to the window) of the new locationpublic void pressKeys(String keys)
Valid keystrokes include:
public void pressKeys(String keys, boolean ensureFocus)
Valid keystrokes include:
public void pressMouse()
pressMouse
in interface IClickable
public void pressMouse(int button)
pressMouse
in interface IClickable
button
- the mouse button to press. Values include: 1=left, 2=right,3=center,...public void pressMouse(int button, Point pos)
pressMouse
in interface IClickable
button
- the mouse button to press. Values include: 1=left, 2=right,3=center,...pos
- the coordinates (relative to the object) at which to press the mousepublic void pressMouse(int button, Point pos, ModifierKey modifiers)
pressMouse
in interface IClickable
button
- the mouse button to press. Values include: 1=left, 2=right,3=center,...pos
- the coordinates (relative to the object) at which to press the mousemodifiers
- the modifierpublic void releaseKeys(String keys)
Valid keystrokes include:
releaseKeys
in interface IKeyable
keys
- the keys or mouse buttons to releasepublic void releaseKeys(String keys, boolean ensureFocus)
Valid keystrokes include:
releaseKeys
in interface IKeyable
keys
- the keys or mouse buttons to releaseensureFocus
- determines whether it should be ensured that the control actually has the keyboard focus. Defaults to true
public void releaseMouse()
releaseMouse
in interface IClickable
public void releaseMouse(int button)
releaseMouse
in interface IClickable
button
- the mouse button to press. Values include: 1=left, 2=right,3=center,...public void releaseMouse(int button, Point pos)
releaseMouse
in interface IClickable
button
- the mouse button to press. Values include: 1=left, 2=right,3=center,...pos
- the coordinates (relative to the object) at which to release the mousepublic void releaseMouse(int button, Point pos, ModifierKey modifiers)
releaseMouse
in interface IClickable
button
- the mouse button to press. Values include: 1=left, 2=right,3=center,...pos
- the coordinates (relative to the object) at which to release the mousemodifiers
- the modifierpublic void setFocus()
setFocus
in interface IFocusable
public void typeKeys(String keys)
Valid keystrokes include:
Sample UsageFor example, the following code copies the currently selected text into the clipboard by pressing Ctrl+C:
window.typeKeys ("<Left Ctrl+C>");
public void typeKeys(String keys, int delay)
Valid keystrokes include:
Sample UsageFor example, the following code copies the currently selected text into the clipboard by pressing Ctrl+C:
window.typeKeys ("<Left Ctrl+C>");
public void typeKeys(String keys, int delay, boolean ensureFocus)
Valid keystrokes include:
Sample UsageFor example, the following code copies the currently selected text into the clipboard by pressing Ctrl+C:
window.typeKeys ("<Left Ctrl+C>");
public void typePasswordKeys(String keys)
If the object supports the SetText method, any existing text is cleared before typing the encrypted password.
Sample Usage
Sample Usage
For example, the following code encrypts a string and prints it to the console:
String encryptedPassword = desktop.encrypt("my password"); System.out.println(encryptedPassword);
You can then copy the encrypted password from the console, in this case 6Fk+Bcm+GoXe3X0=
, and use it as follows:
textField.typePasswordKeys("6Fk+Bcm+GoXe3X0=");
typePasswordKeys
in interface IKeyable
keys
- the encrypted passwordpublic void typePasswordKeys(String keys, int delay)
If the object supports the SetText method, any existing text is cleared before typing the encrypted password.
Sample Usage
Sample Usage
For example, the following code encrypts a string and prints it to the console:
String encryptedPassword = desktop.encrypt("my password"); System.out.println(encryptedPassword);
You can then copy the encrypted password from the console, in this case 6Fk+Bcm+GoXe3X0=
, and use it as follows:
textField.typePasswordKeys("6Fk+Bcm+GoXe3X0=");
typePasswordKeys
in interface IKeyable
keys
- the encrypted passworddelay
- the delay between keystrokes in millisecondspublic void typePasswordKeys(String keys, int delay, boolean ensureFocus)
If the object supports the SetText method, any existing text is cleared before typing the encrypted password.
Sample Usage
Sample Usage
For example, the following code encrypts a string and prints it to the console:
String encryptedPassword = desktop.encrypt("my password"); System.out.println(encryptedPassword);
You can then copy the encrypted password from the console, in this case 6Fk+Bcm+GoXe3X0=
, and use it as follows:
textField.typePasswordKeys("6Fk+Bcm+GoXe3X0=");
typePasswordKeys
in interface IKeyable
keys
- the encrypted passworddelay
- the delay between keystrokes in millisecondsensureFocus
- determines whether it should be ensured that the control actually has the keyboard focus. Defaults to true
public Color getBackground()
public void setBackground(Color background)
background
- the background color of the GUI objectpublic boolean isEnabled()
public void setEnabled(boolean enabled)
enabled
- whether the GUI object is enabledpublic String getFont()
public void setFont(String font)
font
- the font type of the GUI objectpublic Color getForeground()
public void setForeground(Color foreground)
foreground
- the foreground color of the GUI objectpublic int getNativeHandle()
getNativeHandle
in interface INativeWindow
public boolean isVisible()
true
. However, you might need this property when an already located object in the application under test gets invisible during replay.public void setVisible(boolean visible)
true
. However, you might need this property when an already located object in the application under test gets invisible during replay.visible
- whether the object is visible. You can only locate visible objects, so by default the value is always true
. However, you might need this property when an already located object in the application under test gets invisible during replay.Copyright 2009-2012 Micro Focus. All Rights Reserved.