Tutorial - 16 : How to pass parameters from one script to another by CallScript Method using IBM...

3

Click here to load reader

description

How to pass parameters from one script to another by CallScript Method using IBM Rational Functional Tester - RFT

Transcript of Tutorial - 16 : How to pass parameters from one script to another by CallScript Method using IBM...

Page 1: Tutorial - 16 : How to pass parameters from one script to another by CallScript Method  using IBM RFT

Tutorial - 16 : How to pass parameters from one script to another by CallScript Methodusing IBM Rational Functional Tester - RFT

This article presents a simple method of using the different signatures of the callScriptmethod to pass data from one script to another using IBM RFT

The example uses two different Functional Tester scripts:

a) Script - 1: TheCaller, which calls another script and passes parameters

b) Script - 2: TheCalled, which receives the parameters and prints them to System.out

TheCaller script further uses three different versions of the callScript method:

Version - 1: Without additional parameters: This is the default usage of the callScript method,which will execute the specified script.

callScript("TheCalled");

Version - 2: With additional string array parameter: An array of strings is used to pass stringparameters to the called script.

String[] dataToPass = new String[4];...callScript("TheCalled",dataToPass);

Version - 3: With additional object array parameter: An array of objects is used to pass differentobject type parameters to the called script.

Object[] objdataToPass = new Object[4];...callScript("TheCalled",objdataToPass);

The TheCaller script sample had been recorded as under:import resources TheCallerHelper;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.siebel.*;import com.rational.test.ft.script.*;import com.rational.test.ft.value.*;import com.rational.test.ft.vp.*;/*** Description : Functional Test Script* @author Administrator*/public class TheCaller extends TheCallerHelper{/*** Script Name : TheCaller* Generated : Feb 10, 2008 7:24:08 PM* Description : Functional Test Script* Original Host : WinNT Version 5.1 Build 2600 (S)** @since 2008/02/10* @author Administrator

Page 2: Tutorial - 16 : How to pass parameters from one script to another by CallScript Method  using IBM RFT

*/public void testMain (Object[] args){callScript("TheCalled");String[] dataToPass = new String[4];dataToPass[0] = "this";dataToPass[1] = "is";dataToPass[2] = "really";dataToPass[3] = "cool";callScript("TheCalled",dataToPass);Object[] objdataToPass = new Object[4];objdataToPass[0] = new String("Thought the previous was cool?");objdataToPass[1] = "Take this one!";objdataToPass[2] = new Float(0.02);objdataToPass[3] = new Integer(4711);callScript("TheCalled",objdataToPass);}}The TheCalled script uses a simple loop to print the received parameters to System.out:import resources.TheCalledHelper;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.siebel.*;import com.rational.test.ft.script.*;import com.rational.test.ft.value.*;import com.rational.test.ft.vp.*;/*** Description : Functional Tester Script* @author Administrator*/public class TheCalled extends TheCalledHelper{/*** Script Name : TheCalled* Generated : Feb 10, 2008 7:24:08 PM* Description : Functional Test Script* Original Host : WinNT Version 5.1 Build 2600 (S)** @since 2008/02/10* @author Administrator*/public void testMain (Object[] args){if (args.length < 1){System.out.println( "Expected at least 1 arg, however we got:"+args.length);return;}else{System.out.println( "Got: "+args.length+" args");}for (int i = 0; i < args.length; ++i){

Page 3: Tutorial - 16 : How to pass parameters from one script to another by CallScript Method  using IBM RFT

System.out.println( " arg["+i+"] = "+args[i]);}}}

Tutorial by :

http://www.softwaretestinggenius.com