How can I restart device?

I set AppiumDriverLocalService + AndroidDriver,.
My test should check my app after device reboot, but here my issue, I loose connection to device !
there is a way to restart device without close appium + android drivers ?

Thanks for help

Try “adb reboot” command in your test case using java code with java.lang.Runtime class.

I tried but driver loosing connection of device

I’m not sure there is a way to reboot a device without losing the connection. By design, wouldn’t the device shut down all existing connections when it reboots?

The only thing I can think of right now is to write some custom code to poll for the device using adb and re-instantiate the driver once adb reports the device is available.

Good luck.