How to run Appium tests on Android devices over Wi-Fi?

I just had release cycle completed and had to run sanity pack for mobile as well as a desktop application.  That day, unfortunately, I missed the cable at home because I was doing deployment till late at night. In such a case, I had to figure out some way so that I could run our Appium tests for Sanity run. Thus, I thought to connect our Android devices over Wi-Fi. It was just a little instance when I started Appium tests over Wi-Fi. Your case could be different, such as, when you want to run mobile tests over different devices and you don’t have the cable so in such case you can distribute few with cable and few over Wi-Fi.

Does it make sense?

Yes.

The agenda of this article is to teach you how to run Appium test cases on Android devices over Wi-Fi. Before that, I would recommend you some fundamental articles on Appium. So let’s have a look at them:

For more Appium Tutorials, Click here.

Step by Step guide to connect Android Devices over Wi-Fi to run Appium Tests

Follow the steps below to connect your Android devices over Wi-Fi.

Step# 1: Check connected devices

Command: adb devices

Use the above command to check how many devices are connected with your machine.

adb devices for Appium tests

Step# 2: Validate Wi-Fi Connection

You should make sure that your Android devices and machine are both on the same Wi-Fi network.

Step# 3: Start TCPIP and restart ADB daemon

Command: adb tcpip <port_no>

This command turns off default device identification by USB and it starts identifying them through TCPIP protocol.

adb tcpip Appium tests

Step# 4: Get the IP Address of your Device

First, you need to get the IP address of your device. Devices are connected over Wi-Fi by using the IP address only. You can get it from ‘About Phone’ options inside Settings of your device.

See Image below:

Get IP Address Appium tests

 

Step# 5: Connect Android devices Over Wi-Fi

Command: adb connect <device_ip_address>

Use the above command to connect your devices over Wi-Fi.

adb connect Appium tests

How to connect multiple Android devices over Wi-Fi to execute Appium tests?

Above steps connect a single device over Wi-Fi. If you want to connect multiple devices then you have to first connect each device through USB cable. Then remove the cable and follow the above steps for each of the devices. By doing so, you can connect multiple Android devices over Wi-Fi.

How to set back port from TCPIP to USB?

After you finish running your Appium tests over Wi-Fi then it should be your duty to set back the port to USB.  Use the following command to gain back the USB port connectivity for the Android devices.

Command: adb usb

adb usb appium tests

This was all about connecting android devices over Wi-Fi and triggering your Appium tests in the same wireless network. You can post your queries by using below comment form and also do not forget to follow us on Social media.

Join Inviul fb group

Leave a Reply