ADB Concepts : How to Capture Screenshots of Android Devices Using ADB Commands

Get a step-by-step walkthrough in the video below!
To take a screenshot of the current display on our mobile device, we can use the following command:
Command:
adb shell screencap <path_to_file>
Example1:
adb shell screencap /sdcard/download/appiumguide.png
Explanation:
adb shell: is the command used to execute commands on an Android device.
Screencap: is the command used to capture a screenshot of the current display.
Path_to_file: specifies the location and name of the file where the screenshot will be saved

Output: Screenshot

Example2:
Steps to Capture a Screenshot
1. Connect your device
adb devices
This should list your connected device. If not, ensure USB Debugging is enabled and authorized.
2. Capture the screenshot
$ adb shell
shell@ $ screencap /sdcard/download/appiumguide.png
shell@ $ exit
This command tells the device to take a screenshot and save it to the internal storage.
Example:

3. Pull the screenshot to your computer
$ adb pull /sdcard/download/appiumguide.png C:\Users\SWETHARAMESH\Desktop\AppiumGuide\Inprogress\adbconcepts\PullFile\ramesh.png
This copies the screenshot to your current directory on your computer.
Example:

Output: Screenshot

GitHub Link:
No comments:
Post a Comment