Connect Mobile using Android Debug Bridge (ADB) over USB
Using real android mobile device for automation or manual testing is challenge for testers. But, Android offers a great solution to connect a real device over USB using ADB tool. It helps in getting adb logs for debugging, automation or to mirror the screen.
Using real android mobile device for automation or manual testing is challenge for testers. But, Android offers a great solution to connect a real device over USB using ADB tool. It helps in getting adb logs for debugging, automation or to mirror the screen.
Android Debug Bridge (adb) is a versatile command-line tool that lets you communicate with a device. The adb command facilitates a variety of device actions, such as installing and debugging apps, and it provides access to a Unix shell that you can use to run a variety of commands on a device.
Let’s get started and go through step by step process of connecting your android device to PC
Enable Developer Tool on Android Device
Step 1) Go to your Android Device Settings.
Step 2) Go to About phone
Step 3) Tap multiple times on Build number to Enable Developer options.
Step 4) After couple of tap Developer option will be enabled, then search for Developer options.
Step 5) Enable USB debugging option
Step 6) On your Phone drag down the notification panel and select USB options
Step 7) Now select either ‘Transfer files’ or ‘Transfer photos (PTP)’ option
Download platform-tools to connect to Android Device
Step 1) Go to Android developer site and search for platform-tools https://developer.android.com/studio/releases/platform-tools
Step 2) Download SDK Platform-Tools for Windows
Step 3) Unzip the platform-tools folder
Step 4) Double click and open the platform-tools folder
Step 5) Inside folder hold SHIFT + Right click and then select ‘Open command window here’
Step 6) Command prompt will open with the platform-tools path
Step 7) Check connected devices
adb devices
Connect Android Phone using ADB
Step 1) Go to your Android Device Settings.
Step 2) Tap on About phone
Step 3) Tap on Status
Step 4) Note down the IP Address. It should something like 192.168.X.X
Step 5) lets connect to android phone using adb command.
adb connect 192.168.1.17
Get ADB logs
Now enter adb logcat command and you will start seeing the logs
adb logcat
Now to stop log hold CTRL + C keys on keyboard
Other commands
1) Display the date, invocation time, priority/tag, and PID of the process issuing the message.
adb logcat -v time
2) Capture log in text file
adb logcat -d > Name_of_Log_File.txt
3) Disconnect devices
adb disconnect