Step 1: Make sure both your host computer and Android device are on the same Wifi network.
Step 2: Connect the Android device to the computer using your USB cable. As soon as you do
that, your host computer will detect your device and adb will start running in the USB mode
on the computer. You can check the attached devices with adb devices
.
Step 3: Restart adb in tcpip mode with this command:
adb tcpip 5555
Step 4: Find out the IP address of the Android device. There are several ways to do that:
Go to Settings -> About phone/tablet -> Status -> IP address.
Go to the list of Wi-fi networks available. The one to which you’re connected, tap on that and
get to know your IP.Try $ adb shell netcfg.
Enter following command to connect device over same wifi
adb connect 192.168.31.219:5555
Step 5: Remove the USB cable and you should be connected to your device. Try using adb devices
and you will see that the device is still connected to your system.
Step 6: Now open you test class and change/add the “deviceId” to the desired capabilities.
capabilities.setCapability("deviceId", "IP Address:5555");
//In this case:
capabilities.setCapability("deviceId", "192.168.31.219:5555");
Step 7: Now try to run your test scripts. The tests will run on the wireless connected device
without any issues.