How to disable wifi in local Android device using appium? – pCloudy – Question and Answers
Home >> Appium Tricks and Tricks >> How to disable wifi in local Android ...

How to disable wifi in local Android device using appium?



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.

Leave a Reply

Your email address will not be published. Required fields are marked *