IBM Rational Test Workbench 8.6 offers test automation solution for Mobile and Web Applications on Android & iOS platforms. It also offers automation solution for Web Applications on Windows & Linux desktop platforms on Firefox, Chrome and Internet Explorer browsers. Rational Test Workbench inherits its core functionalities from Rational Performance Tester and Command line execution is on the same guidelines as used by Rational Performance Tester. Help doc reference for the same can be found in following link -
In this blog we would see how user can execute Mobile & Web UI tests using command line interface. Suppose we have Mobile & Web UI tests in a RTW Project as shown in below image –
FIGURE 1. Sample RTW Project with 1 Mobile & 1 Web UI Test
As seen above I have 1 Mobile test (Test recorded on mobile app) and 1 Web UI test (test recorded on a web app) which we are planning to execute using command line interface. Before we start the command line execution user should make sure that all pre-requisites are met.
Pre-requisites for running Mobile & Web UI tests in Mobile Devices/Emulators –
1) In case of mobile test, Application under test must be installed in playback ready mode in Mobile devices/emulators. In case of Web UI tests, RTW Mobile Web Recorder (Sometimes referred as RTW Browser) must be installed in Mobile devices/Emulators.
2) Mobile device must be connected to RTW Workbench in passive mode.
3) In command line execution, RTW will run in headless mode. User must make sure that any running instance of RTW must be closed before doing command line execution.
4) Optional - To select correct mobile device for playback, user can set a variable named “RTW_Mobile_Selected_Device” in the test, the value for the variable should be equal to device ID of device under test. Alternatively the variable can be provided as an argument to command line which we will discuss later.
Below screenshot shows how to get device ID for a device.
FIGURE 2. Identifying device id (A unique id for every device/emulator/simulator)
Below figure shows setting Mobile device selection variable at test level -
FIGURE 3. Adding Mobile device selection variable at test level
Note – If user does not provide RTW_Mobile_Selected_Device variable, the command line will execute Mobile or Web UI test randomly on one of the connected devices/emulators which satisfies the pre-requisites. If no devices found matching the criteria, the RTW playback log will report the same.
Pre-requisites for running Web UI tests in Desktop –
1) Make sure that browser under test is installed in the system.
2) Optional - To select correct browser for playback, user can set a variable named “RTW_WebUI_Browser_Selection” in the test, the value for the variable should be equal to browser under test [either Firefox / Chrome / Internet Explorer / Internet Explorer 64]. Alternatively the variable can be provided as an argument to command line which we will discuss later.
Note – If user does not provide RTW_WebUI_Browser_Selection variable but mobile devices are connected in passive modes, the command line will execute Web UI test randomly on one of the connected mobile devices/emulators (on RTW Browser) which satisfies the pre-requisites. If no devices found matching the criteria, the RTW playback log will report the same. RTW allows running same Web UI tests on Mobile & desktop ir-respective of where the tests are recorded, tests will pass or fail based on the web application uniformity across mobile & desktop platforms. The test will not run on desktop browser/s unless RTW_WebUI_Browser_Selection variable is explicitly declared.
Note - Once all pre-requisites are met, in command prompt or in terminal in linux, user can set IBM JDK (bundled with RTW generally in /opt/IBM/SDP/jdk in linux and c:\Program Files\IBM\SDP\jdk) in the path or in the shell so that it can be used for execution.
Executing Mobile & Web UI Tests from command line –
Setting mobile device selection / desktop browser selection variables – To provide mobile selection variable as an argument to command line, user have to define the variable name & value pair in a xml file and provide that xml file absolute path against –varfile option. The contents of the xml file can be like as shown below –
<?xml version="1.0" encoding="UTF-8"?>
<variable_init value="909F449D156A8930EC0E653BCE1BDDE9" name="RTW_Mobile_Selected_Device"/>
Similarly for desktop browser (e.g. firefox in this case) –
<?xml version="1.0" encoding="UTF-8"?>
<variable_init value="Firefox" name="RTW_WebUI_Browser_Selection"/>
Below figure shows the snapshot of the xml file -
FIGURE 4. sample xml snapshot for variable declaration
Now user can proceed to execute following commands –
1) Change directory to cmdline directory in product install directory, where cmdline.sh (in linux) or cmdline.bat (in windows) exists e.g.
cd /opt/IBM/SDP/cmdline (In linux)
cd “C:\Program Files\IBM\SDP\cmdline” (In Windows)
cmdline directory location may differ based on where you have installed the product.
Note – Currently Command line execution is not supported in Mac OS.
2) Execute following command –
In case of Mobile Test in Windows OS –
cmdline.bat -workspace "C:\Users\Administrator \IBM\rationalsdp\workspace" -project RTWProject -plugins "C:\Program Files\IBM\IBMIMShared\plugins" -eclipsehome "C:\Program Files\IBM\SDP" -suite "Tests\Calculator_MobileTest.testsuite" -varfile "C:\Temp\mobileDeviceSelection.xml" -results "Results\Calc_mobileTest" -exportlog "C:\Temp\webLog.txt"
In case of Web UI test on desktop browser in Windows OS -
cmdline.bat -workspace "C:\Users\Administrator\IBM\rationalsdp\workspace" -project RTWProject -plugins "C:\Program Files\IBM\IBMIMShared\plugins" -eclipsehome "C:\Program Files\IBM\SDP" -suite "Tests\ www.ibm.com_WebUITest.testsuite" -varfile "C:\Temp\browserSelectionVariable.xml" -results "Results\webUItest_on_ff" -exportlog "C:\Temp\webLog.txt"
Similarly these can be executed in linux e.g. for Mobile test –
./cmdline.sh -workspace "/root/IBM/rationalsdp/workspace" -project RTWProject -plugins "/opt/IBM/IBMIMShared/plugins" -eclipsehome "/opt/IBM/SDP" -suite "Tests/Calculator_MobileTest.testsuite" -varfile "/tmp/mobileDeviceSelection.xml" -results "Results/Calc_mobileTest" -exportlog "tmp\webLog.txt"
Though the command is quite self explanatory, yet let’s see the options –
|Command line Option
||Value it consumes
|cmdline.bat or cmdline.sh
||command line invoker
||Absolute path to workspace directory
||Absolute path to IBMIMShared plugins directory
||Absolute path to RTW install directory
||Relative path of the test from project [In case of a schedule (RPT asset for parallel execution, can be used in RTW also when RPT & RTW are shell shared) execution, this can be replaced by schedule]
||defining variables name & value pairs which will be used during execution
||RTW by default creates a default name for the playback log which is generally testname followed by epoch time at the time of execution. User can choose this option to create the log with name of his choice and the log will be stored in the directory provided, like here it will be stored in Results folder inside RTWProject.
||This option creates a verbose log at the end of the playback which user can refer post playback. To view the RTW logs user need to launch RTW and then see the log, this option may save this effort.
There are other options too which can be used in command line execution available in RTW help, here we have just discussed some of them which are most common.
Executing a Compound Test via command line –
A compound test may contain all different kind of tests which RTW supports and execution of compound test executes these tests sequentially. To execute a compound test via command line, it’s better to define the mobile device or desktop browser selection variables at the compound test level or at the test level itself and then execute the similar commands as mentioned above.