RTW - Functional GUI Testing - Examples

IBM.com Documentation developerWorks
Java for Rational Functional Tester Users

Thanks to contribution of "IBM Test Community". Please send me more examples or comments about this file! marc_van_lint@nl.ibm.com


  1. Introduction
  2. Learning Java (example website use Google)
  3. RFT Best practices
  4. RFT Examples
  5. Support
  6. Useful links


Please give a email when you've used this page and think it's usefull to continue: Yes (makes use of your email program).

These pages should give users of Rational Functional Tester a jumpstart in java programming. With this knowledge one can unleash the power of Rational Functional Tester by using the Java language. For example: When only using UI functions or an RRAFS, how does one close all browsers before starting a job? With some programming in RFT it's possible!
Most materials are IBM Internal, so do not distribute to customers. Pieces can be shared or sold to customers :-).

To get support please check Support
You can play with any website but also with: http://test.vanlint5.nl or our Appscan website http://altoromutual.com/

I am not the Mr Know It All on RFT. I'm just the guy who collects RFT things and put them together. So please contribute via email to Marc_van_lint@nl.ibm.com

I reuse from various sources. I can NOT verify if redistribution is granted. It might inspire to write some own code.

The examples are not 100% checked or verified. Again this is just to help, it's not yet to the level of an official document!!

RFT Best practices

Applicable for Robot, RFT and RPT. The tips are in random order and combined for recording, editing and replaying.

RFT - Tips and Examples

RFT1 - Datapool - Iteration via java

Don't use the playback wizard to indicate that you want to user datapool iterations. Enclose the second portion of your script in the following loop ( add dpNext() at the bottom of the loop):

	while( !dpDone() )
		//This is data populating to read customer records from datapool and will run multiple times
		tFrame().inputKeys("{TAB}"); // press Tab key to go data input position
		tFrame().inputChars(dpString("clientID")); //clientID

		String clientID = dpString("clientID");
		//write output file ClientID in the console
		System.out.print("clientID: ");
		tFrame().inputChars(dpString("Language")); //Lang

		dpNext(); //Move the datapool cursor to the next row

Sample CSV-file: names.csv

RFT2 - Datapool & callScript #2

One can combine various testcases in (CQ)TM into a testsuite. This way you can NOT give arguments to the calling routines. When calling the seperate routines from one 'master' program one can add intelligence and have arguments. An example is:
		callScript("ScriptB", DEFAULT_ARGS, DP_ALL);
		callScript("ScriptC", DEFAULT_ARGS, DP_ALL);
		callScript("ScriptC", DEFAULT_ARGS, 3 );

As a property of a script one can specify a random or sequential selection of the datapool rows. This is NOT possible to influence with arguments.

RFT3 - Multi Datapool

This sample script dynamically connects to two different datapools and dumps out all the datapool values:

	1.  File -> Import -> Functional Test Project Items
	2.  Point to the attached .rftjdtr file
	3.  The names of the imported scripts are "DynamicMain" and "DynamicStandardOutput"

Sorry - no script.....

RFT4 - Datapool - Row selection

Full question: Is there a way to specify only certain records in a datapool for playback? For example, if the datapool has 10 records, can we specify that RFT play back the script using only records #2, #5, and #9?

Full answer: There is no UI supported way of selecting records to use in a given datapool. Typically when users want to do this, they'll include an additional key column into the datapool. In that column store a "Yes/No" or "True/False" type value and use that to determine if a row of the datapool should be used. IE: Make the first action of your test to check the contents of the key column. If it's False or No, then skip to the end of the test. If it's Yes or True, then continue on through the test using that row of data.

The user can add a variable, say, "Flag" of the type "Boolean" and set it to true or false for each record to choose the appropriate records whose value will be used for every iteration. Inorder to ensure that the correct record is being chosen during playback, the user needs to check the value of this variable. For instance in the code below the user checks for true/false value of the variable dpBoolean("Flag") and then executed the rest of the code.

	public void testMain(Object[] args)
		if (dpBoolean("Flag"))

			// Frame: ClassicsCD
			tree2().click(atPath("Composers->Schubert->Symphonies Nos. 5 & 9"));

			// Data Driven Code inserted on Oct 18, 2005
			// Frame: Member Logon

			// Data Driven Code inserted on Oct 18, 2005
			// Frame: Place an Order


			// Frame: ClassicsCD

Attached below is the snapshot of the various records used in the Test Datapool. Here the variable "Flag" has the value "false" for record no. 3. The logic from the above code states that record values need to be used only when the value of the variable "Flag" is set to "true" Hence during playback the values used for the controls will come from record no 1, 2 and 4 and not from 3.

Use the Apply button!

RFT5 - Starting RFT

To start RFT81 from the command prompt and the log-file got a timestamp.
echo Off
Rem Set CALCTIME variable to time
Rem Alternative approach see: http://ss64.com/nt/syntax-gettime.html
Rem Remove : and , and space
Rem Add leading zeros for time before 10 oclock
Rem Take last 8 characters
Rem Take first 6 characters
"C:\Program Files\IBM\SDPRFT81\jdk\bin\java" -cp "C:\Program Files\IBM\SDPRFT81\FunctionalTester\bin\rational_ft.jar" com.rational.test.ft.rational_ft -datastore "C:\RFTPRJ\Project1" -playback "Script13" -log "RUN%CALCTIME%""C:\Program Files\IBM\SDPRFT81\jdk\bin\java" -cp "C:\Program Files\IBM\SDPRFT81\FunctionalTester\bin\rational_ft.jar" com.rational.test.ft.rational_ft -datastore "C:\SAMP\Project1" -playback "Script13" -log "RUN%CALCTIME%"

Check the documentation for
Reference > Rational Functional Tester command line interface

RFT6 - Call DOS cmd

Please read on Javaworld

import resources.BasisHelper;

import com.rational.test.ft.*;
import com.rational.test.ft.object.interfaces.*;
import com.rational.test.ft.script.*;
import com.rational.test.ft.value.*;
import com.rational.test.ft.vp.*;
import java.io.*;

 * Description   : Functional Test Script
 * @author marc_van_lint@nl.ibm.com
public class Basis extends BasisHelper
	 * Script Name   : Basis
	 * Generated	 : 6-feb-2006 14:38:30
	 * Description   : Functional Test Script
	 * Original Host : WinNT Version 5.1  Build 2600 (S)
	 * @since  2006/02/06
	 * @author marc_van_lint@nl.ibm.com
	public void testMain(Object[] args)
		String s = null;
		String DOScmd;
		DOScmd = "C:/RFTTest/CopyMF.bat";
		// DOScmd = "ping localhost";

		try {

			// run the Unix "ps -ef" command

			Process p = Runtime.getRuntime().exec(DOScmd);

			BufferedReader stdInput = new BufferedReader(new

			BufferedReader stdError = new BufferedReader(new

			// read the output from the command

			System.out.println("Here is the standard output of the command:\n");
			while ((s = stdInput.readLine()) != null) {

			// read any errors from the attempted command

			System.out.println("Here is the standard error of the command (if any):\n");
			while ((s = stdError.readLine()) != null) {

			// System.exit(0);

		} catch (IOException e) {
			System.out.println("[IOException]. Printing Stack Trace");

		// Frame: ClassicsCD
		tree2().click(atPath("Composers->Bach->Violin Concertos"));

		// Frame: Member Logon

		// Frame: Place an Order


		// Frame: ClassicsCD

The called program CopyMF.cmd
cd C:\RFTTest
copy /Y source.txt target.txt
dir > output.txt
call wait 10
An emulated wait state in XP wait.bat
@ping -n 2 -w 1000 > nul
@ping -n %1% -w 1000> nul

RFT7 - Reading Excel

If you need to read values from an Excel file, you have a few options:

  1. Save the file as plain text and use java.io to do the reading.
  2. Use the Excel COM interface to read an Excel-formatted (not plain ASCII) file. There are several java2COM solutions on the market. One open source solution I've used in the past is JAWIN: http://sourceforge.net/projects/jawinproject/

    The code you write will look something like this

    		DispatchPtr app = new DispatchPtr("RFTcel.Application");
    		app.put("Visible", true);
    		DispatchPtr workbooks = app.getObject("Workbooks");
    		DispatchPtr workbk = (DispatchPtr) workbooks.invoke("Open", "C:\\Common\\book1.xls");
    		DispatchPtr sheets = workbk.getObject("Worksheets");
    		DispatchPtr sheet = sheets.getObject("Item", new Integer(1));
    		DispatchPtr range = sheet.getObject("Range", "A2");
    		String s = (String) range.get("Value");
    		range.put("Value", "Java2COM can b");
  3. If you don't want the overhead of COM, Apache has a package for Java that essentially "hacks" the Excel file format: http://jakarta.apache.org/poi/hssf/index.html
  4. I supposed you could set up Excel as a data source and go through JDBC.
  5. There is a JXL opensource package.

RFT8 - Email from RFT

Previous source replaced by this link: More

RFT - Close Browsers before starting

Here is some Java code that I have used when closing any open Internet Explorer window. You should be able to do something similar if you are working with More browsers as well.
	public void closeBrowserAny()
		IWindow[] wins = getTopWindows();
		for (int n = 0; n < wins.length; ++n)
			if (wins[n].getWindowClassName().equals("IEFrame"))
Use MozillaUIWindowClass instead of IEFrame to close mozilla. Or closing only the old Playback logs (leaving open the usefull IE)
	public void closeBrowserAny() {
		IWindow[] wins = getTopWindows();
		for (int n = 0; n < wins.length; ++n) {
			if (wins[n].getWindowClassName().equals("IEFrame")) {
				if (wins[n].getText().substring(0,8).equals("Playback") )
Don't forget to call the closeBrowserAny() in the main program....

RFT10 - Timer #1

Down here some timer examples are given. Consider to adapt the playback preferences to a lesser check interval. This will increase CPU usage but will result in better time indications. Check for specific waitForExistence options!

The 5 seconds interval was to prove that longer intervals was resulting in a worse timing. Use 0.5 sec or even less. You might select "Skip VP" to speed up.

In the RFT course also a timer solution is given.

RFT11 - Timer #2

public void testMain(Object[] args)
		long startTime;
		long stopTime;
		long intervalTime;

		// Action to be measured takes place
		startTime = System.currentTimeMillis();

		// Response content test takes place (briefest possible to minimize timing intrusion)

		stopTime = System.currentTimeMillis();
		intervalTime = stopTime - startTime;
		logInfo("timerStub: time to do nothing - this is just a stub, you need to insert your own actions and response tests: " + intervalTime + " ms");
To store these kind of values in a flat text file you can use the following code:

	private void pushInt(String intervaltime) {
		BufferedWriter distbw = null;

			String fileName;
			String string1;
			String strTemp;
			String compURL;
			boolean append;
			String OutputDir = "C:\\";
			fileName=OutputDir + fileName;
			//Logger.log("WriteEmployee: " + file + " " + email);
			if (intervaltime!=null ) {
				boolean exists = (new File(fileName)).exists();
				if (exists) {
					// File or directory exists

				try {
					distbw = new BufferedWriter(new FileWriter(fileName,append) );
				} catch (IOException ioe2) {
					// just ignore it

				try {
					// select 1 of the following lines
					//System.out.println("PRINT *** " + strLine);
				} catch (IOException ioe) {

				try {
				} catch (IOException ioe2) {
					// just ignore it

RFT12 - Timer #3

Here will the 3736 Adv Rat Functional Tester lab. This includes timers and logging!

RFT13 - Super helper class example

See also the RFT education. Source of sample super helper class to capture an unexpected window:
 * Created on 7-jul-2006
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
package superScripts;

import com.rational.test.ft.object.interfaces.*;
import com.rational.test.ft.script.*;

public abstract class UAW extends RationalTestScript{
	public void onTestObjectMethodException(ITestObjectMethodState testObjectMethodState,
			TestObject foundObject)
		if (testObjectMethodState.getThrowableClassName().equals("com.rational.test.ft.WindowActivateFailedException"))
			IWindow activeWindow = getScreen().getActiveWindow();
			if (activeWindow !=null)
				System.out.println("Unexpected active window caption = "+activeWindow.getText());
			super.onTestObjectMethodException(testObjectMethodState, foundObject);
		super.onTestObjectMethodException(testObjectMethodState, foundObject);

More superclass code might be, string functions.
public class StringManager
	  public static string Left(string text, int length)
			return text.Substring(0, length);

	  public static string Right(string text, int length)
			return text.Substring(text.Length - length, length);

	  public static string Mid(string text, int start, int end)
			return text.Substring(start, end);

	  public static string Mid(string text, int start)
			return text.Substring(start, text.Length - start);

RFT14 - Retrieving a HTML table contents

You don't need the recorded verification point. You can get the data from the HTML table directly by calling getTestData():
Try this code out. Note: one issue you may need to think about is that of multiple instances of the same flight number. In the screenshot below, there are 2 instanaces of flight SK499. This is why I have findRowOfRadioButtonByFlightNumber return an array of ints.
To use the method, pass it a reference to the table from which you want to get fligh information.

public int[] getRowsByFlightNumber(TestObject table,String flygnr) {

ITestDataTable iTableData = (ITestDataTable) table.getTestData("contents");

int rows = iTableData.getRowCount();
int cols = iTableData.getColumnCount();
int col = 0;

Vector vRows = new Vector();
for (col = 0; col < cols; col++) {
	if (iTableData.getColumnHeader(col) != null && iTableData.getColumnHeader(col).toString().equals("Flygnr")) {
		for (int row = 1; row < rows; row++) {
			Object value = iTableData.getCell(row, col);
			if (value != null && value.toString().equals(flygnr)) {
				vRows.add(new Integer(row));

int foundRows[] = new int[vRows.size()];
for (int i = 0; i < vRows.size(); i++) {
	foundRows[i] = ((Integer) vRows.get(i)).intValue();

return foundRows;

RFT15 - Logging a screenshot

How to get screenshot captured in the RFT? There is an option in RFT that when a VP fails automatically a screen snapshot is taken. This code will be suitable for your need.

//capture the screenshot
logInfo("your message",getRootTestObject().getScreenSnapshot());

This code captures a screenshot and puts it into a HTML logfile. We can also see it as a jpeg file in Package-Explorer.

First: New in RFT 6.1.1 is the ability to take a screenshot of any object - this includes the top level HTML document...so if you did code like this:

logInfo ("My Screenshot Name",document_google().getScreenSnapshot());

you would get a screenshot in your log...though this only works for HTML logging. For a sample, select File->Import->Functional Test Project Items and select this attachment (..\Rational\Documentation\Artifacts\RFT) There is also a default setting in the playback preferences to capture a screenshot on failure now.

Second: There might be something in this devWorks article that might work for you: Works/rational/library/4927.html"> http://www-128.ibm.com/developerWorks/rational/library/4927.html

See also the RFT help - Search for "infoWarning".

  1. logInfo
  2. logWarning
  3. logError
  4. logTestResult
	logTestResult("Text buffer comparison", true);
	logTestResult("Text buffer comparison", false,
	   "Expected '"+TextField_text+"' but found '"+msExpect+"'");

RFT16 - Starting an application

Alternative way to start app without registring:


Be aware when using even a variable in these cases, you do not have a easy clue which program was started when examining the log.

RFT17 - Get the length of a data value

A sample which drops an Error when the value is not of length 7.

		String number_Text = (String)html_number(ANY,LOADED).getProperty(".text");
		int intLength = number_Text.length() ;
		if (intLength != 7) {
			logError("Ordernumber length " + intLength + " " + number_Text);

RFT18 - Clean fields before entering

Clear fields before entering by using Ctrl-A and Delete.
Or add these lines later to the script infront of the actual value! Resulting...

Note: placeAnOrder is source object.

RFT19 - Get columns of datapool

import org.eclipse.hyades.execution.runtime.datapool.IDatapool;
import org.eclipse.hyades.execution.runtime.datapool.IDatapoolIterator;

		File datapoolFile = new File( "path to datapool file" );
		IDatapool dp = dpFactory().load(datapoolFile, true);
		IDatapoolIterator dpIterator = dpFactory().open(dp, null);

		int cols = dp.getVariableCount();

		while (!dpIterator.dpDone()) {
			for (int col = 0; col < cols; col++) {
				System.out.print(dpIterator.dpString(col) + "\t");


RFT20 - Reading Clipboard

Reading of datavalues in the clipboard. Copied with Crtl-A and Ctrl-C.

import java.awt.datatransfer.*;
import java.awt.Toolkit;

public static String getClipboard()
Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);

try {
if (t != null && t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
String text = (String)t.getTransferData(DataFlavor.stringFlavor);
return text;
} catch (UnsupportedFlavorException e) {
} catch (IOException e) {
return null;

RFT21 - Accessing a URL in a HTML cell

Author: Alexander McDonald, IBM

// The main table needs to be accessible to the script
TestObject table = (table_htmlTable_1().getChildren())[0];
TestObject[] rows = table.getChildren();

// This routine looks at the first object in the first column of each row,
// looking for the text "Societa' non finanziarie". If it finds it, it clicks the link in
// the second column and stops. This is fairly straightforward since each cell
// in the table only contains the one link, if there were More HTML objects in
// the cell you might have to find the one that is the html.A class.

for(int i=0;i<rows.length;i++) {
	TestObject row = rows;
	TestObject[] columns = row.getChildren();
	TestObject[] col1 = columns[0].getChildren();
	String linktext = (String) col1[0].getProperty(".text");

	if(linktext.equals("Societa' non finanziarie")) {
	TestObject[] col_euro = columns[1].getChildren();
	GuiTestObject linktoclick = new GuiTestObject(col_euro[0]);

RFT22 - Accessing 'hidden' properties

Sometimes the value can not be retrieved from a object. Use the following to circumvent:
  1. Add a waitforExistence
    Results that the object is created in the object nav.
  2. Remove the .waitForExistence()
  3. Add the dot and scan the pop-up.

Resulting script:
String result = result_text().getText();
System.out.println("result: " + result);

For example reading the results from MS Calculator.

RFT23 - Compare files

import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.RandomAccessFile;
import java.util.Vector;

import resources.Script1Helper;

import com.rational.test.ft.*;
import com.rational.test.ft.object.interfaces.*;
import com.rational.test.ft.script.*;
import com.rational.test.ft.value.*;
import com.rational.test.ft.vp.*;

 * Description   : Functional Test Script
public class Script1 extends Script1Helper
	 * Description   : Functional Test Script
	public void testMain(Object[] args)

		File file1 = new File("C://Documents and Settings//RS1.pdf");
		File file2 = new File("C://Documents and Settings///RS2.pdf");

		// start comparing
		Vector baseline = new Vector();
		Vector actual= new Vector();

		byte[] buf = new byte[32768];

		//Read First File into Vector
		try {
			FileInputStream fin =  new FileInputStream(file1);

			int i;
			while ((i = fin.read(buf)) != -1) {
				System.out.println("BASELINE READ: " + i);
				buf = new byte[32768];

		catch (Exception e) {

		//Read Second File into Vector
		try {
			FileInputStream fin =  new FileInputStream(file2);

			int i;
			while ((i = fin.read(buf)) != -1) {
				System.out.println("ACTUAL READ: " + i);
				buf = new byte[32768];

		catch (Exception e) {

		vpManual("FileCompare", VpUtil.getTestData(baseline), VpUtil.getTestData(actual)).performTest();

	public static boolean filesAreIdentical(File left, File right) throws IOException
		assert left != null;
		assert right != null;
		assert left.exists();
		assert right.exists();

		if (left.length() != right.length())
			return false;

		FileInputStream lin = new FileInputStream(left);
		FileInputStream rin = new FileInputStream(right);
			byte[] lbuffer = new byte[4096];
			byte[] rbuffer = new byte[lbuffer.length];
			for (int lcount = 0; (lcount = lin.read(lbuffer)) > 0;)
				int bytesRead = 0;
				for (int rcount = 0; (rcount = rin.read(rbuffer, bytesRead, lcount - bytesRead)) > 0;)
					bytesRead += rcount;
				for (int byteIndex = 0; byteIndex < lcount; byteIndex++)
					if (lbuffer[byteIndex] != rbuffer[byteIndex])
						return false;
		return true;

Google provides some nice comparision libraries.

RFT24 - Movie of RFT actions

See QSE site (IBM Internal)

RFT25 - Finding objects

The example below provides some examples of how to find objects in a web page. Ofcause one can combine this finding with data from a datapool.

public class Script2 extends Script2Helper {
	 * Script Name : Script2 Generated : 24 mrt 2009 20:30:01
	 * Description : Functional Test Script Original Host : WinNT Version 5.1
	 * Build 2600 (S)
	 * @since 2009/03/24
	 * @author marc_van_lint@nl.ibm.com
	public void testMain(Object[] args) {
		// Start http://test.vanlint5.nl/car/index.html

		// Give my laptop some time to start IE and load the page...
		RootTestObject root = getRootTestObject();

		GuiTestObject o;
		TestObject[] list = root.find(atDescendant(".class", "Html.A"));
		// TestObject[] htmlpage =
		// root.find(atDescendant(".class","Html.HTMLBrowser"
		// ,".documentName","http://test.vanlint5.nl/index.html"));

		// To print out all links on the page....
		for (int i = 0; i < list.length; i++) {
			o = (GuiTestObject) list[i];

			System.out.println(o.getProperty(".text") + " "
					+ o.getProperty(".href"));

		// Take very first link
		o = (GuiTestObject) list[0];

		// to get back to previous page, do click on index.html page
		TestObject[] retrun_Back = root.find(atDescendant(".class", "Html.A",
				".href", "http://test.vanlint5.nl/car/index.html"));
		o = (GuiTestObject) retrun_Back[0];

		// Close the browser
		browser_htmlBrowser(document_htmlDocument(), MAY_EXIT).close();

RFT26 - Datapool in DB2

Datapool in DB2

RFT27 - Timing

This chapter discusses some examples how to keep your RFT and AUT in sync. This is often an area of concern. It do give problems. For example: We have a normal link which results in a message. Only the message might take a while...

Try it: Try it as a link

How to tackle this....
We have severaloptions:

  1. Hard coded sleep statements
  2. Setttings
  3. Intelligence


  1. Hard coded sleep
    When recording one can select the menu option

    And select the Insert code (which I forget often). and you get in your code:

    Advantage is, it's simple and quick. Disadvantage it truely slows down your script. Even if there is no reason for it. And 1000 times 5 seconds is nearly 1.5 hours waiting in a run.


  2. Settings
    One can play around with the wait-for settings in the Window > Preferences.


  3. Intelligence
    Add an additional wait-for-object verification point statement.

RFT28 - RFT jTree relative references

  • Rational Functional Tester JavaÆ jTree relative references

    RFT29 - Retrieve properties of a JTable cell

  • Retrieve properties of a JTable cell (or JTable itself) by using native methods on the Java domain

    RFT30 - Logfile Viewer

    To view the RFT log in IE nicely and without any security warnings, do the following settings:

    1. TOOLS
    2. Advanced
    3. Security
    4. Select "Allow active contnt to run in files on My Computer."

    RFT31 - DB Testing with SQuirrel

    Database testing with SQuirrel. SQuirreL with RFT
    Part 1 & Part 2

    Example 39 shows how to connect directly from RFT to a DB2 database.

    RFT32 - Viewer does not pop up / Applet does not load

    The error: Simply said:

    1. Install a Java version on your computer.
    2. Enable it in RFT
    3. Activate it in IE

    In more detail (but relatively old info):

    Error creating verification point display:
    An enabled JRE (1.3.1_02 or better) must be associated with the browser to view VP results.

    Check the following:

    1. A JRE v. 1.3.1_02 - 1.4.2 is installed on the computer
    2. The JRE is used as the browser plug-in
      1. Click the JAVA's plug-in icon in the Control panel
      2. Click the Advanced tab
      3. Java Plugin
        DESELECT Enable the next-generation...
    3. Make sure the JRE is enabled
        Select Configure > Enable environments from IBMÆ RationalÆ Functional Tester menu
      1. Click the Java Tab
      2. Check that the JRE is listed as enabled. In addition, highlight the JRE and click the Test button to double-check. As a precaution, search the computer's local hard drives for all instances of installed JREs. If there are any newly found JREs, it is possible that one of them is being used as the browser's plug-in. If so, enable any "likely suspects"
    4. Make sure the browser is enabled by clicking on the Browser tab of the Enable Environments tool.

    In some cases above is not enough. You have to set the Applet Support to 1 in the registry:

    RFT33 - A Reusable Testing Framework

    Check this: Using IBM Rational Functional Tester to implement a reusable testing framework
    Nice reference and examples.

    RFT34 - CRFCN0379E: Load script class failed

    How many of you have attempted to playback an RFT script (usually in front of a customer), and suddenly RFT spits out the dreaded error:
       Script Playback Failure: CRFCN0379E: Load script class failed
       [] [java.lang.ClassNotFoundException: ]
    Well, I've searched developerWorks and More
    sources and have never been able to figure out a reliable workaround ---
    UNTIL NOW.  I just talked to Dan Ch.., and he told me that this is
    a known problem with a known workaround!
       1.  Make sure "Project ->
    	Build Automatically" is NOT checked.
       2.  You may need to do "Project -> Clean" and "Project -> Build All"
    		in order to get rid of the zero-length .class files that got created
    	when "Build Automatically" was set.

    RFT35 - No RFT options in VS Studio

    If you don't see the RFT options in VS Studio/Tools make sure you have selected the show all settings.

    When properly set you get the RFT settings. If not, call support....

    RFT36 - External Features to RFT

    External Features to RFT

    RFT37 - Validating a user defined property

    RFT gives you the posibility to recognize objects based on user defined (not standard) properties.As an example here in a JSP the following line of jsp code:

    <INPUT TYPE="SUBMIT" VALUE="Convert" style="color:#FFFFFF;background-color:#008800" IBMLABEL="TOP">

    The following code finds the Submit button and prints out the value of the IBMLABEL, which is here TOP.

    		// Checking
    		RootTestObject root = getRootTestObject();
    		// The following lines do NOT WORK!
    		// TestObject[] testObject = root.find(atDescendant(".class","Html.INPUT.submit", ".value", "Convert"));
    		// 	TestObject[] testObject = root.find(atDescendant(".class","Html.INPUT.submit"));
    		// Following line works...
    		TestObject[] testObject = root.find(atDescendant(".value", "Convert"));
    		System.out.println("Objects found: " + testObject.length);
    		if (testObject.length > 0) {
    			for (int i = 0; i < testObject.length; i++) {

    RFT38 - Starting Notepad from RFT

    The following example shows how a RFT script can start Notepad to open a text-file and validate the contents. This might give some idea's to start an More application from RFT. The validation of the text file can be done best by just reading it via Java (more robuust).

    import java.awt.Desktop;
    import java.io.File;
    import resources.Script3Helper;
     * Description : Functional Test Script
     * @author Marc
    public class Script3 extends Script3Helper {
    	 * Script Name : Script3 Generated : 21 jun 2010 13:16:20
    	 * Description : Functional Test Script Original Host : WinNT Version 5.1
    	 * Build 2600 (S)
    	 * @since 2010/06/21
    	 * @author Marc
    	private Desktop desktop;
    	public void testMain(Object[] args) {
    		// TODO Insert code here
    		String fileName = "C:\\Documents and Settings\\Administrator\\My Documents\\rfttest.txt";
    		File file = new File(fileName);
    		try {
    			desktop = Desktop.getDesktop();
    		} catch (Exception ioe) {
    			// ioe.printStackTrace();
    			System.out.println("Cannot perform the given operation to the "
    					+ file + " file");
    		// Window: NOTEPAD.EXE: rfttest.txt - Notepad
    		ditIsEenTesttext().click(atPoint(543, 360));
    		rfttestTxtNotepadwindow(ANY, MAY_EXIT).click(CLOSE_BUTTON);

    RFT39 - RFT datapool in DB2

    The following link reveals a document describing the way to get data from a DB2 datapool. It's an example to accomplish this.


    See also: RFT51 - RFT - DB2

    RFT40 - File Compare

    Rational Tester - File compare

    RFT41 - RFT and PDF


    See also Example 23.

    RFT42 - Ping Host

    Based on Example 6 an elaborated example of using ping.

    Calling script:

    Object[] myargs = new Object[2];

    The Pingtest RFT (!) script:

    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import resources.PingtestHelper;
     * Description : Functional Test Script
     * @author Marc van Lint
    public class Pingtest extends PingtestHelper {
    	 * Script Name : Script1 Generated : 13 mei 2011 10:56:32
    	 * Description : Functional Test Script Original Host : WinNT Version 5.1
    	 * Build 2600 (S)
    	 * @since 2011/05/13
    	 * @author Marc
    	 * @return
    	 * Because of the RFT-log files calls it must be a RFT-script.
    	public void testMain(Object[] args) {
    		// TODO Insert code here
    		boolean retvalue = false;
    		String DOScmd = new String();
    		String s = null;
    		String val = null;
    		int ival;
    		String site = (String)args[0];
    		int number = 10;
    		if (number<3) number=3;
    		DOScmd = "ping -n "+ number +" "+site;  // Rational demo site
    		try {
    			Process p = Runtime.getRuntime().exec(DOScmd);
    			BufferedReader stdInput = new BufferedReader(new InputStreamReader(
    			BufferedReader stdError = new BufferedReader(new InputStreamReader(
    			// read the output from the command
    			System.out.println("Here is the standard output of the command:\n");
    			while ((s = stdInput.readLine()) != null) {
    				if (s.indexOf("Average") != -1) {
    					int p1 = s.lastIndexOf("=") + 2;
    					int p2 = s.lastIndexOf("ms");
    					val = s.substring(p1, p2);
    					System.out.println("Average is " + val + "ms");
    			if (val != null) {
    				ival = Integer.parseInt(val);
    				int threshold = (Integer) args[1];
    				if (ival > threshold) {
    					logInfo("Average is " + val + "ms and should be less than "+threshold);
    				} else {
    			} else {
    				logInfo("No ping available");
    			// read any errors from the attempted command
    					.println("Here is the standard error of the command (if any):\n");
    			while ((s = stdError.readLine()) != null) {
    			// System.exit(0);
    		} catch (IOException e) {
    			System.out.println("[IOException]. Printing Stack Trace");
    		logTestResult("Website "+site,retvalue);

    RFT43 - Interaction on result

    The Tomcat software has a simple jsp example of guessing the number. This script, guesses and act up on the screen output (getProperty).

    Because this is an test script, in real life I would count the numbers of guesses, if it's above 50 than the algorithm of giving hiher/lower is incorrect!

    Related customer question: What's the difference between:

    String Field_1_1_text = (String)field_1_1_4().getProperty("text");
    String Field_1_1_text  = field_1_1_4().getText();
    In this case there is no difference. Still make note that the .getProperty() and .getText() might use different software routines. Furthermore in the first example we have to cast the value to a string, but it might look better in your code when you have to get multiple properties. RFT generates the first one if you use the GUI-VP as you can see in this example.
    import resources.Script1Helper;
    import com.rational.test.ft.*;
    import com.rational.test.ft.object.interfaces.*;
    import com.rational.test.ft.object.interfaces.SAP.*;
    import com.rational.test.ft.object.interfaces.WPF.*;
    import com.rational.test.ft.object.interfaces.dojo.*;
    import com.rational.test.ft.object.interfaces.siebel.*;
    import com.rational.test.ft.object.interfaces.flex.*;
    import com.rational.test.ft.object.interfaces.generichtmlsubdomain.*;
    import com.rational.test.ft.script.*;
    import com.rational.test.ft.value.*;
    import com.rational.test.ft.vp.*;
    import com.ibm.rational.test.ft.object.interfaces.sapwebportal.*;
     * Description : Functional Test Script
     * @author Marc
    public class Script1 extends Script1Helper {
    	 * Script Name : Script1 Generated : 25 mei 2011 18:58:45
    	 * Description : Functional Test Script Original Host : WinNT Version 5.1
    	 * Build 2600 (S)
    	 * @since 2011/05/25
    	 * @author Marc
    	public void testMain(Object[] args) {
    		boolean right = false;
    		String NumberGuess_Text;
    		int min = 1;
    		int max = 100;
    		int intguess = 0;
    		String guess = "";
    		// HTML Browser
    		// Document: Number Guess:
    		while (!right) {
    			// Define Guess
    			intguess = (min + max) / 2;
    			guess = Integer.toString(intguess);
    			// Enter Guess and Submit.
    			text_guess().click(atPoint(1, 1));
    			browser_htmlBrowser(document_numberGuess(), DEFAULT_FLAGS)
    			// Read Result
    			NumberGuess_Text = (String) document_numberGuess().getProperty(
    			// Assume we were right ...
    			right = true;
    			// No it was lower
    			if (NumberGuess_Text.indexOf("lower") > 0) {
    				max = intguess;
    				right = false;
    			// No it was higher
    			if (NumberGuess_Text.indexOf("higher") > 0) {
    				min = intguess;
    				right = false;
    		NumberGuess_Text = (String) document_numberGuess().getProperty(".text");
    		browser_htmlBrowser(document_numberGuess(), MAY_EXIT).close();

    RFT44 - ftp connection

    This code was written and donated by Olav Wirtz ( olav.wirtz-at-logica.com ). It is used at a customer utilizing the testframe methodology.

    package TestFrame.scripts;
    import resources.TestFrame.scripts.Script2Helper;
    import sun.net.ftp.FtpClient;
    import java.io.IOException;
    import com.rational.test.ft.*;
    import com.rational.test.ft.object.interfaces.*;
    import com.rational.test.ft.script.*;
    import com.rational.test.ft.value.*;
    import com.rational.test.ft.vp.*;
     * Name			: Check FTP connection
     * Description  : Test an FTP connection and loggin in.\
     * Creation date: August 25, 2011
     * @Author		 : Olav Wirtz, Logica Nederland B.V. (olav.wirtz -at- logica.com)
    public class Script2 extends Script2Helper
    		String ftpServer = new String("");
    		String user = new String("");
    		String password = new String("");
    		String fileName = new String("");
    		String source = new String("");
    		Boolean blErrors;
    	public void testMain(Object[] args)
    		ftpServer = "";
    		user = "";
    		password = "";
    		blErrors = false;
    		if (ftpServer != null)
    			FtpClient f;
    			try {
    				f = new FtpClient(ftpServer);
    				f.login(user, password);
    			} catch (IOException e) {
    				// TODO Auto-generated catch block
    				if(e != null){
    					blErrors = true;
    			if(blErrors == false){
    				System.out.println("Het is wel gelukt om een verbinding te maken en in te loggen.");
    				System.out.println("Het is niet gelukt om een verbinding te maken en in te loggen.");

    RFT45 - Calling RFT from Java

    Add the reference to the rational_ft.jar in the buildpath of the java project.

    public class mainjava {
    	 * @param args
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    		String[] execScript=new String[]{"-datastore","C:\\rftworkspace\\rftprojectjava\\RFTproject","-playback","RFTScript1"};

    See also: Documentation of com.rational.test.ft.rational_ft
    Make note that there is a "[-args ]" to the command used above. This gives the option to start the specific RFT script with 'user arguments'.

    So there must be a RFT script RFTScript1 in the RFTproject.
    As far as we know now there are no options to provide More arguments or return values.

    RFT46 - SuperHelper

    This works perfectly when the superhelper class is stored in a directory (java package preferably). You may want to switch to the Java perspective. It will NOT work when the superhelper is stored in the default package (project root).

    The superhelper class in a package in the RFT perspective.

    RFT47 - Find example

    public class Script1Find extends Script1FindHelper {
    	 * Script Name : Script1 Generated : 18 jan. 2013 19:35:01
    	 * Description : Functional Test Script Original Host : WinNT Version 6.1
    	 * Build 7601 (S)
    	 * @since 2013/01/18
    	 * @author nl52772
    	public void testMain(Object[] args) {
    		RootTestObject r = getRootTestObject();
    		// Frame: ClassicsCD
    		tree2().drag(atPoint(9, 57), atPoint(9, 56));
    		tree2().click(atPath("Composers->Bach->Violin Concertos"));
    		// Frame: Member Logon
    		// Notice the spaces around the OK
    		TestObject[] myButtons0 = r.find(atDescendant("accessibleContext.accessibleName", "  OK  "), true);
    		GuiTestObject button0 = (GuiTestObject)myButtons0[0];
    		// Frame: Place an Order
    		cardNumberIncludeTheSpaces().drag(atPoint(25, 6), atPoint(25, 7));
    		expirationDate().click(atPoint(15, 12));
    		// The Normal Way ...
    		// ok2().click();
    		// Let find the ok2 object....
    		// Using the RootTestObject
    		timerStart("Find by RootTestObject");
    		//RootTestObject r = getRootTestObject();
    		TestObject[] myButtons = r.find(atDescendant("accessibleContext.accessibleName", "OK"), false);
    		GuiTestObject button1 = (GuiTestObject)myButtons[0];
    		timerStop("Find by RootTestObject");
    		// Using the getDomains
    		// try to find objects by searching all domains, including
    		// unmappable objects
    		timerStart("Find by Domain");
    		DomainTestObject[] dtos = getDomains();
    		TestObject[] myObject;
    		for (int i = 0; i < dtos.length; i++) {
    			myObject = dtos[i].find(
    					// atDescendant(".class", "javax.swing.plaf.basic.BasicOptionPaneUI$ButtonFactory$ConstrainedButton"),
    					atDescendant("accessibleContext.accessibleName", "OK"),
    			System.out.println("Domain: " + dtos[i].getName()
    					+ ", number of objects found: " + myObject.length);
    			if (myObject.length!=0) {
    				GuiTestObject button2 = (GuiTestObject)myObject[0];
    		timerStop("Find by Domain");
    		// Frame: ClassicsCD
    		classicsCD(ANY, MAY_EXIT).close();

    RFT48 - CMD Window compare with Clipboard

    The following steps can be used to copy the text from the command prompt window into the clipboard and compare it with the base line.
    Does not work on XP-SP2 (shallow test done).

    		cWindowsSystem32CmdExewindow().click(RIGHT, atPoint(100,100));
    		// Just to be sure, we wait a second for the pop up.
    		// Select all
    		// Use Enter to copy text into clipboard
    		// Execute Clipboard test

    RFT49 - Datapool encryptie

    Datapool Encryptie

    RFT50 - Listing all properties

    Listing the properties of the identified object:

    	/* Generate leading spaces:
    		n = 10 meaning 2 digits will result in 2 times 3 spaces
    		n = 12028 meaning 5 digits will results in 5 times 3 spaces
    	public static String padRight( int n ) {
    		String value=Integer.toString(n);
    		int l = value.length();
    		if (l!=0) {
    			return String.format("%1$-" + l + "s", "");
    		} else {
    			return "";
    	public void printProperties(int level,TestObject elementOfInterest) {
    		/* Level is the nested level */
    		String str;
    		Enumeration propertiesList;
    		System.out.println("ClassName: "+elementOfInterest.getObjectClassName() );
    		Hashtable elementHash = new Hashtable();
    		elementHash= elementOfInterest.getProperties();
    		while (propertiesList.hasMoreElements()) {
    			str = (String) propertiesList.nextElement();
    			System.out.println(padRight(level)+"*PROP: "+str+": "+elementHash.get(str));
    	public void printElement(int level, TestObject elementOfInterest) {
    		/* Level is the nested level */
    		System.out.println("\n\nElement of Interest - level "+level);
    		String elementOfInterestName = (String) elementOfInterest.getProperty(".name");
    		System.out.println("Element Name: "+elementOfInterestName);
    		//Print main element information
    		printProperties(level, elementOfInterest );
    		Integer number_of_children =  (Integer) elementOfInterest.getProperty(".numChildren");
    		System.out.println("Number of children: "+number_of_children);
    		TestObject[] children = elementOfInterest.getChildren();
    		System.out.println("Number of elements: "+children.length);
    		//TestObject children = (editboxtext().getChildren())[0];
    		for(int i=0;i<children.length;i++) {
    			int childlevel=level*10+i+1;
    			printElement( childlevel,children[i] );
    		System.out.print("Element " + elementOfInterestName + " is done.\n\n");

    You can now call it in the code like:

    		//Use a Test Object to feed the printElement

    RFT51 - RFT - DB2

    import java.sql.DriverManager;
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.Statement;
    public void testMain(Object[] args) throws Exception
    	// TODO Insert code here
    	Connection conn;
    	Statement stmt;
    	ResultSet rs;
    	String sName=null;
    	// Load JDBC-DB2 driver
    	// connect to database by specifying db name, username and password
    	// create statement object to be used to execute query
    	// execute the query and return the results
    	rs=stmt.executeQuery("select name from employee");
    		// insert your RFT script object field here
    		//insert your RFT script object field here
    		logInfo("name "+sName);

    The above code will connect to database Sample and query the Employee Table and return the employee names. Note: db2jcc.jar should be imported into the Project Libraries. When you install DB2 database, the db2jcc.jar file will be located in the path: C:\Program Files\IBM\SQLLIB\java. This code is applicable for operations involving DB2 database only.

    See also: RFT39 - RFT Datapool in DB2


    Where to get support:

    1. RFT Documentation API
    2. DevWorks: A hugh list of usefull docs
    3. Google , searching on "Rational " also for Java code!
    4. Rational Resource page
    5. http://www.ibm.com/developerworks/rational , then search by product.
    6. (IBM Internal) The famous Rational Knowledge Base "Rational Knowledge Base" is a goldmine.
    7. (IBM Internal) Xtreme Leverage's site - look for the "Technical" sections.
    8. (IBM Internal) The SWAN - browse to see if your question has already been answered because someone else asked it previously.
    9. (IBM Internal) TechLine (if you're in a presales situation).
    10. (IBM Internal) The "IBM forums", which you can search via the web, or you can subscribe to them via Lotus Notes (as a newsreader).
    11. (IBM Internal) DCF (on notes) D02DBS88/02/A/IBM    support/swg/rattech.nsf
    12. Yahoo , which is mostly for Robot.
    13. You can call Software support

    Usefull links

    Some are IBM internal.
    Global Campus
    Sun Java Tutorial, Java API
    RFT Training RoadMap
    RFT Wiki http://instawiki.webahead.ibm.com/pilot/wiki/Wiki.jsp?page=IBMPackage&wiki=Automation
    Global Campus Introduction to Object Oriented Programming with Java, Course code: WN86202
    RFT Addons

    An A-Z Index of the Windows XP command line

    Make use of import/export and not of Windows copy to move projects.

    ClassicsA sample application

    Starting ClassicsA you can create a bat file with the contents:
    cd C:\Program Files\IBM\SDPRFT81\FunctionalTester\FTSamples
    java -jar ClassicsJavaA.jar

    Enabling Environments and Browsers

    Replay does not work.

    Action: Enable Environment

    1. In RFT select "Enable Environment"
    2. Goto Enable Browser

    Action: Enable browser

    In the Enable Environments

    1. Select Web Browsers Tab
    2. Select a browset
    3. Select Enable (if not active)
    4. Select Set as Default (if applicable)
    5. Select Test
      This testfunction is not reliable.

    Action: Enable Java

    In the Enable Environments

    1. Select Java Enrionments Tab
    2. Remove any removed Java environments
      Leave IBM Rational SDP JRE
    3. Select a Java
    4. Select Enable

      If you get the message:

      Error Enabling JVM [xxx];
      Error writing accessibility.properties: C:\Program Files (x86)\Java\jre7\lib\accessibility.properties (Access is denied)
      Rerun RFT with admin privileges.

    Symtom: Keyin is not accepted.

    Disable the protected mode (IE) or add the test-site to the trusted sites.

    Disable Protected Mode.