com.rational.test.ft.script

Class RationalTestScript

    • Field Detail

      • ANY

        public static final TestObject ANY
        Acts as the default anchor object for script commands that use specific ScriptCommandFlags with an explicit anchor value.
        Since:
        RFT1.0
      • DEFAULT_ARGS

        public static final java.lang.Object[] DEFAULT_ARGS
        Acts as the default arguments object for callScript commands.
        Since:
        RFT2.0
    • Constructor Detail

      • RationalTestScript

        public RationalTestScript()
        Constructs a RationalTestScript object.
        Since:
        RFT1.0
    • Method Detail

      • resetTOCreationUnregisterCounts

        public void resetTOCreationUnregisterCounts()
      • updateTOCreationCount

        public void updateTOCreationCount(int count)
      • updateTOUnregisterCount

        public void updateTOUnregisterCount(int count)
      • getVersion

        public static float getVersion()
        Returns the version number of the runtime (not for an individual script).
        Since:
        RFT1.1
      • setScriptName

        protected void setScriptName(java.lang.String scriptName)
        For internal use only.
        Since:
        RFT1.0
      • getScriptName

        public java.lang.String getScriptName()
        Returns the script name. Used internally.
        Since:
        RFT1.0
      • getScriptDefinition

        public IScriptDefinition getScriptDefinition()
        Returns the ScriptDefinition interface. Used internally.
        Since:
        RFT1.0
      • isMainScript

        public boolean isMainScript()
        Returns true if the currently executing script is the top-level (main) script, that is, not called by callScript.
        Since:
        RFT1.0
      • getScriptCaller

        public RationalTestScript getScriptCaller()
        Returns the script that called this script using callScript. If isMainScript, null is returned. If the script is not being run, null is returned.
        Since:
        RFT1.1
      • getScriptArgs

        public java.lang.Object[] getScriptArgs()
        Returns the arguments passed to the script testMain.
        Since:
        RFT1.1
      • getTopScript

        public static RationalTestScript getTopScript()
        Returns the currently executing script at the top of the call stack.
        Since:
        RFT1.1
      • getTopScriptName

        public static java.lang.String getTopScriptName()
        Returns the name of the currently executing script at the top of the call stack. This method is used by the logging code to log the script name.

        Used internally.

        Since:
        RFT1.0
      • getTopScriptLineNumber

        public 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. This method is used by the logging code to log the script line number. Used internally.
        Since:
        RFT1.0
      • getCurrentProject

        public static ITestProject getCurrentProject()
        Locate the active project object relative to the current script.
      • getProject

        public static ITestProject getProject(java.lang.String name)
        Locate the registered project with the specified 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.
      • getProjectByLocation

        public static ITestProject getProjectByLocation(java.lang.String projectDirectory)
        Locate the project at the specified projectDirectory. If the specified projectDirectory folder is not a valid project, does not exist or can not be located then a RationalTestException is thrown.
      • callScript

        protected java.lang.Object callScript(java.lang.String scriptFullName)
        Constructs the specified script and invokes the runMain method on the script. Calling the testMain method directly can cause the script to behave erratically.
        Parameters:
        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");

        Since:
        RFT1.0
      • callScript

        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. Calling the testMain method directly can cause the script to behave erratically.
        Parameters:
        scriptFullName - the full Java name of the script, including any leading package specification
        args - 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"});

        Since:
        RFT1.0
      • callScript

        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. Calling the testMain method directly can cause the script to behave erratically.
        Parameters:
        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");

        Since:
        RFT1.0
      • callScript

        protected java.lang.Object callScript(RationalTestScript script)
        Constructs the specified script and invokes the runMain method on the script. Calling the testMain method directly can cause the script to behave erratically.
        Parameters:
        script - the script object that is to be executed
        Since:
        RFT1.0
      • callScript

        protected java.lang.Object callScript(RationalTestScript script,
                                              java.lang.Object[] args)
        Constructs the specified script and invokes the runMain method on the script. Calling the testMain method directly can cause the script to behave erratically.
        Parameters:
        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

        Since:
        RFT1.0
      • callScript

        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. Calling the testMain method directly can cause the script to behave erratically.
        Parameters:
        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

        Since:
        RFT1.0
      • trimStackTrace

        public static java.lang.String trimStackTrace(java.lang.String stackTrace)
      • getLineNumber

        public int getLineNumber()
        Returns the line number of the method (in the source code) if a method belonging to this script is currently executing. If either the code was compiled without debugging information, the JIT has compiled this code, or no method belonging to this script is currently executing, the return value is 0. If more than one method belonging to this script is currently executing, the most deeply nested method for this script is used, regardless of whether line-number information is available for this method.
        Since:
        RFT1.0
      • getLineNumber

        protected int getLineNumber(java.lang.String className)
        Returns the line number of the method (in the source code). If the code was compiled without debugging information, and if the JIT has compiled this code, or if no method belonging to the specified className is currently executing, the return value is 0. If more than one method belonging to the specified classNameis currently executing, the most deeply nested method is used, whether or not the line number information is available for this method.
        Since:
        RFT1.0
      • runMain

        public java.lang.Object runMain(java.lang.Object[] args)
        Handles script initialization, termination, and exceptions. This method is the primary interface method for a script. This method also registers the script with the execution log, and it updates the execution monitor. If you do not use this method to execute a script, unexpected results can occur.
        Parameters:
        args - the command-line arguments intended for this script, which include any localized overrides to the set of options with which the script runs
        Since:
        RFT1.0
      • runMain

        public 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.
      • runMain

        public java.lang.Object runMain(com.ibm.rational.test.ft.tools.interfaces.ICommandLineParams cliParms)
      • runMain

        public java.lang.Object runMain(java.lang.Object[] args,
                                        java.lang.String methodName)
      • runMain

        public java.lang.Object runMain(java.lang.Object[] args,
                                        java.lang.String methodName,
                                        java.lang.Object datapool,
                                        java.lang.Object iterator)
      • runMain

        public 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.
        Parameters:
        args - the command-line arguments intended for this script, which include any localized overrides to the set of options the script runs with
        iterationCount - Determines the number of times the script executed. If a datapool is associated with the script the iterator is incremented each time through.
        Since:
        RFT2.0
      • logException

        public static void logException(java.lang.Throwable e)
      • onAmbiguousRecognition

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

        Specified by:
        onAmbiguousRecognition in interface IObjectManagerEventListener
        Parameters:
        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.
        Since:
        RFT1.0
        See Also:
        IObjectManagerEventListener
      • onCallScriptException

        public boolean onCallScriptException(java.lang.RuntimeException e)
        Indicates that a 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.
        Parameters:
        e - the exception that occurs during the call to callScript
        Since:
        RFT1.0
      • getSimplifiedAction

        public com.ibm.rational.test.ft.extensions.ISimplifiedTestScriptAction getSimplifiedAction()
      • getVisualScriptTestElements

        public org.eclipse.emf.common.util.EList getVisualScriptTestElements()
      • onInitialize

        public void onInitialize()
        Called automatically at the start of every script, before the script's 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.

        Since:
        RFT1.0
      • onRecognitionWarning

        public 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).

        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.

        Specified by:
        onRecognitionWarning in interface IObjectManagerEventListener
        Parameters:
        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.

        Since:
        RFT1.0
        See Also:
        ITestObjectMethodState
      • onRun

        public void onRun(ProcessTestObject process)
        Called automatically after a process is spawned from RationalTestScript. This includes 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.

        Parameters:
        process - the process that was started
        Since:
        RFT2.0
      • onSubitemNotFound

        public void onSubitemNotFound(ITestObjectMethodState testObjectMethodState,
                                      TestObject foundObject,
                                      java.lang.String subitemDescription)
        Called by the ObjectManager when a subitem cannot be found.

        Override this method to handle the event. Do not call this method directly.

        Specified by:
        onSubitemNotFound in interface IObjectManagerEventListener
        Parameters:
        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)

        Since:
        RFT1.0
        See Also:
        ITestObjectMethodState
      • onTerminate

        public void onTerminate()
        Called automatically at the end of every script, after the script's 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.

        Since:
        RFT1.0
      • onTestObjectMethodException

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

        Specified by:
        onTestObjectMethodException in interface IObjectManagerEventListener
        Parameters:
        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

        Since:
        RFT1.0
        See Also:
        IObjectManagerEventListener
      • onUnhandledException

        public boolean onUnhandledException(java.lang.Throwable e)
        Called by the 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.

        Parameters:
        e - the unhandled exception
        Since:
        RFT1.0
      • onVpFailure

        public void onVpFailure(IFtVerificationPoint vp)
        Called by the 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.

        Specified by:
        onVpFailure in interface IObjectManagerEventListener
        Parameters:
        vp - the verification point object that fails to compare successfully
        Since:
        RFT1.0
      • getOption

        public static java.lang.Object getOption(java.lang.String name)
        Returns an option value. See IOptionName.

        Example:
        Object mouseDelay = getOption(IOptionName.DELAY_BEFORE_MOUSE_DOWN);

        Since:
        RFT1.0
      • resetOption

        public static void resetOption(java.lang.String name)
        Resets an option to its default value. See IOptionName.

        Example:
        resetOption(IOptionName.DELAY_BEFORE_KEY_DOWN);

        Since:
        RFT1.0
      • setOption

        public static void setOption(java.lang.String name,
                                     java.lang.Object value)
        Sets an option to an Objectvalue. See IOptionName.
        Since:
        RFT1.0
      • setOption

        public static void setOption(java.lang.String name,
                                     int value)
        Sets an option to an int value. See IOptionName.
        Since:
        RFT1.0
      • setOption

        public static void setOption(java.lang.String name,
                                     long value)
        Sets an option to a long value. See IOptionName.
        Since:
        RFT1.0
      • setOption

        public static void setOption(java.lang.String name,
                                     float value)
        Sets an option to a float value. See IOptionName.
        Since:
        RFT1.0
      • setOption

        public static void setOption(java.lang.String name,
                                     double value)
        Sets an option to a double value. See IOptionName.
        Since:
        RFT1.0
      • setOption

        public static void setOption(java.lang.String name,
                                     boolean value)
        Sets an option to a boolean value. See IOptionName.
        Since:
        RFT1.0
      • logError

        public static void logError(java.lang.String note)
        Logs an error.
        Parameters:
        note - the description of the error

        Example:
        catch (Exception e) {logError("Exception e = "+e.toString();)}

        Since:
        RFT1.0
      • logError

        public static void logError(java.lang.String note,
                                    java.awt.image.BufferedImage snapshot)
        Logs an error that includes a screen snapshot.
        Parameters:
        note - the description of the error
        snapshot - a snapshot to include in the log entry

        Example:
        catch (Exception e) {logError("Exception e = "+e.toString(), getRootTestObject().getScreenSnapshot());}

        Since:
        RFT2.1
      • logWarning

        public static void logWarning(java.lang.String note)
        Logs a warning.
        Parameters:
        note - the description of the warning

        Example:
        logWarning("Warning message goes here.");

        Since:
        RFT1.0
      • logWarning

        public static void logWarning(java.lang.String note,
                                      java.awt.image.BufferedImage snapshot)
        Logs a warning that includes a screen snapshot.
        Parameters:
        note - the description of the warning
        snapshot - a snapshot to include in the log entry

        Example:
        logWarning("Warning message goes here.", getRootTestObject().getScreenSnapshot());

        Since:
        RFT2.1
      • logInfo

        public static void logInfo(java.lang.String note)
        Logs an informational message.
        Parameters:
        note - the informational message

        Example:
        logInfo("AWT button is not enabled.");

        Since:
        RFT1.0
      • logInfo

        public static void logInfo(java.lang.String note,
                                   java.awt.image.BufferedImage snapshot)
        Logs an informational message that includes a screen snapshot.
        Parameters:
        note - the informational message
        snapshot - a snapshot to include in the log entry

        Example:
        logInfo("AWT button is not enabled.", getRootTestObject().getScreenSnapshot());

        Since:
        RFT2.1
      • logTestResult

        public static void logTestResult(java.lang.String headline,
                                         boolean passed,
                                         java.lang.String additionalInfo)
        Logs a test result.
        Parameters:
        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.")

        Since:
        RFT1.0
      • logTestResult

        public static void logTestResult(java.lang.String headline,
                                         boolean passed)
        Logs a test result.
        Parameters:
        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));

        Since:
        RFT1.0
      • timerStart

        public static void timerStart(java.lang.String timerName)
        Starts a timer and writes information in the log. The interval between timerStart(timerName) and timerStop(timerName) is written to the log when timerStop() is called.
        Parameters:
        timerName - the name of the timer

        Example:
        timerStart("timer1");

        Since:
        RFT1.0
      • timerStop

        public static void timerStop(java.lang.String timerName)
        Stops a timer. The interval between timerStart(timerName) and timerStop(timerName) is written to the log.
        Parameters:
        timerName - the name of the timer

        timerStop("timer1");

        Since:
        RFT1.0
      • getTimerValue

        public static double getTimerValue(java.lang.String timerName)
        Get the timer value Returns the interval between timerStart(timerName) and getTimer(timerName) in seconds.
        Parameters:
        timerName - the name of the timer
        Returns:
        timerValue the value of the timer

        getTimerValue("timer1");

        Since:
        RFT8.1
      • stopTimer

        public 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. The interval is written into the log.
        Parameters:
        timerName - the name of the timer
        Returns:
        timerValue the value of the timer

        stopTimer("timer1");

        Since:
        RFT8.1
      • getSystemClipboard

        public static IClipboard getSystemClipboard()
        Supplies access to the system clipboard. The 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.

        Returns:
        access to the system clipboard text
      • vp

        protected IFtVerificationPoint vp(java.lang.String vpName)
        Constructs a static verification point object. Static verification points require that the baseline data already exists before 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.

        Parameters:
        vpName - the verification point's unique name
        Returns:
        A IFtVerificationPoint verification point object
        Since:
        RFT1.0
      • vp

        protected IFtVerificationPoint vp(java.lang.String vpName,
                                          TestObject anchor)
        Constructs a static verification point object. Static verification points require that the baseline data already exists before 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.

        Parameters:
        vpName - the verification point's unique name
        anchor - the reference to the TestObject context
        Returns:
        A IFtVerificationPoint verification point object
        Since:
        RFT1.0
      • vpManual

        protected IFtVerificationPoint vpManual(java.lang.String vpName,
                                                java.lang.Object actual)
        Constructs a manual verification point object. Manual verification points require that the user supply any necessary data before performTest can be executed.

        This verification point form has several unique characteristics:

        • This verification point must be inserted by a script developer. It is not a record-time capability. The data is managed directly by the script developer and is not extracted from a TestObject in the way that static or dynamic verification points can automatically create the data.

        • If a baseline version of the data does not already exist from a previous playback, the actual data is used to create a baseline for subsequent script executions. The performTest method logs an informational message only (not pass or fail) when constructing a baseline file.

        • As the baseline is not created until the first time the script is executed, if you are using ClearCase change management, you should run the script before checking it in. If you check the script in before running it, this verification point baseline will not be checked in.

        • If a baseline exists, the actual data is compared to the initial baseline of the data when the 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.

        • The script developer is responsible for supplying a script-relative unique name for any single instance of these verification points. Reusing a verification point name commonly causes false negative results to occur because the incorrect data is tested.

        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.

        Parameters:
        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

        Returns:
        A IFtVerificationPoint verification point object
        Since:
        RFT1.0
        See Also:
        VpUtil
      • vpManual

        protected IFtVerificationPoint vpManual(java.lang.String vpName,
                                                java.lang.Object expected,
                                                java.lang.Object actual)
        Constructs a manual verification point object. Manual verification points require that the user supply any necessary data before performTest can be executed.

        This verification point form has several unique characteristics:

        • This verification point must be inserted by a script developer and is not a record-time capability. The data is managed directly by the script developer and is not extracted from a TestObject in the way that static or dynamic verification points can automatically create the data.

        • There is no baseline version of this data associated with a script. The script developer supplies both the expected and actual data for 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.

        • The script developer is responsible for supplying a script-relative unique name for any single instance of these verification points. Reusing a verification point name commonly causes false negative results to occur because the incorrect data is tested.

        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.

        Parameters:
        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

        Returns:
        A IFtVerificationPoint verification point object
        Since:
        RFT1.0
        See Also:
        VpUtil
      • vpDynamic

        protected IFtVerificationPoint vpDynamic(java.lang.String vpName)
        Constructs a dynamic verification point object. Dynamic verification points raise an appropriate record-style UI so that the verification point can be constructed by 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:

        • This verification point must be inserted by a script developer and is not a record-time capability.

        • The record-style UI is raised the first time that performTest is run against this verification point relative to this script. Subsequent runs use the baseline data generated by the initial execution.

        • The script artifacts and associated object map must be able to be edited when the baseline version of the verification point is executed.

        • The script must be run in interactive mode for a record-style UI to be displayed. Scripts are automatically run in interactive mode when run from the IDE. However, the -rt.interactive true option must be specified when running from the command line while initially creating the baseline data.

        • As the baseline is not created until the first time the script is executed, if you are using ClearCase change management, you should run the script before checking it in. If you check the script in before running it, this verification point baseline will not be checked in.

        • The script developer is responsible for supplying a script-relative unique name for any single instance of these verification points. Reusing a verification point name commonly causes false negative results to occur because the incorrect data is tested.

        Refer to IFtVerificationPoint for information on restrictions on verification point names and data format.

        Parameters:
        vpName - the script-relative verification point name, which must be unique

        Returns:
        A IFtVerificationPoint verification point object
        Since:
        RFT1.0
      • vpDynamic

        protected IFtVerificationPoint vpDynamic(java.lang.String vpName,
                                                 TestObject objectUnderTest)
        Constructs a dynamic verification point object. Dynamic verification points raise an appropriate record-style UI so that the verification point can be constructed by 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:

        • This verification point must be inserted by a script developer and is not a record-time capability.

        • While the supplied 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.

        • The record-style UI is raised the first time that performTest is run against this verification point relative to this script. Subsequent runs use the baseline data generated by the initial execution.

        • The raised UI only allows creation of data relative to the specified TestObject and does not allow gathering of properties for child TestObjects. This means that there is one data object against the one supplied TestObject.

        • The script developer is responsible for supplying a script-relative unique name for any single instance of these verification points. Reusing a verification point name commonly causes false negative results to occur because the incorrect data is tested.

        • As the baseline is not created until the first time the script is executed, if you are using ClearCase change management, you should run the script before checking it in. If you check the script in before running it, this verification point baseline will not be checked in.

        • The script must be run in interactive mode for a record-style UI to be displayed. Scripts are automatically run in interactive mode when run from the IDE. However, the -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.

        Parameters:
        vpName - the script-relative verification point, which must be unique

        objectUnderTest - the TestObject that is used in performTest

        Returns:
        An IFtVerificationPoint verification point object
        Since:
        RFT1.0
      • getMap

        public ObjectMap getMap(java.lang.String id)
      • getMap

        public ObjectMap getMap()
        Returns the object map associated with the script.
        Since:
        RFT1.0
      • getMappedTestObject

        public 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. The identifier is mapped through the 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.
        Parameters:
        testObjectName - the script-specific unique name for an object in the associated object map
        Since:
        RFT1.0
      • getJVMs

        public static java.lang.String[] getJVMs()
        Returns an array of the JVM names defined in the Enabler.
        Returns:
        an array of JVM names; returns a 0-length array of Strings if no JVM names have been defined in the Enabler
        Since:
        RFT1.0
      • isJVMDefined

        public static boolean isJVMDefined(java.lang.String jvmName)
        Returns true if the specified JVM name has been defined by the Enabler.
        Parameters:
        jvmName - the name of a JVM defined in the Enabler
        Since:
        RFT1.0
      • getCurrentJVM

        public static java.lang.String getCurrentJVM()
        Returns the default JVM. If 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.
        Since:
        RFT1.0
        See Also:
        setCurrentJVM(String)
      • setCurrentJVM

        public static void setCurrentJVM(java.lang.String jvmName)
        Sets the default JVM for testing Java applications. This will override the default set in the Enabler.

        Note: If a Java application has specified a JVM in the Application Configuration Tool, that JVM is used, not the value set here.

        Parameters:
        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")

        Since:
        RFT1.0
        See Also:
        getCurrentJVM()
      • getBrowsers

        public static java.lang.String[] getBrowsers()
        Returns an array of the browser names defined in the Enabler.
        Returns:
        An array of browser names; returns a 0-length array of Strings if no browser names have been defined in the Enabler
        Since:
        RFT1.0
      • isBrowserDefined

        public static boolean isBrowserDefined(java.lang.String browserName)
        Returns true if the specified browser name has been defined by the Enabler.
        Parameters:
        browserName - the name of a browser defined in the Enabler
        Since:
        RFT1.0
      • getCurrentBrowser

        public static java.lang.String getCurrentBrowser()
        Returns the default browser. If 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.
        Since:
        RFT1.0
        See Also:
        setCurrentBrowser(String)
      • setCurrentBrowser

        public static void setCurrentBrowser(java.lang.String browserName)
        Sets the default browser for testing Java applications. This overrides the default set in the Enabler.

        Note: If an HTML application has specified a browser in the Application Configuration Tool, that browser is used, not the value set here.

        Parameters:
        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");

        Since:
        RFT1.0
        See Also:
        getCurrentBrowser()
      • getApplications

        public static java.lang.String[] getApplications()
        Returns an array of the application names defined in the configuration.
        Returns:
        An array of application names; returns a 0-length array of Strings if no application names have been defined.
        Since:
        RFT1.1
      • isApplicationDefined

        public static boolean isApplicationDefined(java.lang.String applicationName)
        Returns true if the specified application has been defined in the configuration file.
        Parameters:
        jvmName - the name of a JVM defined in the Enabler
        Since:
        RFT1.1
      • getOperatingSystem

        public static IOperatingSystem getOperatingSystem()
        Allows access to certain host-specific methods that are otherwise difficult to access.
        Returns:
        The operating system accessor object
        Since:
        RFT1.0
      • sleep

        public static void sleep(double seconds)
        Waits for the specified amount of time.

        sleep (5.0);

        Since:
        RFT1.0
      • getenv

        public static java.lang.String getenv(java.lang.String name)
        Gets the value of an environment variable.
        Since:
        RFT1.0
      • setenv

        public static void setenv(java.lang.String name,
                                  java.lang.String value)
        Sets the value of an environment variable.
        Since:
        RFT1.0
      • unsetenv

        public static void unsetenv(java.lang.String name)
        Unsets an environment variable.
        Since:
        RFT1.0
      • run

        public static ProcessTestObject run(java.lang.String command,
                                            java.lang.String workingDirectory)
        Provides the basic command-line execution functionality. The supplied command line is executed in host-specific fashion with the working directory set to the specified location. If the working directory is null, the script's working directory is used.
        Parameters:
        command - the command line to execute

        workingDirectory - the directory that the command should use as its execution context
        Since:
        RFT1.0
      • runJava

        public 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. The JVM and classpath are split out because they tend to be host specific.
        Parameters:
        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

        Since:
        RFT1.0
      • startApp

        public static ProcessTestObject startApp(java.lang.String symbolicName)
        Starts an application based on a logical name. The 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.
        Parameters:
        symbolicName - the logical name of the application, as specified in the user's configurations.rftcfg file

        Example:
        startApp("ClassicsA");

        Since:
        RFT1.0
      • startApp

        public static ProcessTestObject startApp(java.lang.String symbolicName,
                                                 java.lang.String[] args)
        Starts the software under test. The 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.
        Parameters:
        symbolicName - the logical name of the application, as specified in the user's configurations.rftcfg file

        args[] - arguments to pass to the application being started
        Since:
        RFT1.0
      • startBrowser

        public static ProcessTestObject startBrowser(java.lang.String url)
        Displays a specified URL in the browser of choice. The browser used is the default system-specific browser if not specified in the browser option.
        Parameters:
        url - the web page to be displayed

        startBrowser("www.rational.com");

        Since:
        RFT1.0
      • startBrowser

        public static ProcessTestObject startBrowser(java.lang.String browserName,
                                                     java.lang.String url)
        Displays a specified URL in the browser of choice. The browser used is specified by its logical name, as specified in the Enabler.
        Parameters:
        browsername - the logical name of the browser as specified in the user's >configurations.rftcfg file
        url - the web page to be displayed

        Example:
        startBrowser("InternetExplorer", "www.rational.com");

        Since:
        RFT1.0
      • shellExecute

        public static boolean shellExecute(java.lang.String fileName)
        Starts up the program associated with the file extension. (This is the same as double-clicking on the file from Explorer). For example, on an .htm file, this brings up your default browser. This makes use of Windows ShellExecute. This is not implemented on UNIX.
        Parameters:
        fileName - the file to pass to ShellExecute
        Returns:
        true if ShellExecute succeeds; false otherwise

        Example:
        shellExecute("C:\\WINNT\\Notepad.exe");

        Since:
        RFT1.0
      • getRootTestObject

        public static RootTestObject getRootTestObject()
        Get the RootTestObject
        Since:
        RFT2.0
      • objectAtPoint

        public static GuiTestObject objectAtPoint(java.awt.Point screenPt)
        Returns a GuiTestObject for the object at the screen location.
        Since:
        RFT1.0
      • getDomains

        public static DomainTestObject[] getDomains()
        Returns an array of all the testable domains in the system. DomainTestObjects do not need to be unregistered. If there are no domains (an unlikely situation), a 0-length array is returned.
        Since:
        RFT1.0
      • getScreen

        public static IScreen getScreen()
        Returns an interface to the screen object. 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.
        Since:
        RFT1.0
      • getTopWindows

        public static IWindow[] getTopWindows()
        Returns an array of 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.
        Since:
        RFT1.0
      • find

        public static TestObject[] find(Subitem properties)
        Finds all candidates that match given search criteria. Valid values for the property subitems are: 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.
        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"));       
                 
         
         
        Parameters:
        properties - the property set to match against
        Since:
        RFT2.0
        See Also:
        #unregister(), unregister(Object[]), unregisterAll(), getRegisteredTestObjects()
      • find

        public static TestObject[] find(Subitem properties,
                                        boolean mappableOnly)
        Finds all candidates that match given search criteria. Valid values for the property subitems are: 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"));       
        
         
         
        Parameters:
        properties - the property set to match against.
        mappableOnly - whether to search all children or just mappable children
        Since:
        RFT2.0
        See Also:
        #unregister(), unregister(Object[]), unregisterAll(), getRegisteredTestObjects()
      • getRegisteredTestObjects

        public static TestObject[] getRegisteredTestObjects()
        Returns all registered 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.

        Since:
        RFT1.0
        See Also:
        TestObject.unregister(), unregister(Object[]), unregisterAll()
      • cleanup

        public void cleanup()
        This function dereferences the object map used by this script. This function could be called if this RationalTestScript object is instantiated.
        Since:
        RFT7.0
      • derefAll

        public static void derefAll()
      • downloadProjectFiles

        public static boolean downloadProjectFiles(java.lang.String[] projectRelativeFiles)
        Download project relative files from the source machine to the remote machine. This method can be used to make the project relative external files available to Functional Tester during Remote playback only. Example: To make available the external file("C:\Foo\Project1\custom.properties") from the Functional Tester Project Directory ("C:\Foo\Project1") available to Functional Tester during remote playback. downloadProjectFiles(new String[]{"custom.properties"}); To make available the external file in a folder("C:\Foo\Project1\Custom\custom.properties") to Functional Tester downloadProjectFiles(new String[]{"Custom\\custom.properties"});
        Parameters:
        projectRelativeFileList - The list of Project files to download to remote machine
        Returns:
        true If given files successfully got downloaded to the remote machine.
      • setCurrentLogFilter

        public int setCurrentLogFilter(int filterLevel)
        Set the new logging filter for results of events
        Parameters:
        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.
        Returns:
        The last set filter level
      • getCurrentScriptIterationCount

        public int getCurrentScriptIterationCount()
        Returns the current script iteration count
        Returns:
        The Script iteraion count
        Since:
        8.0
      • setSimplifiedScriptLine

        public 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.
        Parameters:
        line -
      • getSimplifiedScriptLine

        public 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.
        Returns:
      • setDatapool

        @Deprecated
        public void setDatapool(java.lang.String datapoolName,
                                            boolean shared,
                                            int iterationCount)
        Deprecated. deprecated since v10.1.3
        RFT 8.1.1 support multiple datapools. In Simplified script a datapool can be associated with each group. This function can be used to set the datapool. Once the datapool is set, any data driven commands will be using the values from this datapool until unsetDatapool() is used. Simplified Script automatically takes care of generating the code when the datapool and the iteration count is associated with a group. If the user is manually modifying the java script then the user need to write the code for even iterating over the record in the datapool.
        Parameters:
        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(); 
          
          
        See Also:
        DatapoolScriptSupport.unsetDatapool()
      • setInvocationTimeout

        public void setInvocationTimeout(long timeout)
        Set Invocationtimeout value While playing back the Script, Functional Tester will wait for the SUT's response for the actions generated . In some cases SUT takes very long time to respond and Functional Tester will wait for the default InvocationTimeout which is predefined as two minutes. This API enable the user to handle this timeout in a more flexible way
        Parameters:
        timeout - in Milliseconds
        Since:
        RFT 8.1.1
        See Also:

        Example:
        setInvocationTimeout(30000) : This will set the InvocationTimeout to 30 seconds

      • resetInvocationTimeout

        public void resetInvocationTimeout()
        Reset Invocationtimeout value to the default. On calling this API, the InvocationTimeout value will be reset to the default value which is two minutes.
        Since:
        RFT 8.1.1
        See Also:
        setInvocationTimeout(long)
      • getVariablesManager

        public IVariablesManager getVariablesManager()
        This API returns the Variables Manager. The Variables Manager allows access to the input parameters and the output variables.
        Returns:
        The singleton instance of the IVariableManager
      • doesVariablesManagerExist

        public boolean doesVariablesManagerExist()
        This API tells whether variables manager instance is created or not
        Returns:
        true if it exists, false if it does not