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_relative_path> -eclipsehome <eclipse_full_path> -plugins <plugin_full_path> -suite <suite_relative_path> -importzip <full_path.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}> -labels <labelname1, labelname2> -exportlog <log_full_path> -exportstats <local_dir_path> -exportstatshtml <local_dir_path> -exportstatsformat <name of the file format> -compare <"result_path1, result_path2"> -exportstatreportlist <stats_list> -execsummary <local_dir_path> -execsummaryreport <reportID> -usercomments <"any user comment"> -publishreports <"FT, 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 Test UI

You can create a variable file in XML format to specify the details required to run the mobile test on selected device.

You can also add the details to enable the Test UI to collect metrics for certain parameters of the resources used by the mobile devices.

A sample of the syntax or structure is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<inits>
<variable_init value="<iOS device name>" name="Mobile_Device_Selection"/>
<variable_init value="true" name="rm.selected"/>
<variable_init value ="any value equal to or above 1000" name="rm.polling.interval"/>
</inits>
Restriction: Resource Monitoring metrics of iOS simulators are not collected nor graphically displayed.
Refer to the following table to know the variables and values for the attributes mentioned in the XML sample:
Variable Action Sample value
Mobile_Device_Selection Specify the name of the iOS device or simulator that is connected to the computer. Simulator:iPhone 11 Pro_14.0
rm.selected

Optional. Set the value to true if you want to collect the metrics for certain parameters of resources used by mobile applications or devices. The collection of Resource Monitoring metrics and displaying of the data graphically is supported only when you run a single test on a single device.

true
rm.polling.interval

Specify the interval in milliseconds to collect the metrics for certain parameters of resources used by mobile applications or devices. The minimum value that you can enter is 1000 milliseconds. Enter the value, if you set the attribute rm.selected to true.

1000

You can then use the variable file with the -varfile option in the command to run a test from the command line.

Variable file for UI Test Agent

You can 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 a simulator.

You can also add the details to enable the Test UI to collect metrics for certain parameters of the resources used by the mobile devices.

A sample of the syntax or structure 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"/>
<variable_init value="true" name="rm.selected"/>
<variable_init value ="any value equal to or above 1000" name="rm.polling.interval"/>
</inits>
Restriction: Resource Monitoring metrics of iOS simulators are not collected nor graphically displayed.
Refer to the following table to know the variables and values for the attributes mentioned in the XML sample:
Variable Action Sample value
device_id Specify the name of the iOS device or a simulator that is connected to the computer. Simulator:iPhone 11 Pro_14.0
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.
10.115.50.61
appium.server.port Specify the port number of the UI Test Agent that is installed on the remote machine. 7082
rm.selected

Optional. Set the value to true if you want to collect the metrics for certain parameters of resources used by mobile applications or devices. The collection of Resource Monitoring metrics and displaying of the data graphically is supported only when you run a single test on a single device.

true
rm.polling.interval

Specify the interval in milliseconds to collect the metrics for certain parameters of resources used by mobile applications or devices. The minimum value that you can enter is 1000 milliseconds. Enter the value, if you set the attribute rm.selected to true.

1000

You can then use the variable file with the -varfile option in the command to run a test from the command line.

Variable file for BitBar Cloud

You can 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>
Note: When you want to run an AFT Suite on devices connected to BitBar Cloud, create the XML file without the variable Mobile_Device_Selection.
The following table lists the variables and the sample values that are used to create a variable file:
Variable Action Sample value
Mobile_Device_Selection Specify the name of the mobile device that is connected to the BitBar Cloud. BitBar:iPhone 11 Pro_14.0
bitbar.apikey Specify the user token generated for your BitBar account to authenticate your connection with the BitBar Cloud. LkBldnjcnzrIcwWZpCZZxy
bitbar.host Specify the host name of the BitBar Cloud instance. appium.bitbar.com
bitbar.project Specify the name of the project that contains the recorded test. PlaybackMobile
bitbar.testrun Specify a name for the test run that must be displayed in the BitBar dashboard for the test run. CLIExecution

The example variable file 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>

You can then use the variable file with the -varfile option in the command to run a test from the command line.

Variable file for BrowserStack Cloud

You can create an XML file as a variable file that specifies the details of the BrowserStack Cloud. The format of the variable file is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<inits>
<variable_init value="<BrowserStack user name>" name="browserstack.username"/>
<variable_init value="<BrowserStack host URL>" name="browserstack.host"/>
<variable_init value="<BrowserStack API key>" name="browserstack.apikey"/>
<variable_init value="<project name>" name="browserstack.project"/>
<variable_init value="<Browser(BrowserStack : device name)>" name="RTW_WebUI_Browser_Selection"/>
</inits>
The following table lists the variables and the sample values that are used to create a variable file:
Variable Action Sample value
browserstack.username Specify the user name of your BrowserStack account to authenticate your connection with the BrowserStack Cloud. tester_1
browserstack.apikey Specify the user token generated for your BrowserStack account to authenticate your connection with the BrowserStack Cloud. api-cloud.browserstack.com
browserstack.host Specify the host name of the BrowserStack Cloud instance. KBk7PjhpqgfeVmxasUye
browserstack.project Specify the name of the project that contains the recorded test. CMDLINETest
RTW_WebUI_Browser_Selection Specify the browser to be used on the mobile device that is connected to the BrowserStack Cloud. Chrome(BrowserStack : iPhone 11)

The example variable file is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<inits>
<variable_init value="tester_1" name="browserstack.username"/>
<variable_init value="api-cloud.browserstack.com" name="browserstack.host"/>
<variable_init value="KBk7PjhpqgfeVmxasUye" name="browserstack.apikey"/>
<variable_init value="CMDLINETest" name="browserstack.project"/>
<variable_init value="Chrome(BrowserStack : iPhone 11)" name="RTW_WebUI_Browser_Selection"/>
</inits>

You can then use the variable file with the -varfile option in the command to run a test from the command line.

Variable file for Perfecto Cloud

You can create an XML file as a variable file that specifies the details of the Perfecto 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>
Note: When you want to run an AFT Suite on devices connected to Perfecto Cloud, create the XML file without the variable Mobile_Device_Selection.
The following table lists the variables and the sample values that are used to create a variable file:
Variable Action Sample value
Mobile_Device_Selection Specify the name of the mobile device that is connected to the Perfecto Cloud. Perfecto:8D3E35CF16D8D827E4827ABBCD0E582E2761CADA
perfecto.securitytoken Specify the user token generated for your Perfecto account to authenticate your connection with the Perfecto Cloud. LkBldnjcnzrIcwWZpCZZxy
perfecto.host Specify the URL of the Perfecto Cloud that is configured to communicate with Test UI. partners.perfectomobile.com

The example variable file 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>

You can then use the variable file with the -varfile option in the command to run a test from the command line.

Variable file for pCloudy Cloud

You can 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>
Note: When you want to run an AFT Suite on devices connected to pCloudy Cloud, create the XML file without the variable Mobile_Device_Selection.
The following table lists the variables and the sample values that are used to create a variable file:
Variable Action Sample value
Mobile_Device_Selection Specify the name of the mobile device that is connected to the pCloudy Cloud. pCloudy:Apple_iPhone8plus_Ios_14.4.0_9db66
pcloudy.apikey Specify the API key of your pCloudy account to authenticate the user name for a successful connection. csv7wxjyyzzgrzbqym62cvfg
pcloudy.host Specify the URL of the pCloudy Cloud instance. device.pcloudy.com
pcloudy.username Specify the user name of your pCloudy account. myUserName@pcloudy

The example variable file is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<inits>
<variable_init value="pCloudy:Apple_iPhone8plus_Ios_14.4.0_9db66" name="Mobile_Device_Selection"/>
<variable_init value="csv7wxjyyzzgrzbqym62cvfg" name="pcloudy.apikey"/>
<variable_init value="device.pcloudy.com" name="pcloudy.host"/>
<variable_init value="myUserName@pcloudy" name="pcloudy.username"/>
</inits>

You can then use the variable file with the -varfile option in the command to run a test from the command line.

Variable file to run mobile tests on multiple mobile clouds

When you want to run mobile tests on devices that are connected to multiple mobile clouds, you can create an XML file and use it as a variable file. You must specify the details of each of the mobile clouds in the variable file that enable Test UI to connect to the mobile clouds.

You can configure details of the mobile clouds as an xml file. You can use the following sample XML file to enter the details of the name and value pairs for the mobile clouds.

For example, if you want to run on the BitBar Cloud and pCloudy Cloud, edit the XML file and remove the details of the Perfecto Cloud.

<?xml version="1.0" encoding="UTF-8"?>
<inits>
<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"/>
<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"/>
<variable_init value="<security token>" name="perfecto.securitytoken"/>
<variable_init value="<perfecto host URL>" name="perfecto.host"/>
</inits>
Note: You must only enter the details of the mobile clouds that you want to use.

Refer to the following table to know the details of the mobile clouds, that you need to enter in the XML file:

Mobile clouds Name of the variable Description
BitBar Cloud bitbar.apikey Specifies the user token generated for your BitBar account to authenticate the connection with the BitBar Cloud.
bitbar.host Specifies the host name of the BitBar Cloud instance.
bitbar.project Specifies the name of the project that contains the recorded test.
bitbar.testrun Specifies a name for the test run that must be displayed in the BitBar dashboard for the test run.
pCloudy Cloud pcloudy.apikey Specifies the API key of your pCloudy account to authenticate the user name for a successful connection.
pcloudy.host Specifies the URL of the pCloudy cloud instance.
pcloudy.username Specifies the user name of your pCloudy account.
Perfecto Cloud perfecto.securitytoken Specifies the user token generated for your Perfecto account to authenticate your connection with the Perfecto Cloud.
perfecto.host Specifies the URL of the Perfecto Cloud.

You can then use the variable file with the -varfile option in the command to run a test from the command line.