NOTICE: Our Community is moving. Get more information. Updated information on a New Login Process
When testing a native application on an Android device, Silk Test creates a connection string which defines the device and app to be used for testing. The “app” component of the connection string is used to specify the location of the Android apk file to be deployed to the Android device for testing. For example:sConnectionString = "deviceName=Nexus 7;platformName=Android;host=localhost;app=C:\MyMobileApps\InsuranceMobile.apk"
If you do not wish to specify the apk file in the connection string, you can use a combination of appActivity and appPackage. This article will demonstrate how you can use Android SDK commands to retrieve the appActivity and appPackage of the installed app on your mobile device.
This article will use the android adb command, therefore you will be required to download the Android SDK (Android SDK Tools). Alternatively you can use the adb.exe that is installed with Silk Test:- (%OPEN_AGENT_HOME%\mobile\windows\AndroidTools\platform-tools\).
4Test Code Example
See example testcase below that uses custom function "GetPackageInfo()". This will return the appActivity and appPackage of an android apk that is installed on a specified device. This function takes 2 parameters:
sAppName - This is the name of the android app (Eg - InsuranceMobile).sDeviceName (Optional) - This is the name of the device that the app is installed on. This is an optional parameter, and is useful if you have multiple android devices connected to your machine or remote location.
[-] testcase ReturnAppDetails() appstate none [ ] // If you wish to return the appActivity and appPackage of your "InsuranceMobile" app [ ] GetPackageInfo("InsuranceMobile")[-] testcase ReturnAppDetails() appstate none [ ] // If you wish to return the appActivity and appPackage of your "InsuranceMobile" app that is installed on your "Nexus 7" device [ ] GetPackageInfo("InsuranceMobile", "Nexus 7")
The above testcases will return the following result:-
[-] Testcase ReturnAppDetails - Passed [ ] App Package = silktest.insurancemobile [ ] App Activity = silktest.insurancemobile.LoginActivity
I can now edit my connection string to use the appPackage and appActivity instead of specifying the physical apk file:-sConnectionString = "deviceName=Nexus 7;platformName=Android;host=localhost;appActivity=.LoginActivity;appPackage=silktest.insurancemobile"
Please see attached script.t file that contains the GetPackageInfo() function