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:
Variable Action Sample value
Mobile_Device_Selection Specify the name of the Android device or emulator that is connected to the computer. Emulator:Pixel_2_API_28
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 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:
Variable Action Sample value
Mobile_Device_Selection Specify the name of the Android device or emulator that is connected to the computer. Emulator:Pixel_2_API_28
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.

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 sample values:
Variable Action Sample value
Mobile_Device_Selection Specify the name of the mobile device that is connected to the BitBar Cloud. BitBar:Google Pixel 2
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
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 BrowserStack Cloud

You can create an XML file as a variable file that specifies the details of the BrowserStack 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" standalone="yes"?>
<inits id="N2D6E3E008FC11EDAE07D38ACD9588FD" type="com.ibm.rational.test.ft.aftsuite">
<group>
<tests>
<test path="/UI1/Tests/apidemos1.testsuite"/>
</tests>
<devices>
<device id="BrowserStack : Google Pixel 7 Pro" />
<device id="BrowserStack : Samsung Galaxy Tab S8" />
</devices>
</group>
</inits>
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 mobile device that is connected to the BrowserStack Cloud. BrowserStack : Google Pixel 7 Pro
browserstack.project Specify the name of the project that contains the recorded test. PlaybackMobile
testpath Specify a path for the test run that must be displayed in the BrowserStack dashboard for the test run. CLIExecution
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 Perfecto 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:
Variable Action Sample value
Mobile_Device_Selection Specify the name of the mobile device that is connected to the Perfecto Cloud. Perfecto:R48904TNSAZ
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. partners.perfectomobile.com
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 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:
Variable Action Sample value
Mobile_Device_Selection Specify the name of the mobile device that is connected to the pCloudy Cloud. pCloudy:SAMSUNG_GalaxyS8_Android_7.0.0_3ced4
pcloudy.apikey Specify the user token generated for your Perfecto account to authenticate your connection with the Perfecto Cloud. 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
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 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 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.