Running mobile tests for Android 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 Android device or emulator 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 Android devices or emulators are connected.
  • Specify the details of the variable file in the command.

Creating a variable file

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

Variable file for a computer on which you have installed HCL OneTest 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 HCL OneTest 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="<Android device or emulator 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>
Refer to the following table to know the variables and values for the attributes mentioned in the XML sample:
Attribute Variable Description
Mobile_Device_Selection <Android device or emulator name> Specifies the name of the Android device or emulator that is connected to the computer.
Example:
<variable_init value="Emulator:Pixel_2_API_28" name="Mobile_Device_Selection"/>
rm.selected <true>
Optional. If you want to collect the metrics for certain parameters of resources used by mobile applications or devices, set the value to true. Collection of Resource Monitoring metrics and displaying of the data graphically is supported only when you run a single test on a single device. For example, the entry in the XML file can be as follows:
<variable_init value="true" name="rm.selected"/>
rm.polling.interval <Any value equal to or above 1000>
Specifies the interval in milliseconds to collect the metrics for certain parameters of resources used by mobile application or device. The minimum value that you can enter is 1000 milliseconds. Enter the value, if you set the attribute rm.selected to true. For example, the entry in the XML file can be as follows:
<variable_init value ="1000" name="rm.polling.interval"/>

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 Android device or an emulator.

You can also add the details to enable the HCL OneTest 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="<Android device or emulator 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>
Refer to the following table to know the variables and values for the attributes mentioned in the XML sample:
Attribute Variable Description
Mobile_Device_Selection <Android device or emulator name> Specifies the name of the Android device or emulator that is connected to the computer.
Example:
<variable_init value="Emulator:Pixel_2_API_28" name="Mobile_Device_Selection"/>
appium.server.host <UI Test Agent host URL> Specifies 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.
Example:

<variable_init value="10.115.50.61" name="appium.server.host"/>
appium.server.port <port number> Specifies the port number of the UI Test Agent that is installed on the remote machine.
<variable_init value="7082" name="appium.server.port"/>
rm.selected <true>
Optional. If you want to collect the metrics for certain parameters of resources used by mobile applications or devices, set the value to true. Collection of Resource Monitoring metrics and displaying of the data graphically is supported only when you run a single test on a single device. For example, the entry in the XML file can be as follows:
<variable_init value="true" name="rm.selected"/>
rm.polling.interval <Any value equal to or above 1000>
Specifies the interval in milliseconds to collect the metrics for certain parameters of resources used by mobile application or device. The minimum value that you can enter is 1000 milliseconds. Enter the value, if you set the attribute rm.selected to true. For example, the entry in the XML file can be as follows:
<variable_init value ="1000" name="rm.polling.interval"/>

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.

You can also add the details to enable the HCL OneTest UI to collect metrics for certain parameters of the resources used by the mobile devices and applications.
Restriction: Resource Monitoring metrics of mobile device resources are not collected when the tests are run as an AFT suite.
A sample of the syntax or structure 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"/>
<variable_init value="true" name="rm.selected"/>
<variable_init value ="any value equal to or above 1000" name="rm.polling.interval"/>
</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.
Refer to the following table to know the variables and values for the attributes mentioned in the XML sample:
Attribute Variable Description
Mobile_Device_Selection <BitBar device name> Specifies the name of the mobile device that is connected to the BitBar cloud.
Example:
<variable_init value="BitBar:Google Pixel 2" name="Mobile_Device_Selection"/>
bitbar.apikey <BitBar API key> Specifies the user token generated for your BitBar account to authenticate your connection with the BitBar Cloud.
Example:

<variable_init value="LkBldnjcnzrIcwWZpCZZxy" name="bitbar.apikey"/>
bitbar.host <BitBar host URL> Specify the host name of the BitBar cloud instance.
Example:
<variable_init value="appium.bitbar.com" name="bitbar.host"/>
bitbar.project <project name> Specifies the name of the project that contains the recorded test.
Example:
<variable_init value="PlaybackMobile" name="bitbar.project"/>
bitbar.testrun <test name> Specifies a name for the test run that must be displayed in the BitBar dashboard for the test run.
Example:
<variable_init value="CLIExecution" name="bitbar.testrun"/>
rm.selected <true>
Optional. If you want to collect the metrics for certain parameters of resources used by mobile applications or devices, set the value to true. Collection of Resource Monitoring metrics and displaying of the data graphically is supported only when you run a single test on a single device. For example, the entry in the XML file can be as follows:
<variable_init value="true" name="rm.selected"/>
rm.polling.interval <Any value equal to or above 1000>
Specifies the interval in milliseconds to collect the metrics for certain parameters of resources used by mobile application or device. The minimum value that you can enter is 1000 milliseconds. Enter the value, if you set the attribute rm.selected to true. For example, the entry in the XML file can be as follows:
<variable_init value ="1000" name="rm.polling.interval"/>

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 Mobile cloud

You can create an XML file as a variable file that specifies the details of the Perfecto Cloud.

You can also add the details to enable the HCL OneTest UI to collect metrics for certain parameters of the resources used by the mobile devices.
Restriction: Resource Monitoring metrics of mobile device resources are not collected for mobile tests in an AFT suite.
A sample of the syntax or structure is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<inits>
<variable_init value="<Perfecto device name>" name="Mobile_Device_Selection"/>
<variable_init value="<security token>" name="perfecto.securitytoken"/>
<variable_init value="<perfecto host URL>" name="perfecto.host"/>
<variable_init value="true" name="rm.selected"/>
<variable_init value ="any value equal to or above 1000" name="rm.polling.interval"/>
</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.
Refer to the following table to know the variables and values for the attributes mentioned in the XML sample:
Attribute Variable Description
Mobile_Device_Selection <Perfecto device name> Specifies the name of the mobile device that is connected to the Perfecto mobile cloud.
Example:
<variable_init value="Perfecto:R48904TNSAZ" name="Mobile_Device_Selection"/>
perfecto.securitytoken <security token> Specifies the user token generated for your Perfecto account to authenticate your connection with the Perfecto cloud.
Example:

<variable_init value="LkBldnjcnzrIcwWZpCZZxy" name="perfecto.securitytoken"/>
perfecto.host <perfecto host URL> Specifies the URL of the Perfecto Cloud.
<variable_init value="partners.perfectomobile.com" name="perfecto.host"/>
rm.selected <true>
Optional. If you want to collect the metrics for certain parameters of resources used by mobile applications or devices, set the value to true. Collection of Resource Monitoring metrics and displaying of the data graphically is supported only when you run a single test on a single device. For example, the entry in the XML file can be as follows:
<variable_init value="true" name="rm.selected"/>
rm.polling.interval <Any value equal to or above 1000>
Specifies the interval in milliseconds to collect the metrics for certain parameters of resources used by mobile application or device. The minimum value that you can enter is 1000 milliseconds. Enter the value, if you set the attribute rm.selected to true. For example, the entry in the XML file can be as follows:
<variable_init value ="1000" name="rm.polling.interval"/>

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.

You can also add the details to enable the HCL OneTest UI to collect metrics for certain parameters of the resources used by the mobile devices.
Restriction: Resource Monitoring metrics of mobile device resources are not collected for mobile tests in an AFT suite.
A sample of the syntax or structure is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<inits>
<variable_init value="<pCloudy 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"/>
<variable_init value="true" name="rm.selected"/>
<variable_init value ="any value equal to or above 1000" name="rm.polling.interval"/>
</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.
Refer to the following table to know the variables and values for the attributes mentioned in the XML sample:
Attribute Variable Description
Mobile_Device_Selection <pCloudy device name> Specifies the name of the mobile device that is connected to the pCloudy cloud.
Example:

<variable_init value="pCloudy:SAMSUNG_GalaxyS8_Android_7.0.0_3ced4" name="Mobile_Device_Selection"/>
pcloudy.apikey <api key> Specifies the user token generated for your Perfecto account to authenticate your connection with the Perfecto cloud.
Example:
<variable_init value="csv7wxjyyzzgrzbqym62cvfg" name="pcloudy.apikey"/>
pcloudy.host <pcloudy host URL> Specifies the URL of the pCloudy Cloud instance.
Example:
<variable_init value="poc.pcloudy.com" name="pcloudy.host"/>
pcloudy.username <pcloudy user name> Specifies the user name of your pCloudy account.
Example:

<variable_init value="myUserName@pcloudy" name="pcloudy.username"/>
rm.selected <true>
Optional. If you want to collect the metrics for certain parameters of resources used by mobile applications or devices, set the value to true. Collection of Resource Monitoring metrics and displaying of the data graphically is supported only when you run a single test on a single device. For example, the entry in the XML file can be as follows:
<variable_init value="true" name="rm.selected"/>
rm.polling.interval <Any value equal to or above 1000>
Specifies the interval in milliseconds to collect the metrics for certain parameters of resources used by mobile application or device. The minimum value that you can enter is 1000 milliseconds. Enter the value, if you set the attribute rm.selected to true. For example, the entry in the XML file can be as follows:
<variable_init value ="1000" name="rm.polling.interval"/>

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 HCL OneTest 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 Value of the variable
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.