How to know if Android device is connected to Appium Server?

Hi,

May I know, how we can get the status of connection between Appium server and an Android device?

Thanks & regards,
Vijay Bhaskar.

until you will open driver (create connection from point where tests starting to point where Appium server running) you can’t do anything.

so first step is - open driver then e.g. execute e.g. “adb devices” and read result of it.

when tests running on same machine where appium is - you can execute “adb devices” before opening driver.

Thanks for your suggestion @Aleksei,

The thing is when all capabilities are set, Appium server is listening on some(e.g. 4723) port number and App is launched on Mobile device. So the connection has been established between Server and Device.

Therefore, is there a way to get the status whether the device is connected and listening on desired server port number (4723).

Thanks,
Bhaskar.

appium port (e.g. 4723) is only for Appium driver - nothing more.

do you need status of device under test or other device connected to machine where appium server is running?

Thanks @Aleksei,

I need to get the status of device under test.

Regards,
Bhaskar.

so if:

  • device under test and driver yet opened = try open driver with this device. Passed = connected, Failed = not connected.
  • driver opened but you need to check if driver still alive and connected with device. do any command e.g. driver.getPageSource(). Success = connected, Fails = not connected