Android | Robotium: Get Android Version and Device Details Programmatically
|While working with Android we might face some situations where we have to write device specific code. e.g Some code goes if running on Emulator and Some other code goes if running on Real device.
This is very much useful while working with Test automation framework : Robotium
While developing test scripts to specify some code which is intended to be executed in Emulator or Real device specifically, or to reflect the details in test reports etc these functions are useful.
Procedure to get Android Version of the device along with Device type(Emulator/Real Device)
Check if device is Emulator or Real device
Boolean deviceType = “google_sdk”.equals(android.os.Build.PRODUCT);
So our stuffs may go like this:
{
//Do this that intended for Emulator
}
else
{
//Do this that intended for Real Device
} android.os.Build.VERSION.RELEASE : Returns Android Version number as a string. e.g 4.1.1
android.os.Build.VERSION.SDK_INT: Returns Android SDK version number as a string e.g 16 “google_sdk”.equals(android.os.Build.PRODUCT): returns Boolean value as true if device is Emulator and vice-versa android.os.Build.MANUFACTURER: returns a String containing the Manufacturer name. android.os.Build.MODEL: Returns the model number of the device as String.
- Bring the auto Sync magic of Protractor to Selenium with Java - October 23, 2015
- Restarting Appium Server could improve various server freezing issues and may improve execution time - January 20, 2015
- Appium with iOS 8 and XCode 6 : What’s new? - November 5, 2014
- REST API automation testing using Apache HttpClient – The Approach - October 3, 2014
- An Overview of mobile application : Moving forward to automation - October 1, 2014
- An introduction to REST - September 29, 2014
- Run ChromeDriver with Chrome Driver Service to reduce script execution time significantly - September 26, 2014
- Selenium WebDriver – Get Cookies from an existing session and add those to a newly instantiated WebDriver browser instance. - September 26, 2014
- Simulate Copy Paste action using Java Robot and Clipboard class - September 26, 2014
- Android : How to test if Android Application has memory leaks - August 11, 2014