Wifi Disable and Enable doesnt work in Batch execution of scripts Android

Hi All,

I am unable to perform batch execution for scripts which have test cases on wifi on/off scenarios.

Example: To Login appn i need wifi to be On and after signIn have to disable Wifi to verify network disabled and after verifying it must Enable Wifi again To Logout from App.
Like these have written around 20 test cases of various scenarios to be executed in Single batch TestNgSuite .xml file.
Wifi won’t repsond correctly it may enable or sometime maynot enable.
Facing issue in Samusng J7 prime and Samsung galaxy S6 Edge,Nexus.
Andorid 7.0 and Android 6.0.1 OS used.

Please your support is precious.

Adb command:
Runtime.getRuntime().exec(“adb shell am broadcast -a io.appium.settings.wifi --es setstatus enable”);

Note: Single testcase execution works fine.

With regards

If it were me I would try a stronger algorithm. Something like:

until (adb command to check status == statusDesired) {
 adb command to set status

You may want to add some timeout or whatever.

Have you tried:


Also, remember that if you have several android devices connected its not

adb shell ...

it should be:

adb -s «device_id» shell ...

Had refered appium doc site.


Toggle wifi not supported by Java

And am connecting Single device for batch process execution.
Hence used -
Runtime.getRuntime().exec(“adb shell am broadcast -a io.appium.settings.wifi --es setstatus enable”);

Thanks wreed,is it possible to share correct code for algorithm used.

It is supported:

Thanks Telmo shall check the code for samsung and nexus devices, and also how to verify whether wifi is enabled or disabled in samsung and nexus devices.

None of these approaches are working fine under Android Batch Script Run,but single script execution seems to work fine .
It depends on Android OS and its responsiveness when we run more number of scripts as a batch process we cant achieve.

Had tried this approach:
@Test public void toggleWiFi() {
try {
} catch (Exception e) {
fail(“Not able to toggle wifi”);

Batch fails.

Hi Telmo,

For me toggleWiFi, stops the whole test process. Is there any possible reason, in simulator.