Component and Control Classes: JS


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:

Inheritance

Syntax

Variables

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.

Methods

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.

Methods by Name

JS methods by name

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.

Methods by Category

JS methods by category

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.

delay(long)

Syntax

Category

Script control and convenience methods

Description

Request a delay of ms milliseconds. This value may be ignored or scaled at runtime.

Parameters

deliverEventToHidden(boolean)

Syntax

Category

Script control and convenience methods

Description

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.

Parameters

flushEventQueue()

Syntax

Category

Script control and convenience methods

Description

Flushes any pending playback events and flushes the system event queue.

note(String)

Syntax

Category

Script control and convenience methods

Description

Enters the String c in the log. Use to provide additional debugging information.

Parameters

pause()

Syntax

Category

Script control and convenience methods

Description

Forces the script to pause during playback. Use this to insert a breakpoint into your test.

postEvent(AWTEvent)

Syntax

Category

Script control and convenience methods

Description

Posts an event to the system EventQueue. postEvent() is shorthand for Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(evt);.

Parameter

wrap(Component)

Syntax

Category

Script control and convenience methods

Description

Wraps the given Component in a JSComponent. Returns a JSComponent containing only comp (getUnique()==comp).

Parameters

applet (String, int)

Syntax

Category

Find methods

Description

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.

Parameters

dialog(String, String)

Syntax

Category

Find methods

Description

Finds all dialogs matching the type and title exactly. Returns a JSComponent containing all matches.

Parameters

dialogRE(String, String)

Syntax

Category

Find methods

Description

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."

Parameters

find(String, String)

Syntax

Category

Find methods

Description

Finds all frames matching type and title exactly. Returns a JSComponent containing all matches.

Parameters

findRE(String, String)

Category

Find methods

Description

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."

Parameters

frame(String)

Syntax

Category

Find methods

Description

Finds all frames matching title exactly. Returns a JSComponent containing all matches.

Parameters

frameRE(String)

Syntax

Category

Find methods

Description

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."

Parameters

lookup(String)

Syntax

Category

Find methods

Description

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 '.'

Parameters

mlookup(String)

Syntax

Category

Find methods

Description

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 '.'

Parameters

getProperty(String)

Syntax

Category

Get/Set methods

Description

Reads the JavaStar test property of name and returns the value for the key. If the property is not defined, this returns null.

Parameters

setProperty(String, String)

Syntax

Category

Get/Set methods

Description

Sets the JavaStar test property of name to value.

Parameters

getTimeout()

Syntax

Category

Get/Set methods

Description

Returns the current timeout value (in seconds).

setTimeout(int)

Syntax

Category

Get/Set methods

Description

Increases the timeout value to secs. If the setting requested is less than the current timeout value, this has no effect.

Parameters

getTypingRate()

Syntax

Category

Get/Set methods

Description

Returns the current typing rate (milliseconds per character).

setTypingRate(int)

Syntax

Category

Get/Set methods

Description

Sets the current typing rate to ms.

Parameters

check(boolean)

Syntax

Category

Comparison methods.

Description

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.

Parameters

check(boolean, String)

Syntax

Category

Comparison methods

Description

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.

Parameters

check(Script, boolean)

Syntax

Category

Comparison methods

Description

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.

Parameters

check(Script, boolean, String)

Syntax

Category

Comparison methods

Description

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.

Parameters

verifyAnyField(Script, boolean, boolean, Object String, Object, String)

Syntax

Category

Comparison methods

Description

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.

Parameters

verifyAnyMethod(Script, boolean, boolean, Object, String, Object, String)

Syntax

Category

Comparison methods

Description

Calls the method name() of thisObj and compares against the expected value. Returns true or false depending on the comparison results.

Parameters

waitFor(Waiting)

Syntax

Category

Comparison methods

Description

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.

Parameters

dialogRX(String, String)

Syntax

Category

Deprecated methods

Description

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.

Parameters

findRX(String, String)

Syntax

Category

Deprecated methods

Description

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.

Parameters

frameRX(String)

Syntax

Category

Deprecated methods

Description

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.

Parameters

goldenDirectory(String, String)

Syntax

Category

Deprecated methods

Description

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.

Parameters

playbackEnd(String, boolean)

Syntax

Category

Deprecated methods

Description

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.

Parameters

playbackEnd(String, Throwable)

Syntax

Category

Deprecated methods

Description

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.

Parameters

playbackInit(String)

Syntax

Category

Deprecated methods

Description

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.

Parameters

processPlayerArgs(String)

Syntax

Category

Deprecated methods

Description

This method is no longer useful.

Adjusts the arguments to a playback script, accepting arguments of the form:

This is used by the standalone Script's main method. Returns the arguments after stripping the leading arguments that JavaStar uses.

Parameters

startApplication(Script)

Syntax

Category

Deprecated methods

Description

This method is no longer useful.

Starts the application under test with the appropriate reporting. This will call the run method of the script.

Parameters




Send feedback to JavaStar-feedback@suntest.com
Copyright © 1998 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, CA 94303. All rights reserved.