public class Desktop extends TestObject implements IClickable, IKeyable
| Modifier | Constructor and Description |
|---|---|
|
Desktop()
Creates a desktop that connects (via RMI) to an Agent on the default machine (if no system
properties are specified this will be
localhost). |
protected |
Desktop(com.borland.silktest.jtf.internal.Agent agent) |
|
Desktop(String url)
Creates a desktop that connects (via RMI) to an Agent on the given machine by using the specified host.
If no Agent is running or the Agent cannot be reached on that machine, an exception is thrown. If the specified host is the localhost, the Agent is started. After the connection is established, all Agent options are reset to their default values. |
| Modifier and Type | Method and Description |
|---|---|
void |
attach(String executablePattern)
Attaches to the given application.
|
void |
attach(String executablePattern,
String commandLinePattern)
Attaches to the given application that matches the executable pattern and the command line pattern.
|
void |
attach(String executablePattern,
String commandLinePattern,
TechDomain... techdomains)
Attaches to the given application that matches the executable pattern and the command line pattern.
|
void |
attach(String executablePattern,
TechDomain... techdomains)
Attaches to the given application and tries to enable the specified techdomains.
|
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.
|
<T> T |
createAgentDllCall(Class<T> clz)
Returns an object that implements the specified Dll call interface and that will route all calls against the
interface to the Agent where it will load the DLL and execute the calls.
|
<T> T |
createInProcessDllCall(Class<T> clz)
Returns an object that implements the specified Dll call interface and that will route all calls against the
interface to the AUT where it will load the DLL and execute the calls.
|
String |
decrypt(String toDecrypt)
Decrypts the given string.
|
void |
detachAll()
Detaches all currently attached applications.
|
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.
|
String |
encrypt(String toEncrypt)
Encrypts the given string.
|
<T extends TestObject> |
executeBaseState(IBaseState baseState)
Ensures that the application under test is running and ready for testing.
|
String |
getClipboardText()
Returns the current text of the system clipboard.
|
Desktop |
getDesktop()
Returns the desktop for this object.
|
Object |
getOption(String optionName)
Retrieves the value of an Agent option.
Example: desktop.getOption(CommonOptions.OPT_WAIT_RESOLVE_OBJDEF) |
Object |
getOption(String optionName,
TechDomain techDomain)
Retrieves the value of a techdomain specific option.
|
void |
logError(String message)
Logs an error message and screenshot of the complete desktop to the TrueLog file that is written during test execution.
|
void |
logError(String message,
TruelogScreenshotMode screenshotMode)
Logs an error message and a screenshot to the TrueLog file that is written during test execution.
|
void |
logInfo(String message)
Logs an informational message to the TrueLog file that is written during test execution.
|
void |
logInfo(String message,
TruelogScreenshotMode screenshotMode)
Logs an informational message and a screenshot to the TrueLog file that is written during test execution.
|
void |
logWarning(String message)
Logs a warning message to the TrueLog file that is written during test execution.
|
void |
logWarning(String message,
TruelogScreenshotMode screenshotMode)
Logs an warning message and a screenshot to the TrueLog file that is written during test execution.
|
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 |
resetAllOptions()
Resets all options on the Agent to their default values.
|
void |
setClipboardText(String text)
Writes a new text into the system clipboard.
|
void |
setOption(String optionName,
Object optionValue)
Sets an Agent option.
|
void |
setOption(String optionName,
Object optionValue,
TechDomain... techDomains)
Sets an option for the given techdomains.
Example: desktop.setOption(CommonOptions.OPT_CUSTOM_ATTRIBUTES, Arrays.asList("automationId"), TechDomain.SWT, TechDomain.WIN32) |
void |
shutdownAgent()
Call this method to ensure that the Open Agent stops after a test run, for example after a nightly test execution.
|
String |
toString()
Returns a string that contains the class name and the test object's attributes.
|
boolean |
tryVerifyAsset(String verificationAsset)
Executes a verification asset and returns whether the verification passed.
|
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.
|
void |
unloadAllDllsFromAgent()
Unloads all currently loaded DLLs from the agent.
|
<T> boolean |
unloadDllFromAgent(Class<T> dll)
Unloads the specified DLL from the agent.
|
void |
verifyAsset(String verificationAsset)
Executes a verification asset.
|
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, waitForPropertyequals, exists, find, find, findAll, findAll, getCustomTypeName, 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, setPropertypublic Desktop()
localhost). In the local machine scenario, an Agent is
started automatically if no agent is running.resetAllOptions()).agentRmiHost. This can be used to replay a script on
different machines without the need to change the script.-DagentRmiHost=10.5.2.3 is passed via command line, this method
connects to the Agent at the specified host.AgentConnectionException - if connecting to the Agent fails. This can be the case if no Agent is running or
the Agent's port is blocked.public Desktop(String url)
resetAllOptions()).url - The URL to the Open Agent.AgentConnectionException - if connecting to the Agent fails. This can be the case if the host is invalid, no
Agent is running on the specified host, or the Agent's machine blocks the port.
protected Desktop(com.borland.silktest.jtf.internal.Agent agent)
public <T extends TestObject> T executeBaseState(IBaseState baseState)
T - the type of the test object as specified by the locatorbaseState - contains all information required for executing the base stateTestObject that was found using the locator as specified by the base state.BaseState,
public void attach(String executablePattern, TechDomain... techdomains)
NoteBorland recommends using attach(String) for automatic techdomain loading. Selective techdomain loading is an advanced technique that is required only in specific situations.
executablePattern - the executable name of the application. The pattern may include the wildcards '?' and '*' which match one or
none to many characters respectively. Examples: myApplication.exemyApplica?ion.exemyApp*.exetechdomains - the techdomains which should be loaded in the application. Constants for the techdomains are defined in
TechDomain.
public void attach(String executablePattern, String commandLinePattern, TechDomain... techdomains)
*org.MyMainClass).
NoteBorland recommends using attach(String, String) for automatic techdomain loading. Selective techdomain loading is an advanced technique that is required only in specific situations.
executablePattern - the executable name of the application. The pattern may include the wildcards '?' and '*'
which match one or none to many characters respectively. Examples: javaw.exejava*.execommandLinePattern - This pattern is matched against the command line arguments of the application. This is useful when
multiple instances of an application (e.g. javaw.exe) are running, but only some of them should be tested. For java
applications, the command line pattern could include the name of a characteristic jar or the main class, e.g:
*org.MyMainClass).techdomains - the techdomains which should be loaded in the application. Constants for the techdomains are defined in
TechDomain.public void attach(String executablePattern)
executablePattern - the executable name of the application. The pattern may include the wildcards '?' and '*'
which match one or none to many characters respectively. Examples: myApplication.exemyApplica?ion.exemyApp*.exepublic void attach(String executablePattern, String commandLinePattern)
*org.MyMainClass).executablePattern - the executable name of the application. The pattern may include the wildcards '?' and '*'
which match one or none to many characters respectively. Examples: javaw.exejava*.execommandLinePattern - This pattern is matched against the command line arguments of the application.
public void detachAll()
public Object getOption(String optionName)
desktop.getOption(CommonOptions.OPT_WAIT_RESOLVE_OBJDEF)optionName - The name of the option. For a list of available options see CommonOptions.public Object getOption(String optionName, TechDomain techDomain)
optionName - For a list of available options see CommonOptions.techDomain - The techdomain.public void setOption(String optionName, Object optionValue, TechDomain... techDomains)
desktop.setOption(CommonOptions.OPT_CUSTOM_ATTRIBUTES, Arrays.asList("automationId"), TechDomain.SWT, TechDomain.WIN32)optionName - The name of the option. For a list of available options see CommonOptions.techDomains - The name(s) of the techdomain.optionValue - The value of the option
public void setOption(String optionName, Object optionValue)
desktop.setOption(CommonOptions.OPT_WAIT_RESOLVE_OBJDEF, true)optionName - The name of the option. For a list of available options see CommonOptions.optionValue - The value of the option.
public void resetAllOptions()
public String encrypt(String toEncrypt)
toEncrypt - the string to encryptpublic String decrypt(String toDecrypt)
encrypt method.toDecrypt - the string to decryptpublic String getClipboardText()
public void setClipboardText(String text)
text - the new text of the clipboard
public <T> T createInProcessDllCall(Class<T> clz)
DllCall.createInProcessDllCall(Class, Desktop).T - the DLL call interface to supportclz - the class of the DLL call interface to supportpublic <T> T createAgentDllCall(Class<T> clz)
DllCall.createAgentDllCall(Class, Desktop).T - the DLL call interface to supportclz - the class of the DLL call interface to supportpublic <T> boolean unloadDllFromAgent(Class<T> dll)
T - the DLL type to unloaddll - the DLL object to unloadpublic void unloadAllDllsFromAgent()
public Desktop getDesktop()
AbstractTestObjectgetDesktop in class AbstractTestObjectpublic String toString()
AbstractTestObjecttoString in class AbstractTestObjectpublic void logInfo(String message)
message - the message to log
public void logInfo(String message, TruelogScreenshotMode screenshotMode)
message - the message to logscreenshotMode - defines if a screenshot of the complete desktop, the active application, or the active window should be logged
public void logWarning(String message)
message - the warning to log
public void logWarning(String message, TruelogScreenshotMode screenshotMode)
message - the warning to logscreenshotMode - defines if a screenshot of the complete desktop, the active application, or the active window should be logged
public void logError(String message)
message - the error to log
public void logError(String message, TruelogScreenshotMode screenshotMode)
message - the error to logscreenshotMode - defines if a screenshot of the complete desktop, the active application, or the active window should be logged
public void verifyAsset(String verificationAsset)
verificationAsset - the name of the .verification file. The file extension can be omitted.VerificationFailedException - if the verification does not pass.ObjectNotFoundException - if the UI object to verify cannot be found
public boolean tryVerifyAsset(String verificationAsset)
verificationAsset - The name of the .verification file. The file extension can be omitted.ObjectNotFoundException - if the UI object to verify cannot be found
public void shutdownAgent()
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
public void run() {
desktop.shutdownAgent();
}
}));
public void click()
IClickableSample 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 IClickablepublic void click(int button)
IClickableSample 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 IClickablebutton - the mouse button to press. Values include: 1=left, 2=right,3=center,...public void click(int button,
Point pos)
IClickableSample 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 IClickablebutton - 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)
IClickableSample 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 IClickablebutton - 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()
IClickabledoubleClick in interface IClickablepublic void doubleClick(int button)
IClickabledoubleClick in interface IClickablebutton - the mouse button to press. Values include: 1=left, 2=right,3=center,...public void doubleClick(int button,
Point pos)
IClickabledoubleClick in interface IClickablebutton - 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)
IClickabledoubleClick in interface IClickablebutton - 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 mouseMove()
IClickablemouseMove in interface IClickablepublic void mouseMove(Point pos)
IClickablemouseMove in interface IClickablepos - the coordinates (relative to the window) of the new locationpublic void pressMouse()
IClickablepressMouse in interface IClickablepublic void pressMouse(int button)
IClickablepressMouse in interface IClickablebutton - the mouse button to press. Values include: 1=left, 2=right,3=center,...public void pressMouse(int button,
Point pos)
IClickablepressMouse in interface IClickablebutton - 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)
IClickablepressMouse in interface IClickablebutton - 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 releaseMouse()
IClickablereleaseMouse in interface IClickablepublic void releaseMouse(int button)
IClickablereleaseMouse in interface IClickablebutton - the mouse button to press. Values include: 1=left, 2=right,3=center,...public void releaseMouse(int button,
Point pos)
IClickablereleaseMouse in interface IClickablebutton - 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)
IClickablereleaseMouse in interface IClickablebutton - 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 pressKeys(String keys)
IKeyableValid keystrokes include:
public void pressKeys(String keys, boolean ensureFocus)
IKeyableValid keystrokes include:
public void releaseKeys(String keys)
IKeyableValid keystrokes include:
releaseKeys in interface IKeyablekeys - the keys or mouse buttons to releasepublic void releaseKeys(String keys, boolean ensureFocus)
IKeyableValid keystrokes include:
releaseKeys in interface IKeyablekeys - the keys or mouse buttons to releaseensureFocus - determines whether it should be ensured that the control actually has the keyboard focus. Defaults to truepublic void typeKeys(String keys)
IKeyableValid 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)
IKeyableValid 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)
IKeyableValid 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)
IKeyableIf 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 IKeyablekeys - the encrypted passwordpublic void typePasswordKeys(String keys, int delay)
IKeyableIf 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 IKeyablekeys - the encrypted passworddelay - the delay between keystrokes in millisecondspublic void typePasswordKeys(String keys, int delay, boolean ensureFocus)
IKeyableIf 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 IKeyablekeys - 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 trueCopyright 2009-2012 Micro Focus. All Rights Reserved.