How to connect an Android device over a wireless network for Appium testing

During our Appium training courses, we use Android devices tethered to the PCs via USB. However, it is possible to use Appium against Android devices over the wireless network, just by using some simple ADB commands.

Step 1

Make sure the PC with Appium and the Device are on the same wireless network!

Step 2

Find out the IP address of the Android Device (Settings->About device->Status->IP Address) and make a note of this.

Step 3

Connect the Android device via USB, ensure all the device drivers are installed, open a command prompt on the PC and type:

adb devices

and press enter to check USB connectivity before proceeding.

Step 4

While still connected by USB, in a command window, type

adb tcpip 5656

(where 5656 is a user allocated port number – so can be any free port number you choose)

This will restart the adb connection to the device in TCP/IP mode

Step 5

Disconnect the device from USB

Step 6

Connect to the phone wirelessly using

adb connect 10.0.0.61:5656

at a command prompt (where 10.0.0.61 is replaced with the IP of your device that you noted in step 2)

adb wireless connectivity

Step 7

Use adb devices again to check connectivity success

Step 8

Here is how to use the Desired Capabilities to now connect and run a test wirelessly:

capabilities.setCapability (“udid”, “10.0.0.61:5656”);

where the IP address will be whatever you noted in step 2 (also shown when using adb devices)

desired capabilities wireless

For more information on our Appium courses see: Appium Training