Test using adb
Android Debug Bridge (adb) is a robust command-line tool that allows you to communicate with a connected Android device. Using adb
commands, you can perform a variety of device actions, such as installing apps, granting permissions, profiling for performance, etc.
In this guide, you will learn the following:
- ADB Commands use cases in an App Automate session
- Achieve Equivalent functionalities without using ADB Commands
ADB Commands use cases
For security reasons, we launch the appium server on our platform with --relaxed-security
setting off. This means that we won’t be able to support execution of ADB shell commands using the mobile: shell
appium command. More details in Appium documentation. However, we provide custom implementation to run certain useful ADB commands on our Android devices.
This section provides details on how to run adb commands for the following use cases in an App Automate session:
- Log and Debug Firebase Analytics events
- Log Google Analytics events
- Set system-level preferences using settings commands
- Get diagnostic output for system services using dumpsys commands
- Get system and device properties using getprop commands
Currently, we support only those adb commands that have been mentioned in this guide.
browserstack.devicePreferences
capability in your tests.
Log and Debug Firebase Analytics events
Log Events
You can set verbose logging to monitor the logs of Firebase events using the following adb shell setprop
commands:
adb shell setprop log.tag.FA VERBOSE
adb shell setprop log.tag.FA-SVC VERBOSE
In order to achieve this functionality in App Automate, use the browserstack.devicePreferences capability in your test sessions and set the log.tag.FA
and log.tag.FA-SVC
tags to VERBOSE
inside the setprop
object. The following code snippet demonstrates how to do this:
DesiredCapabilities capabilities = new DesiredCapabilities();
HashMap<String, Object> browserstackOptions = new HashMap<String, Object>();
HashMap<String, Object> devicePreferences = new HashMap<String, Object>();
HashMap<String, String> setProp = new HashMap<>();
setProp.put("log.tag.FA", "VERBOSE");
setProp.put("log.tag.FA-SVC", "VERBOSE");
devicePreferences.put("setprop", setProp);
browserstackOptions.put("devicePreferences", devicePreferences);
capabilities.setCapability("bstack:options", browserstackOptions);
var capabilities = {
"bstack:options": {
"devicePreferences": {
"setprop" : {
"log.tag.FA" : "VERBOSE",
"log.tag.FA-SVC" : "VERBOSE"
}
}
}
}
desired_cap = {
"bstack:options": {
"devicePreferences": {
"setprop" : {
"log.tag.FA" : "VERBOSE",
"log.tag.FA-SVC" : "VERBOSE"
}
}
}
}
desired_cap = {
"bstack:options"=> {
"devicePreferences"=> {
"setprop" => {
"log.tag.FA" => "VERBOSE",
"log.tag.FA-SVC" => "VERBOSE"
}
}
}
}
AppiumOptions capabilities = new AppiumOptions();
Dictionary<string, object> browserstackOptions = new Dictionary<string, object>();
Dictionary<string, object> devicePreferences = new Dictionary<string, object>();
Dictionary<string, string> setProp = new Dictionary<>();
setProp.Add("log.tag.FA", "VERBOSE");
setProp.Add("log.tag.FA-SVC", "VERBOSE");
devicePreferences.Add("setprop", setProp);
browserstackOptions.Add("devicePreferences", devicePreferences);
capabilities.AddAdditionalCapability("bstack:options", browserstackOptions);
DesiredCapabilities capabilities = new DesiredCapabilities();
HashMap<String, Object> devicePreferences = new HashMap<String, Object>();
HashMap<String, String> setProp = new HashMap<>();
setProp.put("log.tag.FA", "VERBOSE");
setProp.put("log.tag.FA-SVC", "VERBOSE");
devicePreferences.put("setprop", setProp);
capabilities.setCapability("browserstack.devicePreferences", devicePreferences);
var capabilities = {
"browserstack.devicePreferences": {
"setprop" : {
"log.tag.FA" : "VERBOSE",
"log.tag.FA-SVC" : "VERBOSE"
}
}
}
desired_cap = {
"browserstack.devicePreferences": {
"setprop" : {
"log.tag.FA" : "VERBOSE",
"log.tag.FA-SVC" : "VERBOSE"
}
}
}
desired_cap = {
"browserstack.devicePreferences"=> {
"setprop" => {
"log.tag.FA" => "VERBOSE",
"log.tag.FA-SVC" => "VERBOSE"
}
}
}
AppiumOptions capabilities = new AppiumOptions();
Dictionary<string, object> devicePreferences = new Dictionary<string, object>();
Dictionary<string, string> setProp = new Dictionary<>();
setProp.Add("log.tag.FA", "VERBOSE");
setProp.Add("log.tag.FA-SVC", "VERBOSE");
devicePreferences.Add("setprop", setProp);
capabilities.AddAdditionalCapability("browserstack.devicePreferences", devicePreferences);
Upon setting this capability in your tests, logs for Firebase events will start appearing under device logs. You can capture the complete logs by using driver.manage().logs().get("logcat").filter(Level.ALL);
command and then filter out the firebase events for your app in your test.
Debug Events
You can enable the debug mode for Firebase Analytics on an Android device by using the following adb shell setprop
command:
adb shell setprop debug.firebase.analytics.app <PACKAGE_NAME>
To achieve this functionality in App Automate, use the browserstack.devicePreferences capability in your test sessions and set the debug.firebase.analytics.app
value to your package_name
inside the setprop
object. The following code snippet demonstrates how to do this:
DesiredCapabilities capabilities = new DesiredCapabilities();
HashMap<String, Object> browserstackOptions = new HashMap<String, Object>();
HashMap<String, Object> devicePreferences = new HashMap<String, Object>();
HashMap<String, String> setProp = new HashMap<>();
setProp.put("debug.firebase.analytics.app", "<your_package_name>");
devicePreferences.put("setprop", setProp);
browserstackOptions.put("devicePreferences", devicePreferences);
capabilities.setCapability("bstack:options", browserstackOptions);
var capabilities = {
"bstack:options": {
"devicePreferences": {
"setprop" : {
"debug.firebase.analytics.app" : "<your_package_name>"
}
}
}
}
desired_cap = {
"bstack:options": {
"devicePreferences": {
"setprop" : {
"debug.firebase.analytics.app" : "<your_package_name>"
}
}
}
}
desired_cap = {
"bstack:options"=> {
"devicePreferences"=> {
"setprop" => {
"debug.firebase.analytics.app" => "<your_package_name>"
}
}
}
}
AppiumOptions capabilities = new AppiumOptions();
Dictionary<string, object> browserstackOptions = new Dictionary<string, object>();
Dictionary<string, object> devicePreferences = new Dictionary<string, object>();
Dictionary<string, string> setProp = new Dictionary<>();
setProp.Add("debug.firebase.analytics.app", "<your_package_name>");
devicePreferences.Add("setprop", setProp);
browserstackOptions.Add("devicePreferences", devicePreferences);
capabilities.AddAdditionalCapability("bstack:options", browserstackOptions);
DesiredCapabilities capabilities = new DesiredCapabilities();
HashMap<String, Object> devicePreferences = new HashMap<String, Object>();
HashMap<String, String> setProp = new HashMap<>();
setProp.put("debug.firebase.analytics.app", "<your_package_name>");
devicePreferences.put("setprop", setProp);
capabilities.setCapability("browserstack.devicePreferences", devicePreferences);
var capabilities = {
"browserstack.devicePreferences": {
"setprop" : {
"debug.firebase.analytics.app" : "<your_package_name>"
}
}
}
desired_cap = {
"browserstack.devicePreferences": {
"setprop" : {
"debug.firebase.analytics.app" : "<your_package_name>"
}
}
}
desired_cap = {
"browserstack.devicePreferences"=> {
"setprop" => {
"debug.firebase.analytics.app" => "<your_package_name>"
}
}
}
AppiumOptions capabilities = new AppiumOptions();
Dictionary<string, object> devicePreferences = new Dictionary<string, object>();
Dictionary<string, string> setProp = new Dictionary<>();
setProp.Add("debug.firebase.analytics.app", "<your_package_name>");
devicePreferences.Add("setprop", setProp);
capabilities.AddAdditionalCapability("browserstack.devicePreferences", devicePreferences);
Upon setting this capability in your tests, your test session will begin on a device where debug mode has been enabled. You can then navigate to DebugView to view your app’s events being logged in the DebugView report.
Log Google Analytics events
You can enable the log feature of Google Analytics events by using the following adb shell setprop
command:
adb shell setprop log.tag.GAv4 DEBUG
To achieve this functionality in App Automate, use the browserstack.devicePreferences capability in your test sessions and set the log.tag.GAv4
tag to any of the log filter types such as DEBUG
, VERBOSE
, INFO
etc inside the setprop
object. The following code snippet demonstrates how to do this:
DesiredCapabilities capabilities = new DesiredCapabilities();
HashMap<String, Object> browserstackOptions = new HashMap<String, Object>();
HashMap<String, Object> devicePreferences = new HashMap<String, Object>();
HashMap<String, String> setProp = new HashMap<>();
setProp.put("log.tag.GAv4", "DEBUG");
devicePreferences.put("setprop", setProp);
browserstackOptions.put("devicePreferences", devicePreferences);
capabilities.setCapability("bstack:options", browserstackOptions);
var capabilities = {
"bstack:options": {
"devicePreferences": {
"setprop" : {
"log.tag.GAv4" : "DEBUG"
}
}
}
}
desired_cap = {
"bstack:options": {
"devicePreferences": {
"setprop" : {
"log.tag.GAv4" : "DEBUG"
}
}
}
}
desired_cap = {
"bstack:options" => {
"devicePreferences"=> {
"setprop" => {
"log.tag.GAv4" => "DEBUG"
}
}
}
}
AppiumOptions capabilities = new AppiumOptions();
Dictionary<string, object> browserstackOptions = new Dictionary<string, object>();
Dictionary<string, object> devicePreferences = new Dictionary<string, object>();
Dictionary<string, string> setProp = new Dictionary<>();
setProp.Add("log.tag.GAv4", "DEBUG");
devicePreferences.Add("setprop", setProp);
browserstackOptions.Add("devicePreferences", devicePreferences);
capabilities.AddAdditionalCapability("bstack:options", browserstackOptions);
DesiredCapabilities capabilities = new DesiredCapabilities();
HashMap<String, Object> devicePreferences = new HashMap<String, Object>();
HashMap<String, String> setProp = new HashMap<>();
setProp.put("log.tag.GAv4", "DEBUG");
devicePreferences.put("setprop", setProp);
capabilities.setCapability("browserstack.devicePreferences", devicePreferences);
var capabilities = {
"browserstack.devicePreferences": {
"setprop" : {
"log.tag.GAv4" : "DEBUG"
}
}
}
desired_cap = {
"browserstack.devicePreferences": {
"setprop" : {
"log.tag.GAv4" : "DEBUG"
}
}
}
desired_cap = {
"browserstack.devicePreferences"=> {
"setprop" => {
"log.tag.GAv4" => "DEBUG"
}
}
}
DesiredCapabilities capabilities = new DesiredCapabilities();
Dictionary<string, object> devicePreferences = new Dictionary<string, object>();
Dictionary<string, string> setProp = new Dictionary<>();
setProp.Add("log.tag.GAv4", "DEBUG");
devicePreferences.Add("setprop", setProp);
capabilities.SetCapability("browserstack.devicePreferences", devicePreferences);
Upon setting this capability in your tests, logs for Google Analytics events will start appearing under device logs. You can capture the complete logs by using driver.manage().logs().get("logcat").filter(Level.ALL);
command and then filter out the Google Analytics events for your app in your test.
Set system-level preferences using settings commands
The adb shell settings put
commands can be used to set system-level device preferences such as disabling pop-up notifications, disabling location services, changing device orientation etc.
The following table lists all the adb shell settings put
commands that are supported in App Automate:
Command | Description | Allowed Values |
---|---|---|
adb shell settings put secure location_mode 0 |
Enable/Disable location services on an android device | Disable: 0 Enable: 3 |
adb shell settings put global heads_up_notifications_enabled 0 |
Enable/Disable pop-up notifications on an android device | Disable: 0 Enable: 1 |
adb shell settings put global always_finish_activities 0 |
Enable/Disable aggressive finishing of activities and processes | Disable: 0 Enable: 1 |
adb shell settings put system accelerometer_rotation 0 |
Enable/Disable auto-rotation of the device | Disable: 0 Enable: 1 |
adb shell settings put system user_rotation 3 |
Rotate the device | 0° clockwise rotation: 0 90° clockwise rotation: 1 180° clockwise rotation: 2 270° clockwise rotation: 3 |
location_mode
setting can only be used on API level 19 (Android Version 4.4) to API level 28 (Android Version 9) devices.
To execute these commands, use the browserstack.devicePreferences capability in your tests and set the required settings to your desired values inside the appropriate setting type object. The following table shows the BrowserStack compatible JSON-object format for the settings:
Command | BrowserStack Compatible JSON input |
---|---|
adb shell settings put secure location_mode 0 |
{“browserstack.devicePreferences”: { “settings.secure”: { “locationMode” : 0}}} |
adb shell settings put global heads_up_notifications_enabled 0 |
{“browserstack.devicePreferences”: { “settings.global”: { “headsUpNotificationsEnabled” : 0}}} |
adb shell settings put global always_finish_activities 0 |
{“browserstack.devicePreferences”: { “settings.global”: { “alwaysFinishActivities” : 0}}} |
adb shell settings put system accelerometer_rotation 0 |
{“browserstack.devicePreferences”: { “settings.system”: { “accelerometerRotation” : 0}}} |
adb shell settings put system user_rotation 3 |
{“browserstack.devicePreferences”: { “settings.system”: { “userRotation” : 3}}} |
The following code snippet demonstrates how to run your tests on a device where all the above mentioned settings have been set:
DesiredCapabilities capabilities = new DesiredCapabilities();
HashMap<String, Object> browserstackOptions = new HashMap<String, Object>();
HashMap<String, Object> devicePreferences = new HashMap<String, Object>();
HashMap<String, Integer> settingsGlobal = new HashMap<>();
settingsGlobal.put("headsUpNotificationsEnabled", 0);
settingsGlobal.put("alwaysFinishActivities", 0);
devicePreferences.put("settings.global", settingsGlobal);
HashMap<String, Integer> settingsSecure = new HashMap<>();
settingsSecure.put("locationMode", 0);
devicePreferences.put("settings.secure", settingsSecure);
HashMap<String, Integer> settingsSystem = new HashMap<>();
settingsSystem.put("accelerometerRotation", 0);
settingsSystem.put("userRotation", 3);
devicePreferences.put("settings.system", settingsSystem);
browserstackOptions.put("devicePreferences", devicePreferences);
capabilities.setCapability("bstack:options", browserstackOptions);
var capabilities = {
"bstack:options": {
"devicePreferences": {
"settings.global": {
"headsUpNotificationsEnabled": 0,
"alwaysFinishActivities" : 0
},
"settings.secure": {
"locationMode" : 0
},
"settings.system": {
"accelerometerRotation" : 0,
"userRotation" : 3
}
}
}
}
desired_cap = {
"bstack:options": {
"devicePreferences": {
"settings.global": {
"headsUpNotificationsEnabled": 0,
"alwaysFinishActivities" : 0
},
"settings.secure": {
"locationMode" : 0
},
"settings.system": {
"accelerometerRotation" : 0,
"userRotation" : 3
}
}
}
}
desired_cap = {
"bstack:options" => {
"devicePreferences" => {
"settings.global"=> {
"headsUpNotificationsEnabled"=> 0,
"alwaysFinishActivities" => 0
},
"settings.secure"=> {
"locationMode" => 0
},
"settings.system"=> {
"accelerometerRotation" => 0,
"userRotation" => 3
}
}
}
}
AppiumOptions capabilities = new AppiumOptions();
Dictionary<string, object> browserstackOptions = new Dictionary<string, object>();
Dictionary<string, object> devicePreferences = new Dictionary<string, object>();
Dictionary<string, int> settingsGlobal = new Dictionary<>();
settingsGlobal.Add("headsUpNotificationsEnabled", 0);
settingsGlobal.Add("alwaysFinishActivities", 0);
devicePreferences.Add("settings.global", settingsGlobal);
Dictionary<string, int> settingsSecure = new Dictionary<>();
settingsSecure.Add("locationMode", 0);
devicePreferences.Add("settings.secure", settingsSecure);
Dictionary<string, int> settingsSystem = new Dictionary<>();
settingsSystem.Add("accelerometerRotation", 0);
settingsSystem.Add("userRotation", 3);
devicePreferences.Add("settings.system", settingsSystem);
browserstackOptions.Add("devicePreferences", devicePreferences);
capabilities.AddAdditionalCapability("bstack:options", browserstackOptions);
DesiredCapabilities capabilities = new DesiredCapabilities();
HashMap<String, Object> devicePreferences = new HashMap<String, Object>();
HashMap<String, Integer> settingsGlobal = new HashMap<>();
settingsGlobal.put("headsUpNotificationsEnabled", 0);
settingsGlobal.put("alwaysFinishActivities", 0);
devicePreferences.put("settings.global", settingsGlobal);
HashMap<String, Integer> settingsSecure = new HashMap<>();
settingsSecure.put("locationMode", 0);
devicePreferences.put("settings.secure", settingsSecure);
HashMap<String, Integer> settingsSystem = new HashMap<>();
settingsSystem.put("accelerometerRotation", 0);
settingsSystem.put("userRotation", 3);
devicePreferences.put("settings.system", settingsSystem);
capabilities.setCapability("browserstack.devicePreferences", devicePreferences);
var capabilities = {
"browserstack.devicePreferences": {
"settings.global": {
"headsUpNotificationsEnabled": 0,
"alwaysFinishActivities" : 0
},
"settings.secure": {
"locationMode" : 0
},
"settings.system": {
"accelerometerRotation" : 0,
"userRotation" : 3
}
}
}
desired_cap = {
"browserstack.devicePreferences": {
"settings.global": {
"headsUpNotificationsEnabled": 0,
"alwaysFinishActivities" : 0
},
"settings.secure": {
"locationMode" : 0
},
"settings.system": {
"accelerometerRotation" : 0,
"userRotation" : 3
}
}
}
desired_cap = {
"browserstack.devicePreferences"=> {
"settings.global"=> {
"headsUpNotificationsEnabled"=> 0,
"alwaysFinishActivities" => 0
},
"settings.secure"=> {
"locationMode" => 0
},
"settings.system"=> {
"accelerometerRotation" => 0,
"userRotation" => 3
}
}
}
AppiumOptions capabilities = new AppiumOptions();
Dictionary<string, object> devicePreferences = new Dictionary<string, object>();
Dictionary<string, int> settingsGlobal = new Dictionary<>();
settingsGlobal.Add("headsUpNotificationsEnabled", 0);
settingsGlobal.Add("alwaysFinishActivities", 0);
devicePreferences.Add("settings.global", settingsGlobal);
Dictionary<string, int> settingsSecure = new Dictionary<>();
settingsSecure.Add("locationMode", 0);
devicePreferences.Add("settings.secure", settingsSecure);
Dictionary<string, int> settingsSystem = new Dictionary<>();
settingsSystem.Add("accelerometerRotation", 0);
settingsSystem.Add("userRotation", 3);
devicePreferences.Add("settings.system", settingsSystem);
devicePreferences.Add("settings.global", settingsGlobal);
capabilities.AddAdditionalCapability("browserstack.devicePreferences", devicePreferences);
Get diagnostic output for system services using dumpsys commands
dumpsys is a tool that runs on Android devices and offers information on system services. adb shell dumpsys
commands provide vital diagnostic output for system services operating on a connected device.
The following table lists all the dumpsys
commands that can be used in an App Automate session:
Command | Description |
---|---|
adb shell dumpsys activity -p <package_name> |
Provides complete activity history for the given package |
adb shell dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp' |
Prints current app’s opened activity |
adb shell dumpsys activity -p <package_name> activities |
Provides activity manager activities that contain main stack, running activities and recent tasks |
adb shell dumpsys activity -p <package_name> activities | grep -E ‘mResumedActivity’ |
Prints current app’s resumed activity |
adb shell dumpsys activity -p <package_name> services |
Provides list of services running for the given package |
adb shell dumpsys activity -p <package_name> providers |
Provides list of current content providers for the given package |
adb shell dumpsys activity -p <package_name> recents |
Provides list of recent tasks for the given package |
adb shell dumpsys activity -p <package_name> broadcasts |
Provides list of broadcast states for the given package |
adb shell dumpsys activity -p <package_name> intents |
Provides list of pending intents for the given package |
adb shell dumpsys activity -p <package_name> permissions |
Provides list of permissions for the given package |
adb shell dumpsys activity -p <package_name> processes |
Provides list of running processes for the given package |
Command | Description |
---|---|
adb shell dumpsys gfxinfo <package_name> |
Gathers UI performance data for a specified package name |
adb shell dumpsys gfxinfo <package_name> framestats |
Provides even more detailed frame timing information from recent frames |
adb shell dumpsys gfxinfo <package_name> reset |
Resets the framemetrics data |
Command | Description |
---|---|
adb shell dumpsys input |
Dumps the state of the system’s input devices, such as keyboards and touchscreens, and the processing of input events |
Command | Description |
---|---|
adb shell dumpsys cpuinfo |
Provides info on CPU usage |
adb shell dumpsys display |
Provides info on display |
adb shell dumpsys power |
Provides info on power statistics |
adb shell dumpsys alarm |
Provides info on alarm |
adb shell dumpsys location |
Provides info on location |
adb shell dumpsys window displays |
Provides info like pixel resolution, FPS, and DPI of the device’s display |
adb shell dumpsys telephony.registry |
Gives information about wireless communication related parameters |
adb shell dumpsys bluetooth_manager |
Gives information about connected bluetooth devices, mac addresses etc. |
Command | Description |
---|---|
adb shell dumpsys netstats |
Displays network connections for the Transmission Control Protocol for both incoming and outgoing requests |
adb shell dumpsys netstats detail |
Outputs additional information, such as detailed unique user ID (UID) information |
adb shell dumpsys connectivity |
Provides the internet status and connectivity mode(cellular or Wi-Fi) |
adb shell dumpsys netpolicy |
Generates a report that includes the current global background network restriction setting, package UIDs that are currently allowed to bypass Data Saver, and the network permissions of other known packages |
adb shell dumpsys network_management |
Provides all information about device network management |
Command | Description |
---|---|
adb shell dumpsys batterystats options |
Generates interesting statistical data about battery usage on a device, organized by unique user ID (UID) |
adb shell dumpsys batterystats --charged <package_name> |
Outputs battery usage statistics for a specified app package since the device was last charged |
adb shell dumpsys batterystats --checkin |
Output in machine-readable CSV format |
Command | Description |
---|---|
adb shell dumpsys procstats --hours <hour> |
Provides info on how your app is behaving over time—including how long it runs in the background and how much memory it uses during that time |
adb shell dumpsys meminfo <package_name|pid> |
Record a snapshot of how your app’s memory is divided between different types of RAM allocation |
adb shell dumpsys meminfo <package_name|pid> [-d] |
The -d flag prints more info related to Dalvik and ART memory usage |
Command | Description |
---|---|
adb shell dumpsys package <package_name> |
Provides all the info about your app, ex: Version name/code, first install time, last update time, requested permissions, etc |
Use the following code snippets to call the dumpsys
commands from your test script:
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("browserstack_executor: {
\"action\":\"adbShell\",
\"arguments\": {
\"command\" : \"dumpsys gfxinfo <package_name>\"
}
}"
);
await driver.execute("browserstack_executor: {
\"action\":\"adbShell\",
\"arguments\": {
\"command\" : \"dumpsys gfxinfo <package_name>\"
}
}"
);
driver.execute_script("browserstack_executor: {
\"action\":\"adbShell",
\"arguments\": {
\"command\" : \"dumpsys gfxinfo <package_name>\"
}
}"
);
caps["javascriptEnabled"] = "true" #include this capability for JavaScript Executors to work
driver.execute_script("browserstack_executor: {
\"action\":\"adbShell\",
\"arguments\": {
\"command\" : \"dumpsys gfxinfo <package_name>\"
}
}"
);
((IJavaScriptExecutor)driver).ExecuteScript("browserstack_executor: {
\"action\":\"adbShell\",
\"arguments\": {
\"command\" : \"dumpsys gfxinfo <package_name>\"
}
}"
);
The output of the above-mentioned dumpsys
commands would be captured under text logs on the App Automate dashboard.
For grep commands like
adb shell dumpsys activity -p <package_name> activities | grep -E 'mResumedActivity'
, please ensure that the JSON is in one of the following formats:
driver.execute_script("browserstack_executor: {\"action\":\"adbShell\", \"arguments\": {\"command\" : \"dumpsys activity -p <package_name> activities | grep -E \\\"mResumedActivity\\\"\"}}")
driver.execute_script('browserstack_executor: {"action":"adbShell", "arguments": {"command" : "dumpsys activity -p <package_name> activities | grep -E \"mResumedActivity\""}}')
Get system and device properties using getprop commands
The adb shell getprop
commands can be used to get system and device properties such as Sim Operator, device model, Android version etc.
The following table lists all the getprop
commands that can be called in an App Automate session:
Command | Description |
---|---|
adb shell getprop -T |
Provides a list of system property types |
adb shell getprop gsm.sim.operator.alpha |
Provides SIM Operator |
adb shell getprop ro.build.version.release |
Provides device android version |
adb shell getprop ro.boot.wifimacaddr |
Provides the WiFi Mac Address |
adb shell getprop ro.product.manufacturer |
Provides Android device manufacturer details |
adb shell getprop ro.vendor.product.model |
Provides Android device product number |
adb shell getprop ro.board.platform |
Provides Soc info |
adb shell getprop ro.oem_unlock_supported |
Provides OEM unlock status |
adb shell getprop ro.vendor.product.model |
Provides device model |
adb shell getprop ro.bootimage.build.fingerprint |
Provides Android device build fingerprint |
adb shell getprop ro.cdma.home.operator.alpha |
Provides SIM operator name |
adb shell getprop ro.system.build.version.sdk |
Provides API level |
adb shell getprop -T
command can only be used on Android devices with version 8.1 and above.
Use the following code snipptes to call the getprop
commands from your test script:
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("browserstack_executor: {
\"action\":\"adbShell\",
\"arguments\": {
\"command\" : \"getprop ro.system.build.version.sdk\"
}
}"
);
await driver.execute("browserstack_executor: {
\"action\":\"adbShell\",
\"arguments\": {
\"command\" : \"getprop ro.system.build.version.sdk\"
}
}"
);
driver.execute_script("browserstack_executor: {
\"action\":\"adbShell\",
\"arguments\": {
\"command\" : \"getprop ro.system.build.version.sdk\"
}
}"
);
caps["javascriptEnabled"] = "true" #include this capability for JavaScript Executors to work
driver.execute_script("browserstack_executor: {
\"action\":\"adbShell\",
\"arguments\": {
\"command\" : \"getprop ro.system.build.version.sdk\"
}
}"
);
((IJavaScriptExecutor)driver).ExecuteScript("browserstack_executor: {
\"action\":\"adbShell\",
\"arguments\": {
\"command\" : \"getprop ro.system.build.version.sdk\"
}
}"
);
The output of the above-mentioned getprop
commands would be captured under text logs on the App Automate dashboard.
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback!