Whenever we work with
Android mobile app automation we have to connect the device using USB cable. We
can connect the device over Wi-Fi. To get rid of from the USB there
is a super simple way! All you need is a USB cable (for the initial setup) and
have both devices in the same network. This will work for non-rooted devices also.
Precondition:
- Your system and device must be in the same network.
- Android mobile must have developer option set to true.
- ADB (Android debug bridge) must be configure
- Android SDK installed.
Step 1. Attach mobile via USB
It will confirm that your device is connected and able to recognize by android sdk.
Step 2. Open then command terminal type adb devices and press enter
Step 3: type:
adb tcpip 5555
Step 4:To find the mobile ip type:
adb shell ip -f inet addr show wlan0
Step 5: The ip address will be shown in second line like this:
inet 192.168.1.233/24 brd 192.168.1.255 scope global wlan0
where 192.168.1.233 is the ip address of your mobile.
Step 6:Remove USB cable and type:
adb connect <mobile-ip>:5555
like:
adb connect <192.168.1.233>:5555
adb connect <192.168.1.233>:5555
Note:
- Make sure: that you do not have Android studio running before executing the - 'restart adb in tcpip mode' command
- If you have IDE running then adb may have been already started and you may need to restart it in some cases: adb kill-server; adb start-server