Run Your Test on Any Android Device
We will show you how easy it is to run your Android test on any device. Therefore add another device and instrument and deploy the application under test, as described earlier in this chapter.
Make sure to add a ‘Close Application’ action, when running your test on different devices, because if the app will not be closed on the devices, the app on the first identified device will be automated.
Add a ‘Close Application’ action to ensure that the recording will be executed on the right device
After doing so, make the ‘Device Display Name’ of the ‘Run Mobile App’ action in your recording variable.
Make the Device, the test will be executed, variable
After making the device variable, open the ‘Data Source’ dialog of the test case holding your recording and add a new simple data table holding the names of the devices you want to run the test on.
Open data source dialog…
Add a simple data table…
And add the device names to the simple data table
After doing so, switch to the ‘Data Binding’ tab and bind the data source to the variable in your recording.
Bind the data source to the variable
Have a look at ⇢Data-driven testing if you want to learn more about the data-driven approach of testing.
Now, the test suite is prepared for running the recording on different devices. After successfully running the test, the test report should look something like the following.
Successfully executed test on two devices
Run Tests in parallel
It’s also possible to run one test on multiple devices at the same time.
As there is no need to have a data source, disable the previously created data source in the test case properties.
Disable data source
Add a global parameter and bind it to the variable ‘varMobileDevice’.
Add global parameter
Bind variable to global parameter
Open advanced RanoreXPath editor
Additional to the title add the device name to the RanoreXPath and choose the variable ‘varMobileDevice’ as value.
Add variable device name to RanoreXPath
After performing these steps you can build your test suite and execute the test case from command line using the command line arguments to set the mobile device name as described in section “Lesson 4: Ranorex Test Suite – Running Tests without Ranorex Studio”:
start MobileTest.exe /pa:globalMobileDevice=”Galaxy Nexus”
start MobileTest.exe /pa:globalMobileDevice=”GT-P7500″