How to disable wifi in local Android device using appium?
Posted on July 9, 2019
By Sridatta Pani
String adbCommand = "adb shell am broadcast -a io.appium.settings.wifi --es setstatus disable";
runCommand(adbCommand);
public String runCommand(String command) throws InterruptedException, IOException {
p = Runtime.getRuntime().exec(command);
// get std output
BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = "";
String allLine = "";
int i = 1;
while ((line = r.readLine()) != null) {
allLine = allLine + "" + line + "\n";
if(line.contains("Console LogLevel: debug") && line.contains("Complete")) {
break;
}
i++
}
return allLine;
}
Description
By this script we can enable wifi in android devices.By disabling the wifi we can connect to a network using this script.