Using adb commands

adb (Android debug bridge) is a command-line tool that lets you communicate with Android devices. The adb command facilitates a variety of device actions, such as installing apps, granting permissions, copying files, profiling for performance etc. Learn how to achieve equivalent functionality on BrowserStack without having to use adb.

Managing applications

Install packages

ADB command: adb install [options] package_name

How to achieve this functionality on BrowserStack:

First, you must upload your apps on BrowserStack and obtain the app_url. Refer to Upload your app section to see how this can be done.

Second, mention the app_url of the uploaded app you want to install in the app capability inside the Desired capabilities object while running a new Appium test session on BrowserStack. The app you want to test will be your main app, and the apps your main app depends on need to be specified in the otherApps capability. For more info, refer to Appium capability builder

Uninstall packages

ADB command: adb uninstall package

How to achieve this functionality on BrowserStack:

You don’t have to explicitly uninstall an app after you’re done with your tests. We automatically uninstall your apps, delete the data that was added/modified during your tests and clean up the device before running another test session on that device.

If you want to uninstall the package, and reinstall it during the same session, we recommend you to reset the app instead.

Reset the app or clear package data

ADB command: adb shell pm clear package

How to achieve this functionality on BrowserStack:

You can use Appium’s reset package functionality to clear all the data associated with the app.

File Transfers

Copy a file or directory and its sub-directories to the device

ADB command: adb push local remote

How to achieve this functionality on BrowserStack:

By default, BrowserStack provides a set of pre-loaded media files on our devices you can use to test your apps. But, if you choose to use your own media files, you can upload and use them in your tests as well. You can also use Appium’s push file command to copy files into the /sdcard/Download/ folder.

For more details, please refer to our documentation for testing with sample data to use pre-loaded media files, upload custom media, or use Appium’s push file command.

Retrieve a file or directory and its sub-directories from the device

ADB command: adb pull remote local

How to achieve this functionality on BrowserStack:

If you want to take a screenshot, store it locally on the device, and retrieve it using pull command, you can use Appium’s screenshot functionality to get the screenshot in base64 or PNG format that you can write to a file locally on your machine. Refer to our documentation for taking screenshots

You can also use BrowserStack’s Screenshots functionality to generate screenshots. Just pass the browserstack.debug capability in your Appium script’s desired capability object, and BrowserStack will automatically generate screenshots at various steps in your test so that you can consume them or debug using them later. Refer to our documentation for visual logs

You can also use Appium’s pull file functionality to retrieve files from the /sdcard/Download/ folder. For more details, please refer to our documentation for testing with sample data.

Granting Permissions to Apps

Grant a permission to an app

ADB command: adb shell pm grant package_name permission

How to achieve this functionality on BrowserStack:

You can auto-grant permissions passing the autoGrantPermissions capability while starting the test.

You can also handle with the permission alerts, and click the allow button during the test.

Revoke a permission from an app

ADB command: adb shell pm revoke package_name permission

How to achieve this functionality on BrowserStack:

You cannot do this on BrowserStack at the moment.

If you need to perform your tests with limited permissions, we recommend you to run a new test session and allow / disallow the required permissions during the test by handling the permission alerts.

Debugging Options

ADB command: adb logcat [options]

How to achieve this functionality on BrowserStack:

You can access these logs in the Device Logs section of the test session page in your App Automate dashboard.

You can also retrieve these logs via the AppiumREST API.

Working with Android Activity & Animations

Start an Activity specified by intent

ADB command: adb shell am start [options] intent

How to achieve this functionality on BrowserStack:

You can use Appium’s start activity functionality to start an Android activity by providing package name and activity name.

Force stop everything associated with package

ADB command: adb shell am force-stop package

How to achieve this functionality on BrowserStack:

You can use Appium’s close app functionality to force stop and close your application.

Remember that you can only force stop your main application (specified by the app capability ), but not the applications your main application depends on (the ones specified in otherApps capability).

Disable system animations to speed up your tests and improve stability

ADB command: adb shell am instrument --no-window-animation [options]

How to achieve this functionality on BrowserStack:

You can now use Appium’s capability disableWindowAnimation to disable system’s window animations.

Remember that you need to also set the browserstack.appium_version capability to 1.9.1 or later because this capability is not available in the older versions of Appium.

Screen Capture & Recording

Capture a screenshot and save it to file

ADB command: adb shell screencap filename

How to achieve this functionality on BrowserStack:

You use BrowserStack’s Screenshots functionality to generate screenshots. Just pass the browserstack.debug capability in your tests’ desired capabilities, and BrowserStack will automatically generate screenshots at various steps in your test so that you can consume them or debug using them later.

You can use Appium’s screenshot functionality to get the screenshot in base64 or PNG format that you can write to a file locally on your machine.

Record display of devices

ADB command: adb shell screenrecord [options] filename

How to achieve this functionality on BrowserStack:

You can use browserstack.video capability in your tests’ desired capabilities if you want to enable video recording during your test.

App Profiling

Understand battery consumption, memory, CPU utilization & network performance

ADB command: adb dumpsys [options]

How to achieve this functionality on BrowserStack:

You can get this information from your App Automate dashboard on the test session page.

Note: App profiling is only available for Android.

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

Is this page helping you?

Yes
No

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!

Talk to an Expert
Talk to an Expert