|
IBM Rational Functional Tester Version 8.1.1000 IBM Rational Functional Tester API Reference Project Version 2.3 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.rational.test.ft.script.DatapoolScriptSupport com.rational.test.ft.script.SubitemFactory com.rational.test.ft.script.RationalTestScript
public abstract class RationalTestScript
Provides a variety of methods that can be used in any script. Every script extends this class. It also provides a base implementation for a number of event methods, which you can override if you want to handle these events directly.
Field Summary | |
---|---|
static TestObject |
ANY
Acts as the default anchor object for script commands that use specific ScriptCommandFlags with an explicit anchor value. |
static java.lang.Object[] |
DEFAULT_ARGS
Acts as the default arguments object for callScript commands. |
Fields inherited from class com.rational.test.ft.script.DatapoolScriptSupport |
---|
DP_ALL, DP_DEFAULT_EQUIVALENCE_CLASS, DP_SHARE_CURRENT_RECORD |
Constructor Summary | |
---|---|
RationalTestScript()
Constructs a RationalTestScript object. |
Method Summary | |
---|---|
protected java.lang.Object |
callScript(RationalTestScript script)
Constructs the specified script and invokes the runMain method on the
script. |
protected java.lang.Object |
callScript(RationalTestScript script, java.lang.Object[] args)
Constructs the specified script and invokes the runMain method on the
script. |
protected java.lang.Object |
callScript(RationalTestScript script, java.lang.Object[] args, int iterationCount)
Constructs the specified script and invokes the runMain method on the
script. |
protected java.lang.Object |
callScript(java.lang.String scriptFullName)
Constructs the specified script and invokes the runMain method on the
script. |
protected java.lang.Object |
callScript(java.lang.String scriptFullName, java.lang.Object[] args)
Constructs the specified script and invokes the runMain method on the
script. |
protected java.lang.Object |
callScript(java.lang.String scriptFullName, java.lang.Object[] args, int iterationCount)
Constructs the specified script and invokes the runMain method on the
script. |
void |
cleanup()
This function dereferences the object map used by this script. |
static void |
derefAll()
|
static boolean |
downloadProjectFiles(java.lang.String[] projectRelativeFiles)
Download project relative files from the source machine to the remote machine. |
void |
dpNext()
Override for DatapoolScriptSupport.dpNext() to
allow for incrementing the script iteration count. |
static TestObject[] |
find(Subitem properties)
Finds all candidates that match given search criteria. |
static TestObject[] |
find(Subitem properties, boolean mappableOnly)
Finds all candidates that match given search criteria. |
static java.lang.String[] |
getApplications()
Returns an array of the application names defined in the configuration. |
static java.lang.String[] |
getBrowsers()
Returns an array of the browser names defined in the Enabler. |
static java.lang.String |
getCurrentBrowser()
Returns the default browser. |
static java.lang.String |
getCurrentJVM()
Returns the default JVM. |
static ITestProject |
getCurrentProject()
Locate the active project object relative to the current script. |
int |
getCurrentScriptIterationCount()
Returns the current script iteration count |
static DomainTestObject[] |
getDomains()
Returns an array of all the testable domains in the system. |
static java.lang.String |
getenv(java.lang.String name)
Gets the value of an environment variable. |
static java.lang.String[] |
getJVMs()
Returns an array of the JVM names defined in the Enabler. |
int |
getLineNumber()
Returns the line number of the method (in the source code) if a method belonging to this script is currently executing. |
protected int |
getLineNumber(java.lang.String className)
Returns the line number of the method (in the source code). |
com.rational.test.ft.object.map.ObjectMap |
getMap()
Returns the object map associated with the script. |
com.rational.test.ft.object.map.ObjectMap |
getMap(java.lang.String id)
|
com.rational.test.ft.object.map.SpyMappedTestObject |
getMappedTestObject(java.lang.String testObjectName)
Returns an object from the object map, given a script-specific unique identifier. |
static IOperatingSystem |
getOperatingSystem()
Allows access to certain host-specific methods that are otherwise difficult to access. |
static java.lang.Object |
getOption(java.lang.String name)
Returns an option value. |
static ITestProject |
getProject(java.lang.String name)
Locate the registered project with the specified name . |
static ITestProject |
getProjectByLocation(java.lang.String projectDirectory)
Locate the project at the specified projectDirectory . |
static TestObject[] |
getRegisteredTestObjects()
Returns all registered TestObjects for this client. |
static RootTestObject |
getRootTestObject()
Get the RootTestObject |
static IScreen |
getScreen()
Returns an interface to the screen object. |
java.lang.Object[] |
getScriptArgs()
Returns the arguments passed to the script testMain . |
RationalTestScript |
getScriptCaller()
Returns the script that called this script using callScript . |
IScriptDefinition |
getScriptDefinition()
Returns the ScriptDefinition interface. |
java.lang.String |
getScriptName()
Returns the script name. |
com.ibm.rational.test.ft.extensions.ISimplifiedTestScriptAction |
getSimplifiedAction()
|
int |
getSimplifiedScriptLine()
Returns the simplified script line for use by logadptor and objectmanager to display the simplified script line and line number during play back. |
static IClipboard |
getSystemClipboard()
Supplies access to the system clipboard. |
static double |
getTimerValue(java.lang.String timerName)
Get the timer value Returns the interval between timerStart(timerName) and getTimer(timerName) in seconds. |
static RationalTestScript |
getTopScript()
Returns the currently executing script at the top of the call stack. |
static int |
getTopScriptLineNumber()
Returns the line number at which the currently executing script at the top of the call stack is executing, or 0 if unknown. |
static java.lang.String |
getTopScriptName()
Returns the name of the currently executing script at the top of the call stack. |
static IWindow[] |
getTopWindows()
Returns an array of IWindows . |
static float |
getVersion()
Returns the version number of the runtime (not for an individual script). |
EList |
getVisualScriptTestElements()
|
static boolean |
isApplicationDefined(java.lang.String applicationName)
Returns true if the specified application has been defined
in the configuration file. |
static boolean |
isBrowserDefined(java.lang.String browserName)
Returns true if the specified browser name has been defined by the Enabler. |
static boolean |
isJVMDefined(java.lang.String jvmName)
Returns true if the specified JVM name has been defined
by the Enabler. |
boolean |
isMainScript()
Returns true if the currently executing script is the top-level
(main) script, that is, not called by callScript . |
static void |
logError(java.lang.String note)
Logs an error. |
static void |
logError(java.lang.String note, java.awt.image.BufferedImage snapshot)
Logs an error that includes a screen snapshot. |
static void |
logException(java.lang.Throwable e)
|
static void |
logInfo(java.lang.String note)
Logs an informational message. |
static void |
logInfo(java.lang.String note, java.awt.image.BufferedImage snapshot)
Logs an informational message that includes a screen snapshot. |
static void |
logTestResult(java.lang.String headline, boolean passed)
Logs a test result. |
static void |
logTestResult(java.lang.String headline, boolean passed, java.lang.String additionalInfo)
Logs a test result. |
static void |
logWarning(java.lang.String note)
Logs a warning. |
static void |
logWarning(java.lang.String note, java.awt.image.BufferedImage snapshot)
Logs a warning that includes a screen snapshot. |
static GuiTestObject |
objectAtPoint(java.awt.Point screenPt)
Returns a GuiTestObject for the object at the screen location. |
void |
onAmbiguousRecognition(ITestObjectMethodState testObjectMethodState, TestObject[] choices, int[] scores)
Called by the ObjectManager if the ObjectManager is looking for
a TestObject to invoke a method on and it finds more than one object
that matches the description of the MappedTestObject in the
TestObject . |
boolean |
onCallScriptException(java.lang.RuntimeException e)
Indicates that a callScript command raised an exception. |
void |
onInitialize()
Called automatically at the start of every script, before the script's testMain method is called. |
void |
onObjectNotFound(ITestObjectMethodState testObjectMethodState)
Called when a TestObject that matches the description of the
MappedTestObject in the
method cannot be found. |
void |
onRecognitionWarning(ITestObjectMethodState testObjectMethodState, TestObject foundObject, int score)
Called by the ObjectManager when an object is found and the
recognition score is above the warning threshold (rt.recognition_threshold_warning ). |
void |
onRun(ProcessTestObject process)
Called automatically after a process is spawned from RationalTestScript. |
void |
onSubitemNotFound(ITestObjectMethodState testObjectMethodState, TestObject foundObject, java.lang.String subitemDescription)
Called by the ObjectManager when a subitem cannot be
found. |
void |
onTerminate()
Called automatically at the end of every script, after the script's testMain method returns. |
void |
onTestObjectMethodException(ITestObjectMethodState testObjectMethodState, TestObject testObject)
Called by the ObjectManager when it is invoking
a method on a TestObject and an exception is thrown from the method. |
boolean |
onUnhandledException(java.lang.Throwable e)
Called by the runMain
method whenever a Throwable exception
is thrown from the testMain method. |
void |
onVpFailure(IFtVerificationPoint vp)
Called by the IFtVerificationPoint implementation when the
specified verification point fails to compare successfully. |
void |
resetInvocationTimeout()
Reset Invocationtimeout value to the default. |
static void |
resetOption(java.lang.String name)
Resets an option to its default value. |
static ProcessTestObject |
run(java.lang.String command, java.lang.String workingDirectory)
Provides the basic command-line execution functionality. |
static ProcessTestObject |
runJava(java.lang.String main, java.lang.String classpath, java.lang.String workingDirectory, java.lang.String jvm, java.lang.String jvmOptions)
Starts a Java application with the specified options. |
java.lang.Object |
runMain(java.lang.Object[] args)
Handles script initialization, termination, and exceptions. |
java.lang.Object |
runMain(java.lang.Object[] args, int iterationCount)
Wraps the single execution script driver runMain and iterates over the script
for the specified number of times. |
java.lang.Object |
runMain(java.lang.Object[] args, int iterationCount, java.lang.String methodName)
Default we would execute the "testMain" method in the TestScript class But for "keyword Genie Project" Support We need to get the execute methods corresponding to keywords. |
java.lang.Object |
runMain(java.lang.Object[] args, java.lang.String methodName)
|
java.lang.Object |
runMain(java.lang.Object[] args, java.lang.String methodName, java.lang.Object datapool, java.lang.Object iterator)
|
static void |
setCurrentBrowser(java.lang.String browserName)
Sets the default browser for testing Java applications. |
static void |
setCurrentJVM(java.lang.String jvmName)
Sets the default JVM for testing Java applications. |
int |
setCurrentLogFilter(int filterLevel)
Set the new logging filter for results of events |
void |
setDatapool(java.lang.String datapoolName, boolean shared, int iterationCount)
RFT 8.1.1 support multiple datapools. |
static void |
setenv(java.lang.String name, java.lang.String value)
Sets the value of an environment variable. |
void |
setInvocationTimeout(long timeout)
Set Invocationtimeout value While playing back the Script, RFT will wait for the SUT's response for the actions generated . |
static void |
setOption(java.lang.String name, boolean value)
Sets an option to a boolean value. |
static void |
setOption(java.lang.String name, double value)
Sets an option to a double value. |
static void |
setOption(java.lang.String name, float value)
Sets an option to a float value. |
static void |
setOption(java.lang.String name, int value)
Sets an option to an int value. |
static void |
setOption(java.lang.String name, long value)
Sets an option to a long value. |
static void |
setOption(java.lang.String name, java.lang.Object value)
Sets an option to an Object value. |
protected void |
setScriptName(java.lang.String scriptName)
For internal use only. |
void |
setSimplifiedScriptLine(int line)
If visalscript(simplified script) is enabled the JET emits the simplified script line number in the generated java to be able to show the simplified script line number and line in the log and play back monitor. |
static boolean |
shellExecute(java.lang.String fileName)
Starts up the program associated with the file extension. |
static void |
sleep(double seconds)
Waits for the specified amount of time. |
static ProcessTestObject |
startApp(java.lang.String symbolicName)
Starts an application based on a logical name. |
static ProcessTestObject |
startApp(java.lang.String symbolicName, java.lang.String[] args)
Starts the software under test. |
static ProcessTestObject |
startBrowser(java.lang.String url)
Displays a specified URL in the browser of choice. |
static ProcessTestObject |
startBrowser(java.lang.String browserName, java.lang.String url)
Displays a specified URL in the browser of choice. |
static void |
stop()
Stops the script by throwing a UserStoppedScriptError . |
static double |
stopTimer(java.lang.String timerName)
Get the timer value and stop the timer Returns the interval between timerStart(timerName) and stopTimer(timerName) in seconds. |
static void |
timerStart(java.lang.String timerName)
Starts a timer and writes information in the log. |
static void |
timerStop(java.lang.String timerName)
Stops a timer. |
static java.lang.String |
trimStackTrace(java.lang.String stackTrace)
|
static void |
unregister(java.lang.Object[] testObjects)
Unregisters an array of TestObjects for this client. |
static void |
unregisterAll()
Unregisters all TestObjects for this client. |
static void |
unsetenv(java.lang.String name)
Unsets an environment variable. |
protected IFtVerificationPoint |
vp(java.lang.String vpName)
Constructs a static verification point object. |
protected IFtVerificationPoint |
vp(java.lang.String vpName, TestObject anchor)
Constructs a static verification point object. |
protected IFtVerificationPoint |
vpDynamic(java.lang.String vpName)
Constructs a dynamic verification point object. |
protected IFtVerificationPoint |
vpDynamic(java.lang.String vpName, TestObject objectUnderTest)
Constructs a dynamic verification point object. |
protected IFtVerificationPoint |
vpManual(java.lang.String vpName, java.lang.Object actual)
Constructs a manual verification point object. |
protected IFtVerificationPoint |
vpManual(java.lang.String vpName, java.lang.Object expected, java.lang.Object actual)
Constructs a manual verification point object. |
Methods inherited from class com.rational.test.ft.script.SubitemFactory |
---|
_S, atArea, atButton, atButton, atCell, atCell, atChild, atChild, atChild, atColor, atColumn, atColumn, atColumn, atColumn, atColumn, atColumn, atColumn, atColumnHeader, atDate, atDate, atDescendant, atDescendant, atDescendant, atDPoint, atDPosition, atFile, atFile, atHeader, atHref, atId, atImage, atImage, atIndex, atLink, atLink, atList, atList, atList, atList, atList, atLocation, atModifiers, atName, atName, atPath, atPoint, atPosition, atProperty, atRecognitionIndex, atRow, atRow, atRow, atRow, atRow, atRow, atRow, atRowColumnIndex, atRowHeader, atSeparator, atText, atText, atTextPosition, atToolTipText, atToolTipText, atTopLeftHeader, atValue, atWeek, atWeekDay, delay, keyDown, keyUp, leftMouseButtonDown, leftMouseButtonUp, middleMouseButtonDown, middleMouseButtonUp, mouseMove, mouseWheel, rightMouseButtonDown, rightMouseButtonUp, toScreenPoint |
Methods inherited from class com.rational.test.ft.script.DatapoolScriptSupport |
---|
dpBoolean, dpBoolean, dpBoolean, dpByte, dpByte, dpByte, dpChar, dpChar, dpChar, dpCurrent, dpDone, dpDouble, dpDouble, dpDouble, dpFactory, dpFloat, dpFloat, dpFloat, dpInitialization, dpInitialization, dpInitialize, dpInt, dpInt, dpInt, dpLong, dpLong, dpLong, dpReset, dpShort, dpShort, dpShort, dpString, dpString, dpString, dpTermination, dpValue, dpValue, dpValue, getDatapool, setCurrentdp, setDatapool, storeDatapool, unsetDatapool |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final TestObject ANY
ScriptCommandFlags
with an explicit anchor value.
public static final java.lang.Object[] DEFAULT_ARGS
Constructor Detail |
---|
public RationalTestScript()
RationalTestScript
object.
Method Detail |
---|
public static float getVersion()
protected void setScriptName(java.lang.String scriptName)
public java.lang.String getScriptName()
public IScriptDefinition getScriptDefinition()
ScriptDefinition
interface.
Used internally.
public boolean isMainScript()
true
if the currently executing script is the top-level
(main) script, that is, not called by callScript
.
public RationalTestScript getScriptCaller()
callScript
.
If isMainScript
, null
is returned.
If the script is not being run, null
is returned.
public java.lang.Object[] getScriptArgs()
testMain
.
public static RationalTestScript getTopScript()
public static java.lang.String getTopScriptName()
Used internally.
public static int getTopScriptLineNumber()
public static ITestProject getCurrentProject()
public static ITestProject getProject(java.lang.String name)
name
.
If more then one project with the specified name
is
registered then the first encountered is returned. If the specified
name
does not exist or can not be located then a
RationalTestException
is thrown.
public static ITestProject getProjectByLocation(java.lang.String projectDirectory)
projectDirectory
.
If the specified projectDirectory
folder is not a valid
project, does not exist or can not be located then a
RationalTestException
is thrown.
protected java.lang.Object callScript(java.lang.String scriptFullName)
runMain
method on the
script. Calling the testMain
method directly can cause
the script to behave erratically.
scriptFullName
- the full Java name of the script, including any
leading package specification
Example:
callScript("com.acme.kaBoom1");
String s = (String)callScript("com.acme.KaBoom1");
protected java.lang.Object callScript(java.lang.String scriptFullName, java.lang.Object[] args)
runMain
method on the
script. Calling the testMain
method directly can cause
the script to behave erratically.
scriptFullName
- the full Java name of the script, including any
leading package specificationargs
- the command-line arguments intended for this
script, which include any localized overrides
to the set of options that the script runs with
Example:
callScript("com.acme.BigTrap", new Object[] {new Integer(2), "Get'im!"});
String s = (String)callScript("com.acme.BiggerTrap", new Object[] {"Bait"});
protected java.lang.Object callScript(java.lang.String scriptFullName, java.lang.Object[] args, int iterationCount)
runMain
method on the
script. Calling the testMain
method directly can cause
the script to behave erratically.
scriptFullName
- the full Java name of the script, including any
leading package specification
Example:
callScript("com.acme.kaBoom1");
String s = (String)callScript("com.acme.KaBoom1");
protected java.lang.Object callScript(RationalTestScript script)
runMain
method on the
script. Calling the testMain
method directly can cause
the script to behave erratically.
script
- the script object that is to be executedprotected java.lang.Object callScript(RationalTestScript script, java.lang.Object[] args)
runMain
method on the
script. Calling the testMain
method directly can cause
the script to behave erratically.
script
- the script object that is to be executed
args
- the command-line arguments intended for this
script, which include any localized overrides
to the set of options with which the script runs
protected java.lang.Object callScript(RationalTestScript script, java.lang.Object[] args, int iterationCount)
runMain
method on the
script. Calling the testMain
method directly can cause
the script to behave erratically.
script
- the script object that is to be executed
args
- the command-line arguments intended for this
script, which include any localized overrides
to the set of options with which the script runs
public static java.lang.String trimStackTrace(java.lang.String stackTrace)
public int getLineNumber()
protected int getLineNumber(java.lang.String className)
className
is currently executing, the return value is 0.
If more than one method belonging to the specified className
is currently executing, the most deeply nested method is used, whether or not the line number information is available for this
method.
public java.lang.Object runMain(java.lang.Object[] args)
args
- the command-line arguments intended for this
script, which include any localized overrides
to the set of options with which the script runspublic java.lang.Object runMain(java.lang.Object[] args, int iterationCount, java.lang.String methodName)
public java.lang.Object runMain(java.lang.Object[] args, java.lang.String methodName)
public java.lang.Object runMain(java.lang.Object[] args, java.lang.String methodName, java.lang.Object datapool, java.lang.Object iterator)
public java.lang.Object runMain(java.lang.Object[] args, int iterationCount)
runMain
and iterates over the script
for the specified number of times.
args
- the command-line arguments intended for this
script, which include any localized overrides
to the set of options the script runs withiterationCount
- Determines the number of times the script
executed. If a datapool is associated with the
script the iterator is incremented each time through.public static void logException(java.lang.Throwable e)
public void onAmbiguousRecognition(ITestObjectMethodState testObjectMethodState, TestObject[] choices, int[] scores)
ObjectManager
if the ObjectManager
is looking for
a TestObject
to invoke a method on and it finds more than one object
that matches the description of the MappedTestObject
in the
TestObject
.
If this event is not handled and the testObjectMethodState
is not modified, an AmbiguousRecognitionException
is thrown.
Override this method to handle the event. Do not call this method directly.
onAmbiguousRecognition
in interface IObjectManagerEventListener
testObjectMethodState
- an interface used to query and modify
the state of the TestObject
method
that the ObjectManager
was trying to
invoke
choices
- an array of the ambiguous TestObjects
. The best
match, that is, the one with the lowest score, is first.
score
- an array of scores. A score of zero is best, and larger scores indicate a worse match. The array
of scores lines up with the choices
.IObjectManagerEventListener
public boolean onCallScriptException(java.lang.RuntimeException e)
callScript
command raised an exception.
A return value of true
causes the exception to be ignored.
By default, the exception propagates to the caller of this script.
This event is raised by an error when finding or constructing the script or
when the script is successfully called and
an exception occurs.
Override this method to handle the event. Do not call this method directly.
e
- the exception that occurs during the call to callScript
public com.ibm.rational.test.ft.extensions.ISimplifiedTestScriptAction getSimplifiedAction()
public EList getVisualScriptTestElements()
public void onInitialize()
testMain
method is called.
If an exception is thrown in the onInitialize
method, the script calls onUnhandledException
and then
onTerminate
.
Override this method to handle the event; do not call this method directly.
public void onObjectNotFound(ITestObjectMethodState testObjectMethodState)
TestObject
that matches the description of the
MappedTestObject
in the
method cannot be found.
If this event is not handled and the testObjectMethodState
is not modified, an ObjectNotFoundException
is thrown.
Override this method to handle the event; do not call this method directly.
onObjectNotFound
in interface IObjectManagerEventListener
testObjectMethodState
- an interface used to query and modify
the state of the TestObject
method
that the ObjectManager
is trying to
invokeIObjectManagerEventListener
public void onRecognitionWarning(ITestObjectMethodState testObjectMethodState, TestObject foundObject, int score)
ObjectManager
when an object is found and the
recognition score is above the warning threshold (rt.recognition_threshold_warning
).
onRecognitionWarning
is only called once per TestObject
method call. It is called before the
method is invoked. If the method throws a SubitemNotFoundException
or any other
exception that causes the method to be called again, onRecognitionWarning
is not called again.
Override this method to handle the event. Do not call this method directly.
onRecognitionWarning
in interface IObjectManagerEventListener
testObjectMethodState
- the state of the test object method
foundObject
- the object used when the exception occurs
score
- the numeric recognition score. A score of 0 is best, and a larger score is worse.
ITestObjectMethodState
public void onRun(ProcessTestObject process)
startApp
, startBrowser
, and run
.
If an exception is thrown in the onRun
method, the
script calls OnUnhandlerException
You should override this method to handle the event. You should not call this method directly.
process
- the process that was startedpublic void onSubitemNotFound(ITestObjectMethodState testObjectMethodState, TestObject foundObject, java.lang.String subitemDescription)
ObjectManager
when a subitem cannot be
found.
Override this method to handle the event. Do not call this method directly.
onSubitemNotFound
in interface IObjectManagerEventListener
testObjectMethodState
- the state of the test object method
foundObject
- the object used in the method invocation when the
exception occurred
subitemDescription
- the description of the subitem (from the SubitemNotFoundException)
ITestObjectMethodState
public void onTerminate()
testMain
method returns.
If an exception is thrown from onTerminate
, the newly
thrown exception terminates the script. The onUnhandledException
method is not called for exceptions thrown from onTerminate
. Throwing an
exception from onTerminate
causes a warning to be logged.
Override this method to handle the event; do not call this method directly.
public void onTestObjectMethodException(ITestObjectMethodState testObjectMethodState, TestObject testObject)
ObjectManager
when it is invoking
a method on a TestObject
and an exception is thrown from the method.
If this event is not handled and the testObjectMethodState
is not modified, a RationalTestException
is thrown.
By default, warnings are suppressed for any click method where the object under test disappears.
Disappearance is expected in most cases.
Override this method to handle the event; do not call this method directly.
onTestObjectMethodException
in interface IObjectManagerEventListener
testObjectMethodState
- an interface used to query and modify
the state of the TestObject
method
that the ObjectManager
is trying to
invoke
testObject
- the TestObject
that was found and whose method was
called
IObjectManagerEventListener
public boolean onUnhandledException(java.lang.Throwable e)
runMain
method whenever a Throwable
exception
is thrown from the testMain
method.
If onUnhandledException
returns false
, the default exception
handling behavior is used.
The default behavior is to log the Throwable
exception and to propagate a
RationalTestScriptException
for a throwable exception that extends either
java.lang.Exception
or a RationalTestScriptError
for a throwable exception that extends
java.lang.Error
.
If onUnhandledException
returns true
, the regular exception
handling does not occur, and the exception is not logged or propagated.
The script terminates normally, and onTerminate
is called.
If a Throwable
is thrown in onUnhandledException
, this new Throwable
terminates the script. onUnhandledException
is not called for an exception
thrown from onTerminate
.
Override this method to handle the event. Do not call this method directly.
e
- the unhandled exceptionpublic void onVpFailure(IFtVerificationPoint vp)
IFtVerificationPoint
implementation when the
specified verification point fails to compare successfully. The default
implementation of this event handler performs no actions. You may choose
to override the default implementation and throw an exception to terminate
script execution on verification point failure.
Override this method to handle the event. Do not call this method directly.
onVpFailure
in interface IObjectManagerEventListener
vp
- the verification point object that fails to compare successfullypublic static java.lang.Object getOption(java.lang.String name)
IOptionName
.
Example:
Object mouseDelay = getOption(IOptionName.DELAY_BEFORE_MOUSE_DOWN);
public static void resetOption(java.lang.String name)
IOptionName
.
Example:
resetOption(IOptionName.DELAY_BEFORE_KEY_DOWN);
public static void setOption(java.lang.String name, java.lang.Object value)
Object
value. See IOptionName
.
public static void setOption(java.lang.String name, int value)
int
value. See IOptionName
.
public static void setOption(java.lang.String name, long value)
long
value. See IOptionName
.
public static void setOption(java.lang.String name, float value)
float
value. See IOptionName
.
public static void setOption(java.lang.String name, double value)
double
value. See IOptionName
.
public static void setOption(java.lang.String name, boolean value)
boolean
value. See IOptionName
.
public static void logError(java.lang.String note)
note
- the description of the error
Example:
catch (Exception e)
{logError("Exception e = "+e.toString();)}
public static void logError(java.lang.String note, java.awt.image.BufferedImage snapshot)
note
- the description of the errorsnapshot
- a snapshot to include in the log entry (note: not supported by TestManager logging)
Example:
catch (Exception e)
{logError("Exception e = "+e.toString(), getRootTestObject().getScreenSnapshot());}
public static void logWarning(java.lang.String note)
note
- the description of the warning
Example:
logWarning("Warning message goes here.");
public static void logWarning(java.lang.String note, java.awt.image.BufferedImage snapshot)
note
- the description of the warningsnapshot
- a snapshot to include in the log entry (note: not supported by TestManager logging)
Example:
logWarning("Warning message goes here.", getRootTestObject().getScreenSnapshot());
public static void logInfo(java.lang.String note)
note
- the informational message
Example:
logInfo("AWT button is not enabled.");
public static void logInfo(java.lang.String note, java.awt.image.BufferedImage snapshot)
note
- the informational messagesnapshot
- a snapshot to include in the log entry (note: not supported by TestManager logging)
Example:
logInfo("AWT button is not enabled.", getRootTestObject().getScreenSnapshot());
public static void logTestResult(java.lang.String headline, boolean passed, java.lang.String additionalInfo)
headline
- the headline describing the test
passed
- the result of the test, where true
indicates a pass and false
indicates
a failure
additionalInfo
- additional information about the test
For example:
logTestResult("Text buffer comparison", true, "The text strings are identical.")
public static void logTestResult(java.lang.String headline, boolean passed)
headline
- the headline describing the test
passed
- the result of the test, where true
indicates a Pass and false
indicates
a failure
For example:
LogTestResult("Text buffer comparison", TextField_text.equals(msExpect));
public static void timerStart(java.lang.String timerName)
timerStart(timerName)
and timerStop(timerName)
is
written to the log when timerStop() is called.
timerName
- the name of the timer
Example:
timerStart("timer1");
public static void timerStop(java.lang.String timerName)
timerStart(timerName)
and timerStop(timerName)
is
written to the log.
timerName
- the name of the timer
timerStop("timer1");
public static double getTimerValue(java.lang.String timerName)
timerStart(timerName)
and getTimer(timerName)
in seconds.
timerName
- the name of the timer
getTimerValue("timer1");
public static double stopTimer(java.lang.String timerName)
timerStart(timerName)
and stopTimer(timerName)
in seconds.
The interval is written into the log.
timerName
- the name of the timer
stopTimer("timer1");
public static void stop()
UserStoppedScriptError
.
public void dpNext()
DatapoolScriptSupport.dpNext()
to
allow for incrementing the script iteration count.
dpNext
in class DatapoolScriptSupport
DatapoolScriptSupport.dpNext()
public static IClipboard getSystemClipboard()
clipboard
interface provides access to text available from a clipboard. Also exposed
is the ability to perform a directed verification point. Note that the
verification point support supplied requires the existence of a baseline
VP. Scripting of verification points for the clipboard can more easily
utilize the vpManual
method combined with
the clipboard text wrapped in a test data
object.
For example:
vpManual("cliptest", VpUtil.getTestData(getSystemClipboard().getText()));
performs a verification point against the active clipboard text, creating the
baseline data the first time the script is executed.
protected IFtVerificationPoint vp(java.lang.String vpName)
performTest
can be executed. This verification point format
is generated automatically when a verification point is inserted at record time.
See IFtVerificationPoint
for information on verification point limitations
regarding names and data format.
vpName
- the verification point's unique name
IFtVerificationPoint
verification point objectprotected IFtVerificationPoint vp(java.lang.String vpName, TestObject anchor)
performTest
can be executed. This verification point format
is generated automatically when a verification point is inserted at record time.
The anchor
TestObject
is used to find all TestObjects referenced by the baseline
data. The anchor is significant when differentiating between common objects that may
arise simultaneously in different inheritance hierarchies. For example, if two browsers
are raised at the same time, you may have to anchor the verification point to a particular page
to differentiate between common controls in the two browsers.
Refer to IFtVerificationPoint
for information on limitations on verification point
names and data format.
vpName
- the verification point's unique nameanchor
- the reference to the TestObject
context
IFtVerificationPoint
verification point objectprotected IFtVerificationPoint vpManual(java.lang.String vpName, java.lang.Object actual)
performTest
can be executed.
This verification point form has several unique characteristics:
TestObject
in the way that static or dynamic verification points can
automatically create the data.
performTest
method logs an informational
message only (not pass or fail) when constructing a baseline file.
performTest
method is
executed.
performTest
persists the supplied data
regardless of the outcome of the test. Therefore, it must be an object based on the Value
class
that can be persisted and compared.
Refer to IFtVerificationPoint
for information on restrictions on verification point
names and data format. Refer to VpUtil
for utility methods that can be used to
create mode interesting data formats from existing data.
vpName
- the script-relative verification point, which must be unique
actual
- the actual data to be compared to an existing baseline or used
to create a baseline if one does not already exist
IFtVerificationPoint
verification point objectVpUtil
protected IFtVerificationPoint vpManual(java.lang.String vpName, java.lang.Object expected, java.lang.Object actual)
performTest
can be executed.
This verification point form has several unique characteristics:
TestObject
in the way that static or dynamic verification points can
automatically create the data.
performTest
to act upon.
performTest
persists the supplied data
regardless of the outcome of the test. Therefore, it must be an object based on the Value
that can be persisted and compared.
Refer to IFtVerificationPoint
for information on restrictions on verification point
names and data format. Refer to VpUtil
for utility methods that can be used to
create more interesting data formats from existing data.
vpName
- the script-relative verification point, which must be unique
expected
- the expected data that is compared to the supplied actual
data
actual
- the actual data that is compared to the supplied expected
data
IFtVerificationPoint
verification point objectVpUtil
protected IFtVerificationPoint vpDynamic(java.lang.String vpName)
performTest
the next time that a script is played
back. This method allows the script developer to insert a verification point in an insert-recording
manner without having to drive the software under test to the appropriate state
before recording the verification point.
This verification point form has several unique characteristics:
performTest
is run against this verification point relative to this script. Subsequent
runs use the baseline data generated by the initial execution.
-rt.interactive true
option must be specified when running from the command
line while initially creating the baseline data.
Refer to IFtVerificationPoint
for information on restrictions on verification point
names and data format.
vpName
- the script-relative verification point name, which must be unique
IFtVerificationPoint
verification point objectprotected IFtVerificationPoint vpDynamic(java.lang.String vpName, TestObject objectUnderTest)
performTest
the next time that a script is played
back. This method allows the script developer to insert a verification point against a specific
TestObject
located directly by a script developer. This object does not need to be available
in the object map or through the normal TestObject
hierarchy.
This verification point form has several unique characteristics:
TestObject
does not have to be an object from the object map, it
must consistently be the same TestObject
for consistent results to be perceived.
performTest
is run against this verification point relative to this script. Subsequent
runs use the baseline data generated by the initial execution.
TestObject
and
does not allow gathering of properties for child TestObjects
. This means that there is one data object
against the one supplied TestObject
.
-rt.interactive true
option must be specified when running from the command
line for initial creation of the baseline data.
Refer to IFtVerificationPoint
for information on restrictions on verification point
names and data format.
vpName
- the script-relative verification point, which must be unique
objectUnderTest
- the TestObject
that is used in performTest
IFtVerificationPoint
verification point objectpublic com.rational.test.ft.object.map.ObjectMap getMap(java.lang.String id)
public com.rational.test.ft.object.map.ObjectMap getMap()
public com.rational.test.ft.object.map.SpyMappedTestObject getMappedTestObject(java.lang.String testObjectName)
IScriptDefinition
interface to the appropriate node in the object map. This node can be
used to locate the associated object in the software under test.
testObjectName
- the script-specific unique name for an object in
the associated object mappublic static java.lang.String[] getJVMs()
public static boolean isJVMDefined(java.lang.String jvmName)
true
if the specified JVM name has been defined
by the Enabler.
jvmName
- the name of a JVM defined in the Enablerpublic static java.lang.String getCurrentJVM()
setCurrentJVM
has been called, the default is this
value; otherwise, the default is the value set in
the Enabler.
If no default JVM has been set in the Enabler, null
is returned.
setCurrentJVM(String)
public static void setCurrentJVM(java.lang.String jvmName)
Note: If a Java application has specified a JVM in the Application Configuration Tool, that JVM is used, not the value set here.
jvmName
- the name of a JVM defined in the Enabler or
null, which clears the current JVM. The
default is whatever is set in the Enabler.
Example:
setCurrentJVM("JRE 1.4")
getCurrentJVM()
public static java.lang.String[] getBrowsers()
public static boolean isBrowserDefined(java.lang.String browserName)
true
if the specified browser name has been defined by the Enabler.
browserName
- the name of a browser defined in the Enablerpublic static java.lang.String getCurrentBrowser()
setCurrentBrowser
has been called, the default is this
value. Otherwise, the default is the value set in
the Enabler.
If no default browser has been set in the Enabler,
null
is returned.
setCurrentBrowser(String)
public static void setCurrentBrowser(java.lang.String browserName)
If an HTML application has specified a browser in the Application Configuration Tool, that browser is used, not the value set here.
browserName
- the name of a browser defined in the Enabler or
null
, which clears the current browser. The
default is whatever is set in the Enabler.
Example:
setCurrentBrowser("InternetExplorer");
getCurrentBrowser()
public static java.lang.String[] getApplications()
public static boolean isApplicationDefined(java.lang.String applicationName)
true
if the specified application has been defined
in the configuration file.
jvmName
- the name of a JVM defined in the Enablerpublic static IOperatingSystem getOperatingSystem()
public static void sleep(double seconds)
sleep (5.0);
public static java.lang.String getenv(java.lang.String name)
public static void setenv(java.lang.String name, java.lang.String value)
public static void unsetenv(java.lang.String name)
public static ProcessTestObject run(java.lang.String command, java.lang.String workingDirectory)
null
, the script's
working directory is used.
command
- the command line to execute
workingDirectory
- the directory that the command should use as its
execution contextpublic static ProcessTestObject runJava(java.lang.String main, java.lang.String classpath, java.lang.String workingDirectory, java.lang.String jvm, java.lang.String jvmOptions)
main
- the full Java class name of the class to be run.
Package and class names must be included.
classpath
- Specifies the classpath that is
used to run the main class. If this
argument is null
, the system classpath
environment variable is used.
workingDirectory
- the directory that the command uses as its
execution context
jvm
- the JVM that is used to execute the
main class
jvmOptions
- JVM-specific options
public static ProcessTestObject startApp(java.lang.String symbolicName)
startApp
method differs from run
and runJava
.
The application name is a logical name that is looked up
in the configurations.rftcfg
file so that it can be mapped to the actual details
about how to run the application. For example, the configuration file
might specify the location of
the executable file or the location of the main class for Java programs.
In this way, testers can avoid hard coding details, which may vary
from one test machine to another.
symbolicName
- the logical name of the application, as specified
in the user's configurations.rftcfg
file
Example:
startApp("ClassicsA");
public static ProcessTestObject startApp(java.lang.String symbolicName, java.lang.String[] args)
startApp
method differs from
run
and runJava
.
The application name is a logical name that is looked up
in the configurations.rftcfg
file so that it can be mapped to the actual details
about how to run the application. For example, the configuration file
can specify the location of
the executable file or the location of the main class for Java programs.
In this way, testers can avoid hard coding details, which may vary
from one test machine to another.
symbolicName
- the logical name of the application, as specified
in the user's configurations.rftcfg
file
args[]
- arguments to pass to the application being startedpublic static ProcessTestObject startBrowser(java.lang.String url)
url
- the web page to be displayed
startBrowser("www.rational.com");
public static ProcessTestObject startBrowser(java.lang.String browserName, java.lang.String url)
browsername
- the logical name of the browser as specified in the user's
>configurations.rftcfg
fileurl
- the web page to be displayed
Example:
startBrowser("InternetExplorer", "www.rational.com");
public static boolean shellExecute(java.lang.String fileName)
ShellExecute
. This is not implemented on UNIX.
fileName
- the file to pass to ShellExecute
true
if ShellExecute
succeeds; false
otherwise
Example:
shellExecute("C:\\WINNT\\Notepad.exe");
public static RootTestObject getRootTestObject()
RootTestObject
public static GuiTestObject objectAtPoint(java.awt.Point screenPt)
GuiTestObject
for the object at the screen location.
public static DomainTestObject[] getDomains()
DomainTestObjects
do not need to be unregistered.
If there are no domains (an unlikely situation), a 0-length array is returned.
public static IScreen getScreen()
public static IWindow[] getTopWindows()
IWindows
. IWindow
provides access to the native
windowing layer. This is provided to allow scripting a solution for
various situations. This method is never recorded.
Any script that uses this method is probably platform specific.
If there are no top windows (an unlikely situation), a 0-length array is returned.
public static TestObject[] find(Subitem properties)
atProperty
- A name/value pair representing a TestObject
property.
atChild
- One or more properties that must be matched
against the direct child of the starting TestObject
.
atDescendant
- One or more properties that can be matched
against any child of the starting TestObject
.
atList
- A sequential list of properties to match against.
atList
valid subitems are atChild
, atDescendant
, and atProperty
.
The first list item will be matched against to get a list of candidates,
and out of those candidates their descendants will be matched against for the next
list item, and so on.
There are special properties that apply to a RootTestObject find. These include:
.processName
- As a toplevel property this has two functions:
to dynamically enable the processes with that processName for testing..processId
- As a toplevel property this has two functions:
to dynamically enable the processes with that process id (pid) for testing..domain
- Only search in toplevel domains matching the .domain property
.hWnd
- along with the hWnd property being used for the search, if the .domain
"Win" is also specified the matching window will be enabled for testing.
Handle
- along with the window handle property being used for the search, if the .domain
"Net" is also specified the matching window will be enabled for testing.
Examples:
TestObject[] foundTOs ;
RootTestObject root = RootTestObject.getRootTestObject() ;
// This will find all toplevel windows in the Windows domain with caption "My Document"
CaptionText caption = new CaptionText("My Document") ;
foundTOs = root.find(atChild(".domain", "Win", ".caption", caption)) ;
// This will find any dialogs, then return their children "OK" buttons.
RegularExpression dialogRE = new RegularExpression("*dialog", false) ;
RegularExpression buttonRE = new RegularExpression("*button", false) ;
foundTOs = root.find(atList(atDescendant(".class", dialogRE), atChild(".class", buttonRE, ".value", "OK"))) ;
// This will start Notepad, dynamically enable that process, find its toplevel window that
// matches the process id and get its descendant text window.
ProcessTestObject p1 = StartApp("Notepad") ;
Integer pid = new Integer((int)p1.getProcessId()) ;
foundTOs = root.find(atList(atProperty(".processId", pid, atDescendant(".class", ".text"))) ;
// This enables a Windows app with the provided window handle and returns a
// TestObject representing the window.
Long hWnd = getAppsHwnd();
foundTOs = root.find(atChild(".hwnd", hWnd, ".domain", "Win"));
// This enables a .NET app with the provided window handle and returns a
// TestObject representing the window.
Long handle = getAppsHwnd();
foundTOs = root.find(atChild("Handle", handle, ".domain", "Net"));
properties
- the property set to match against#unregister()
,
unregister(Object[])
,
unregisterAll()
,
getRegisteredTestObjects()
public static TestObject[] find(Subitem properties, boolean mappableOnly)
atProperty
- A name/value pair representing a TestObject property.
atChild
- Contains one or more properties that must be matched
against the direct child of the starting TestObject.
atDescendant
- Contains one or more properties that can be matched
against any child of the starting TestObject.
atList
- Used to specify a sequential list of properties to match against.
AtList valid subitems are atChild
, atDescendant
, and atProperty
.
The first list item will be matched against to get a list of candidates,
and out of those candidates their descendants will be matched against for the next
list item, and so on.
There are special properties that apply to a RootTestObject find. These include:
.processName
- As a toplevel property this has two functions:
to dynamically enable the processes with that processName for testing.
to constrain the find to only look in processes with that name.
.processId
- As a toplevel property this has two functions:
to dynamically enable the processes with that process id (pid) for testing.
to constrain the find to only look in processes with that process id (pid).
.domain
- Only search in toplevel domains matching the .domain property
.hWnd
- along with the hWnd property being used for the search, if the .domain
"Win" is also specified the matching window will be enabled for testing.
Handle
- along with the window handle property being used for the search, if the .domain
"Net" is also specified the matching window will be enabled for testing.
Examples:
TestObject[] foundTOs ;
RootTestObject root = RootTestObject.getRootTestObject() ;
// This will find all toplevel windows in the Windows domain with caption "My Document"
CaptionText caption = new CaptionText("My Document") ;
foundTOs = root.find(atChild(".domain", "Win", ".caption", caption)) ;
// This will find any dialogs, then return their children "OK" buttons.
RegularExpression dialogRE = new RegularExpression("*dialog", false) ;
RegularExpression buttonRE = New RegularExpression("*button", false) ;
foundTOs = root.find(atList(atDescendant(".class", dialogRE), atChild(".class", buttonRE, ".value", "OK"))) ;
// This will start Notepad, dynamically enable that process, find its toplevel window that
// matches the process id and get its descendant text window.
ProcessTestObject p1 = StartApp("Notepad") ;
Integer pid = new Integer((int)p1.getProcessId()) ;
foundTOs = root.find(atList(atProperty(".processId", pid, atDescendant(".class", ".text"))) ;
// This enables a Windows app with the provided window handle and returns a
// TestObject representing the window.
Long hWnd = getAppsHwnd();
foundTOs = root.find(atChild(".hwnd", hWnd, ".domain", "Win"));
// This enables a .NET app with the provided window handle and returns a
// TestObject representing the window.
Long handle = getAppsHwnd();
foundTOs = root.find(atChild("Handle", handle, ".domain", "Net"));
properties
- the property set to match against.mappableOnly
- whether to search all children or just mappable children#unregister()
,
unregister(Object[])
,
unregisterAll()
,
getRegisteredTestObjects()
public static void unregisterAll()
TestObjects
for this client.
TestObject.unregister()
,
unregister(Object[])
,
getRegisteredTestObjects()
public static void unregister(java.lang.Object[] testObjects)
TestObjects
for this client.
TestObject.unregister()
,
unregisterAll()
,
getRegisteredTestObjects()
public static TestObject[] getRegisteredTestObjects()
TestObjects
for this client. If
no TestObjects have been registered for this client, it returns a 0-length
array.
Many TestObjects
provide access to objects
in the software under test, and these objects are generally
in a different process. If a method is called on such a
TestObject
and the object returned by the method can be
recreated in the process of the script, the object
is considered a value class. If the object returned by the method cannot
be recreated in the script process, the script is given
an object that provides remote access to the object in the software under test.
This remote object has to be explicitly unregistered.
TestObject.unregister()
,
unregister(Object[])
,
unregisterAll()
public void cleanup()
public static void derefAll()
public static boolean downloadProjectFiles(java.lang.String[] projectRelativeFiles)
projectRelativeFileList
- The list of Project files to download to remote machine
public int setCurrentLogFilter(int filterLevel)
filterLevel
- The new filter level. The value could be one of the following.
DISABLE_LOGGING The filter level for logging to disable all logging
LOG_FAILURES The filter level for logging to log all failures.
LOG_FAILURES_WARNINGS The filter level for logging to log all failures and warnings
LOG_FAILURES_WARNINGS_PASS The filter level for logging to log all failures, warnings and pass results
LOG_FAILURES_WARNINGS_PASS_INFO The filter level for logging to log all.
LOG_ENABLE_GUI_ACTION The filter level to log all GUI actions.
LOG_DISABLE_GUI_ACTION The filter level to disable logging of all GUI Actions.
public int getCurrentScriptIterationCount()
public void setSimplifiedScriptLine(int line)
line
- public int getSimplifiedScriptLine()
public void setDatapool(java.lang.String datapoolName, boolean shared, int iterationCount)
datapoolName
- The datapool name (eg "dp1")shared
- Set to true if the datapool is shared, false otherwise.iterationCount
- The datapool iteration count, used mainly for simplified script, otherwise can be any value as user need to take care of interation manually in the script.
Example:
setDatapool("Script3.dp2",false,3);
for (int i=0; i<3; i++)
{
password().click(atPoint(40,14));
password().setText(dpString("Password"));
nameCombo().select(dpString("nameCombo"));
dpNext();
}
unsetDatapool();
DatapoolScriptSupport.unsetDatapool()
public void setInvocationTimeout(long timeout)
timeout
- in Milliseconds
Example:
setInvocationTimeout(30000)
: This will set the InvocationTimeout to 30 seconds
public void resetInvocationTimeout()
setInvocationTimeout(long)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |