Running mobile tests for iOS applications from the command-line

You can run a mobile test without using the desktop client by using the command-line interface. You must use the -varfile parameter that specifies the complete path to the XML file in the command. The XML file contains the name-value pairs of the variables. The variables specify the path to the computer to which the iOS device or simulator is connected, and the other configurations required to run the mobile test on the connected device.

Running the command

Before you can run the command to run mobile tests from the command line, you must create a variable file that contains the details of the computer to which the mobile device is connected. You must have also recorded the mobile test.

You can issue the following command to run a mobile test from the command-line:

cmdline -workspace workspace_full_path -project proj_rel_path -eclipsehome eclipse_full_path -plugins plugin_full_path -suite suite_rel_path -importzip file_name.zip -varfile variable_file_full_path -configfile file_full_path -results result_file -overwrite {"true" | "false"} -quiet -vmargs JVM_args -publish serverURL#project.name=projectName -publish_for {ALL,PASS,FAIL,ERROR, INCONCLUSIVE} -exportlog log_full_path -exportstats local_dir_path -exportstatshtml local_dir_path -compare "result_path1, result_path2" -exportstatreportlist stats_list -execsummary local_dir_path -execsummaryreport reportID -usercomments "any user comment" -publishreports "FT, FUNCTIONAL, STATS, TESTLOG" -stdout -swapdatsets existing_dataset_file_path:new_dataset_file-path

Important: When you use the command to run a mobile test, you must ensure that the following conditions are satisfied:
  • Use the variable file that contains the details of the computer, server, or cloud to which the iOS devices or simulators are connected.
  • Specify the details of the variable file in the command.

Creating a variable file

You must create a variable file that contains the variable names and values as pairs that are required to connect to the iOS device or simulator. You can connect and run the mobile tests on iOS devices or simulators that are connected to the following computers, servers, or mobile clouds:

Variable file for a computer on which you have installed Rational® Functional Tester

Create an XML file as a variable file that specifies the details of the computer on which you have installed Rational® Functional Tester and connected the iOS device or a simulator. The format of the variable file is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<inits>
<variable_init value="<iOS device or simulator name>" name="Mobile_Device_Selection"/>
</inits>
For example, if you connect Simulator:Pixel_2_API_28 as the mobile simulator, the variable file can be as follows:
<?xml version="1.0" encoding="UTF-8"?><inits>
<variable_init value="Simulator:Pixel_2_API_28" name="Mobile_Device_Selection"/>
</inits>

Variable file for UI Test Agent

Create an XML file as a variable file that specifies the details of the remote computer on which you have installed the UI Test Agent and connected the iOS device or an simulator. The format of the variable file is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<inits>
<variable_init value="<iOS device or simulator name>" name="Mobile_Device_Selection"/>             
<variable_init value="<UI Test Agent host URL>" name="appium.server.host"/>
<variable_init value="<port number>" name="appium.server.port"/>
</inits>

The following table lists the variables and the actions required for the value field:

Name of the variable Value
Mobile_Device_Selection Specify the name of the mobile device that is connected to the UI Test Agent.
appium.server.host Specify the host name or IP address of the remote computer on which you have installed the UI Test Agent.
Note: The default value for this variable is 127.0.0.1. If no value is specified, the default value is used during the playback.
perfecto.host Specify the URL of Perfecto mobile device cloud.
Note: The default value for this variable is 4723. If no value is specified, the default value is used during the playback.
For example, if you connect Simulator:iPhone 11 Pro_14.0 as the mobile simulator to a remote computer where the UI Test Agent host URL is 10.115.50.61, and the UI Test Agent port is 4723, the variable file can be as follows:
<?xml version="1.0" encoding="UTF-8"?>
<inits>
<variable_init value="iPhone 11 Pro_14.0" name="Mobile_Device_Selection"/>             
<variable_init value="10.115.50.61" name="appium.server.host"/>
<variable_init value="4723" name="appium.server.port"/>
</inits>

Variable file for BitBar Cloud

Create an XML file as a variable file that specifies the details of the BitBar Cloud. The format of the variable file is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<inits>
<variable_init value="<BitBar device name>" name="Mobile_Device_Selection"/>
<variable_init value="<BitBar API key>" name="bitbar.apikey"/>
<variable_init value="<BitBar host URL>" name="bitbar.host"/>
<variable_init value="<project name>" name="bitbar.project"/>
<variable_init value="<test name>" name="bitbar.testrun"/>
</inits>
The following table lists the variables and the actions required for the value field:
Name of the Variable Value
Mobile_Device_Selection Specify the name of the mobile device that is connected to the BitBar cloud.
bitbar.apikey Specify the user token generated for your BitBar account to authenticate your connection with the BitBar Cloud.
bitbar.host Specify the host name of the BitBar cloud instance.
bitbar.project Specify the name of the project that contains the recorded test.
bitbar.testrun Specify a name for the test run that must be displayed in the BitBar dashboard for the test run.
Consider the following values that are used to create a variable file for BitBar Cloud:
Name of the Variable Value
Mobile_Device_Selection Bitbar:iPhone 11 Pro_14.0
bitbar.apikey LkBldnjcnzrIcwWZpCZZxy
bitbar.host appium.bitbar.com
bitbar.project PlaybackMobile
bitbar.testrun CLIExecution

The example variable file for the values in the table is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<inits>
<variable_init value="Bitbar:iPhone 11 Pro_14.0" name="Mobile_Device_Selection"/>
<variable_init value="LkBldnjcnzrIcwWZpCZZxy" name="bitbar.apikey"/>
<variable_init value="appium.bitbar.com" name="bitbar.host"/>
<variable_init value="PlaybackMobile" name="bitbar.project"/>
<variable_init value="CLIExecution" name="bitbar.testrun"/>
</inits>

Variable file for Perfecto Mobile cloud

Create an XML file as a variable file that specifies the details of the Perfecto Mobile cloud. The format of the variable file is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<inits>
<variable_init value="<device name>" name="Mobile_Device_Selection"/>
<variable_init value="<security token>" name="perfecto.securitytoken"/>
<variable_init value="<perfecto host URL>" name="perfecto.host"/>
</inits>
The following table lists the variables and the actions required for the value field:
Name of the Variable Value
Mobile_Device_Selection Specify the name of the mobile device that is connected to the Perfecto mobile cloud.
perfecto.securitytoken Specify the user token generated for your Perfecto account to authenticate your connection with the Perfecto Mobile cloud.
perfecto.host Specify the URL of the Perfecto mobile cloud that is configured to communicate with Rational® Functional Tester.
Consider the following values that are used to create a variable file for Perfecto Mobile cloud:
Name of the Variable Value
Mobile_Device_Selection Perfecto:8D3E35CF16D8D827E4827ABBCD0E582E2761CADA
perfecto.securitytoken LkBldnjcnzrIcwWZpCZZxy
perfecto.host partners.perfectomobile.com

The example variable file for the values in the table is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<inits>
<variable_init value="Perfecto:8D3E35CF16D8D827E4827ABBCD0E582E2761CADA" name="Mobile_Device_Selection"/>
<variable_init value="LkBldnjcnzrIcwWZpCZZxy" name="perfecto.securitytoken"/>
<variable_init value="partners.perfectomobile.com" name="perfecto.host"/>
</inits>

Variable file for pCloudy cloud

Create an XML file as a variable file that specifies the details of the pCloudy cloud. The format of the variable file is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<inits>
<variable_init value="<device name>" name="Mobile_Device_Selection"/>
<variable_init value="<api key>" name="pcloudy.apikey"/>
<variable_init value="<pcloudy host URL>" name="pcloudy.host"/>
<variable_init value="<pcloudy user name>" name="pcloudy.username"/>
</inits>
The following table lists the variables and the actions required for the value field:
Name of the Variable Value
Mobile_Device_Selection Specify the name of the mobile device that is connected to the pCloudy cloud.
pcloudy.apikey Specify the API key of your pCloudy account to authenticate the user name for a successful connection.
pcloudy.host Specify the URL of the pCloudy cloud instance.
pcloudy.username Specify the user name of your pCloudy account.
Consider the following values that are used to create a variable file for pCloudy cloud:
Name of the Variable Value
Mobile_Device_Selection pCloudy:SAMSUNG_GalaxyS8_Android_7.0.0_3ced4
pcloudy.apikey csv7wxjyyzzgrzbqym62cvfg
pcloudy.host poc.pcloudy.com
pcloudy.username myUserName@pcloudy

The example variable file for the values in the table is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<inits>
<variable_init value="pCloudy:SAMSUNG_GalaxyS8_Android_7.0.0_3ced4" name="Mobile_Device_Selection"/>
<variable_init value="csv7wxjyyzzgrzbqym62cvfg" name="pcloudy.apikey"/>
<variable_init value="poc.pcloudy.com" name="pcloudy.host"/>
<variable_init value="myUserName@pcloudy" name="pcloudy.username"/>
</inits>