The suntest.javastar.lib.JS
class contains static functions for playback scripts to use. The constructor for this class is private.
This section describes JS
by:
java.lang.object
 suntest.javastar.lib.JS
public class JS
extends Object
Variables | Description |
---|---|
public static PrintStream log | This PrintStream will be attached to the on-screen terminal and the error-logging file when a script is playing. |
This section provides two ways to view methods. You can use:
If you are viewing this documentation on-line, you can click on any method name to jump to the full description, syntax, and parameter specification.
Method | Category | Description |
---|---|---|
applet (String, int)
|
Find methods | Finds an applet matching the type and position you specify. |
check(boolean)
|
Comparison methods |
Checks the boolean you pass and reports true or false based on the comparison.
|
check(boolean, String)
|
Comparison methods |
Checks the boolean variable you pass and reports true or false based on the comparison. Includes the String when writing to the log.
|
check(Script, boolean)
|
Comparison methods |
Checks the boolean and reports true or false based on the comparison.
|
check(Script, boolean, String)
|
Comparison methods |
Checks the boolean passed and reports true or false based on the comparison. Includes the String when writing to the log.
|
delay(long)
|
Script control/ convenience methods | Requests a delay in milliseconds. |
deliverEventToHidden(boolean)
|
Script control/ convenience methods | Allows events to be sent to hidden or disabled Components. |
dialog(String, String)
|
Find methods | Finds all dialog windows exactly matching the type and title you specify. |
dialogRE(String, String)
|
Find methods | Finds all dialog windows matching the type and title you specify. The title supports regular expressions. |
dialogRX(String, String)
|
Deprecated methods | Finds all dialog windows matching the type and title you specify. |
find(String, String)
|
Find methods | Finds all frames exactly matching the type and title you specify. |
findRE(String, String)
|
Find methods | Finds all frames exactly matching the type and title you specify. The title supports regular expressions. |
findRX(String, String)
|
Deprecated methods | Finds all frames exactly matching the type and title you specify. The title supports regular expressions. |
flushEventQueue()
|
Comparison methods | Flushes any pending playback events and flushes the system event queue. |
frame(String)
|
Find methods | Finds all frames exactly matching the title you provide. |
frameRE(String)
|
Find methods | Finds all frames with a title matching the regular expression you specify. |
frameRX(String)
|
Deprecated methods | Finds all frames with a title matching the regular expression you specify. |
getProperty(String)
|
Get/Set methods | Reads the JavaStar test property of name and returns the value for the key. |
getTimeout()
|
Get/Set methods | Returns the current timeout value (in seconds). |
getTypingRate()
|
Get/Set methods | Returns the current typing rate (milliseconds per character). |
goldenDirectory(String, String)
|
Deprecated methods | Returns the name of the gold file directory for the specified script. |
lookup(String)
|
Find methods | Finds all named components matching the name you provide. |
mlookup(String)
|
Find methods |
Finds all MenuComponents matching the name you provide.
|
note(String)
|
Script control/ convenience methods | Enters a note into the log. |
pause()
|
Script control/ convenience methods | Inserts a breakpoint into your script. |
playbackEnd(String, boolean)
|
Deprecated methods | Terminates script playback. |
playbackEnd(String, Throwable)
|
Deprecated methods | Terminates playback of a script and throws an exception. |
playbackInit(String)
|
Deprecated methods | Performs initialization to allow playback. |
postEvent(AWTEvent)
|
Script control/ convenience methods | Posts an event to the system EventQueue. |
processPlayerArgs(String)
|
Deprecated methods | Adjusts the arguments to a playback script. |
setProperty(String, String)
|
Get/Set methods | Sets the JavaStar test property. |
setTimeout(int)
|
Get/Set methods | Increases the timeout value in seconds. |
setTypingRate(int)
|
Get/Set methods | Sets the typing rate. |
startApplication(Script)
|
Deprecated methods | Starts the application under test. |
verifyAnyField(Script, boolean, boolean, Object String, Object, String)
|
Comparison methods | Reads a data member on the contained Component and compares this against the expected value. |
verifyAnyMethod(Script, boolean, boolean, Object, String, Object, String)
|
Comparison methods | Calls the method name() of thisObj and compares against the expected value. |
waitFor(Waiting)
|
Comparison methods |
Executes a custom synchronization. Used in combination with the user-implemented Waiting interface.
|
wrap(Component)
|
Script control/ convenience methods |
Wraps the given Component in a JSComponent .
|
Category | Method | Description |
---|---|---|
Comparison methods These methods compare the state of components. Comparison methods include verify and synchronization methods, a custom synchronization method, and simple check methods. |
check(boolean)
|
Checks the boolean you pass and reports true or false based on the comparison.
|
check(boolean, String)
|
Checks the boolean variable you pass and reports true or false based on the comparison. Includes the String when writing to the log.
|
|
check(Script, boolean)
|
Checks the boolean and reports true or false based on the comparison.
|
|
check(Script, boolean, String)
|
Checks the boolean passed and reports true or false based on the comparison. Includes the String when writing to the log.
|
|
verifyAnyField(Script, boolean, boolean, Object String, Object, String)
|
Reads a data member on the contained Component and compares this against the expected value. | |
verifyAnyMethod(Script, boolean, boolean, Object, String, Object, String)
|
Calls the method name() of thisObj and compares against the expected value. | |
waitFor(Waiting)
|
Executes a custom synchronization. Used in combination with the user-implemented Waiting interface.
|
|
Deprecated methods These methods will be phased out of JavaStar in the future, but are included in this release to support scripts written with earlier versions of the JavaStar library. See Deprecated Methods in the API Overview for more details. |
dialogRX(String, String)
|
Finds all dialog windows matching the type and title you specify. |
findRX(String, String)
|
Finds all frames exactly matching the type and title you specify. The title supports regular expressions. | |
frameRX(String)
|
Finds all frames with a title matching the regular expression you specify. | |
goldenDirectory(String, String)
|
Returns the name of the gold file directory for the specified script. | |
playbackEnd(String, boolean)
|
Terminates script playback. | |
playbackEnd(String, Throwable)
|
Terminates playback of a script and throws an exception. | |
playbackInit(String)
|
Performs initialization to allow playback. | |
processPlayerArgs(String)
|
Adjusts the arguments to a playback script. | |
startApplication(Script)
|
Starts the application under test. | |
Find methods
These methods locate and return JSComponent or JSMenuComponent . according to your specifications.
|
applet (String, int)
|
Finds an applet matching the type and position you specify. |
dialog(String, String)
|
Finds all dialog windows exactly matching the type and title you specify. | |
dialogRE(String, String)
|
Finds all dialog windows matching the type and title you specify. The title supports regular expressions. | |
find(String, String)
|
Finds all frames exactly matching the type and title you specify. | |
findRE(String, String)
|
Finds all frames exactly matching the type and title you specify. The title supports regular expressions. | |
frame(String)
|
Finds all frames exactly matching the title you provide. | |
frameRE(String)
|
Finds all frames with a title matching the regular expression you specify. | |
lookup(String)
|
Finds all named components matching the name you provide. | |
mlookup(String)
|
Finds all MenuComponents matching the name you provide.
|
|
Get/Set methods These methods provide a way to get and set the values of certain data members. |
getProperty(String)
|
Reads the JavaStar test property of name and returns the value for the key. |
getTimeout()
|
Returns the current timeout value (in seconds). | |
getTypingRate()
|
Returns the current typing rate (milliseconds per character). | |
setProperty(String, String)
|
Sets the JavaStar test property. | |
setTimeout(int)
|
Increases the timeout value in seconds. | |
setTypingRate(int)
|
Sets the typing rate. | |
Script control/ convenience methods These methods provide ways you can control your script--for example, inserting breakpoints or boolean checks. |
delay(long)
|
Requests a delay in milliseconds. |
deliverEventToHidden(boolean)
|
Allows events to be sent to hidden or disabled Components. | |
flushEventQueue()
|
Flushes any pending playback events and flushes the system event queue. | |
note(String)
|
Enters a note into the log. | |
pause()
|
Inserts a breakpoint into your script. | |
postEvent(AWTEvent)
|
Posts an event to the system EventQueue. | |
wrap(Component)
|
Wraps the given Component in a JSComponent .
|
public static void delay(long ms)
Script control and convenience methods
Request a delay of ms milliseconds. This value may be ignored or scaled at runtime.
public static void deliverEventToHidden(boolean deliver)
Script control and convenience methods
If called with true
, this method allows events to be sent to hidden or disabled Components for the duration of the script or until called with false
.
true
, allow events to hidden; if false
, do not.
public static void flushEventQueue()
Script control and convenience methods
Flushes any pending playback events and flushes the system event queue.
public static void note(String c)
Script control and convenience methods
Enters the String c in the log. Use to provide additional debugging information.
public static void pause()
Script control and convenience methods
Forces the script to pause during playback. Use this to insert a breakpoint into your test.
public static void postEvent(AWTEvent evt)
Script control and convenience methods
Posts an event to the system EventQueue. postEvent()
is shorthand for Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(evt);
.
public static JSComponent wrap(Component comp)
Script control and convenience methods
Wraps the given Component in a JSComponent
. Returns a JSComponent
containing only comp (getUnique()==comp
).
public static JSComponent applet(String type, int position)
Find methods
Finds an Applet matching type exactly; normally position is 0; If there is more than one applet of the same type, the position will disambiguate them.
public static JSComponent dialog(String type, String title)
Find methods
Finds all dialogs matching the type and title exactly. Returns a JSComponent
containing all matches.
public static JSComponent dialogRE(String type, String expression)
Find methods
Finds all dialogs matching type exactly and title matching regular expression. Returns a JSComponent
containing all matches. For syntax, see Current Syntax in the chapter "Syntax for Regular Expressions."
public static JSComponent find(String type, String title)
Find methods
Finds all frames matching type and title exactly. Returns a JSComponent
containing all matches.
public static JSComponent findRE(String type, String expression)
Find methods
Finds all frames matching type exactly and title matching regular expression. Returns a JSComponent
containing all matches. For syntax, see Current Syntax in the chapter "Syntax for Regular Expressions."
public static JSComponent frame(String title)
Find methods
Finds all frames matching title exactly. Returns a JSComponent
containing all matches.
public static JSComponent frameRE(String expression)
Find methods
Finds all frames with title matching regular expression. Returns a JSComponent
containing all matches. For syntax, see Current Syntax in the chapter "Syntax for Regular Expressions."
public static JSComponent lookup(String name)
Find methods
Finds all Named components with a matching name (return of the getName()
method). Returns a JSComponent
containing all matches.
Use '.' as a scope operator. JS.lookup(
"A.B
")
is equivalent to JS.lookup(
"A
").lookup(
"B
")
. '#' must be used to escape '.'
public static JSMenuComponent mlookup(String name)
Find methods
Finds all MenuComponents with a matching name (return of the getName()
method). Returns a JSMenuComponent
containing all matches.
Use '.' as a scope operator. JS.mlookup(
"A.B
")
is equivalent to JS.mlookup(
"A
").mlookup(
"B
")
. Returns a JSMenuComponent
containing all matches. '#' must be used to escape '.'
public static String getProperty(String name)
Get/Set methods
Reads the JavaStar test property of name and returns the value for the key. If the property is not defined, this returns null.
public static void setProperty(String name, String value)
Get/Set methods
Sets the JavaStar test property of name to value.
public static int getTimeout()
Get/Set methods
Returns the current timeout value (in seconds).
public static void setTimeout(int secs)
Get/Set methods
Increases the timeout value to secs. If the setting requested is less than the current timeout value, this has no effect.
public static int getTypingRate()
Get/Set methods
Returns the current typing rate (milliseconds per character).
public static void setTypingRate(int ms)
Get/Set methods
Sets the current typing rate to ms.
public static boolean check(boolean b)
Comparison methods.
Checks the boolean variable you pass and reports true
or false
to the log based on the comparison. Includes the String when writing to the log. Returns the value of b. Use this to insert non-GUI checks into your test.
public static boolean check(boolean b, String s)
Comparison methods
Checks the boolean and reports true
or false
to the log (and includes the String s). Returns the value of b. Use this to insert non-GUI checks into your test.
public static boolean check(Script sc, boolean b)
Comparison methods
Checks the boolean and reports true
or false
to the log based on the comparison. Returns the value of b. Use this to insert non-GUI checks into your test.
public static boolean check(Script sc, boolean b, String s)
Comparison methods
Checks the boolean and reports true or false to the log (including the String s) based on the comparison results. Returns the value of b. Use this to insert non-GUI checks into your test.
public static boolean verifyAnyField(Script sc, boolean sync, boolean retry, Object thisObj, String name, Object expected, String purpose)
Comparison methods
Reads the data member name on the contained Component and compares this against the expected value. Returns true
or false
depending on the comparison results.
public static boolean verifyAnyMethod(Script sc, boolean sync, boolean retry, Object thisObj, String name, Object expected, String purpose)
Comparison methods
Calls the method name() of thisObj and compares against the expected value. Returns true
or false
depending on the comparison results.
public static void waitFor(Waiting wait)
Comparison methods
Use this method to perform custom synchronizations--waitFor()
waits for the Waiting
object's getState()
function to return true
, or for the timeout to expire. You must implement the Waiting
class to define the wait condition. If the timeout expires, this method throws a GUINotAcceptingException
.
true
public static JSComponent dialogRX(String type, String expression)
Deprecated methods
Replaced by dialogRE(String, String).
Finds all dialogs matching type exactly and with the title matching regular expression (see the chapter "Syntax for Regular Expressions."). Returns a JSComponent
containing all matches.
public static JSComponent findRX(String type, String expression)
Deprecated methods
Replaced by findRE(String, String).
Finds all frames matching type exactly and title matching regular expression (see the chapter "Syntax for Regular Expressions."). Returns a JSComponent
containing all matches.
public static JSComponent frameRX(String expression)
Deprecated methods
Replaced by frameRE(String).
Finds all frames with title matching regular expression (see the chapter "Syntax for Regular Expressions."). Returns a JSComponent
containing all matches.
public static String goldDirectory(String name, String defaultValue)
Deprecated methods
This method is no longer useful.
Returns the name of the gold file directory for the specified script. If there is no setting for the directory, this method sets playback to use defaultValue.
public static void playbackEnd(String name, boolean norm)
Deprecated methods
This method is no longer useful.
Terminates a playback script. If processPlayerArgs()
included "-exit
", this calls System.exit()
and does not return. This is used by a standalone Script's main method.
public static void playbackEnd(String name, Throwable exc)
Deprecated methods
This method is no longer useful.
Terminates a playback script. If processPlayerArgs()
included "-exit
", this calls System.exit()
and does not return. This is used by a standalone Script's main method.
public static void playbackInit(String name) throws IOException
Deprecated methods
This method is no longer useful.
Performs initialization to allow playback. Sets up the Record/Playback GUI and the log stream. This is used by the standalone Script's main method.
public static String[] processPlayerArgs(String args[])
Deprecated methods
This method is no longer useful.
Adjusts the arguments to a playback script, accepting arguments of the form:
[-exit] [-scale double] [-timeout integer] [-log file] [-gold directory] [-v] [-out]
This is used by the standalone Script's main method. Returns the arguments after stripping the leading arguments that JavaStar uses.
public static void startApplication(Script sc)
Deprecated methods
This method is no longer useful.
Starts the application under test with the appropriate reporting. This will call the run method of the script.
Send feedback to
JavaStar-feedback@suntest.com
Copyright © 1998
Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, CA 94303.
All rights reserved.