Architecture:

Here we are running scripts from a remote/local Appium server while the devices are connected to another system in the network.
Setup:
- Start adb server in the system in which devices are connected:
Just run the below command in cmd (given adb is available in path)
adb kill-server
adb -a -P 5037 server nodaemon
Appium capabilities:
Now to run appium tests we need to add the below capability:
Try appium inspector from the remote system with below capability (edit all other fields according to your setup except remoteAdbHost,systemport and adbPort)
here remoteadbhost is the remote system which has connected devices, system port is the uiautomator2 server port which is 8021 by default and finally adbport
This will allow you to inspect the remote devices from your local system
{
“platformName”: “Android”,
“appium:platformVersion”: “11”,
“appium:deviceName”: “sr”,
“appium:app”: “C:\\Users\\Downloads\\ApiDemos-debug.apk”,
“appium:automationName”: “UiAutomator2”,
"remoteAdbHost":"192:168.0.7",
"systemPort":8021,
"adbPort":5037
}
Note: when using webdriverio 7 add appium: infront of all the capabilities as its the new syntax for w3c.
Manually testing the remote connectivity:
1. From remote machine run:
Note: Change “192.168.0.7” to the ip address of the system in which devices are connected
on running this you can see the remote devices
adb -L tcp:192.168.0.7:5037 devices
Now you are ready to run the tests:
2. if you run
adb devices
This gives the devices connected local to the system
so to change that you can set the variable ADB_SERVER_SOCKET, to set this from use:
Note: change ip to system in which devices are connected
set ADB_SERVER_SOCKET=192.168.0.7
Now adb devices command gives the remote device details
4.To test if the adb is working remotely run the below command, you will see that call view is opened in the remote device:
just run the below command in cmd of the remote machine
adb shell am start -a android.intent.action.VIEW