This post discusses how to use the Android Debugging Bridge (ADB) command line tool with Eggplant Functional to communicate with an Android device.
You can now use the ADBCall() function for communicating with Android devices, so the method presented here is no longer required. However, we leave this article as a scripting example.
ADB is a command line tool that lets you communicate with an Android device that is connected over USB, or with an emulator. It allows you to pull data from the device such as application log files, memory usage data, and push and pull applications. This is very useful when doing regression testing, as you can automate the whole process, from pulling the old application from the device to pushing a new application onto the device, and then testing the application itself.
The only SenseTalk you need to use in Eggplant Functional to do this is the Shell() function, which allows you to initiate a command line call on your Eggplant Functional machine.
Step by Step: Set-up Instructions
Download and install the Android SDK on your Eggplant Functional machine here.
Connect the device to your Eggplant Functional machine via USB.
Create a script in your suite called "adb", and save the below code in that script:
put shell ("cd /Users/MaxGerrard/Documents/adb/adt-bundle-mac-x86_64-20130729/platform-tools", "./adb" && MyCommand) //Change the cd command to the path of your platform-tools folder.
shell "c:\windows\system32\cmd.exe", <</c "C:\Program Files (x86)\adt-bundle-windows-x86_64-20130522\sdk\platform-tools\adb" >> && MyCommand && "> adbexperiment.txt"
shell "c:\windows\system32\cmd.exe", <</c "C:\Program Files (x86)\adt-bundle-windows-x86_64\sdk\platform-tools\adb" >> && MyCommand && "> someFile.txt" //Change the cd command to the path of your platform-tools folder.
put file "C:\wherever\someFile.txt"
- Running an ADB command on the device is as simple as running an ADB command in your script. You simply pass in any ADB command you want to run, as shown below:
adb "devices" //Find out what devices are connected
adb "shell dumpsys meminfo -a" //Output the memory information of the device.