Turn on wifi in appium 1.6.3

How to turn on WiFi in Appium 1.6.3

old method is not working

public void Wifi_On(){
NetworkConnectionSetting ncs = new NetworkConnectionSetting(false, true, true);
ncs.setWifi(true);

driver.setNetworkConnection(ncs);

}

Below code worked for me earlier, so give a try. Not sure if something is updated now.

            AndroidDriver driver=null;
			DesiredCapabilities caps=new DesiredCapabilities();
			caps.setCapability("deviceName", "abc");
			caps.setCapability("appPackage", "myapppackage");
			caps.setCapability("appActivity", "myappactivity");
			
			try 
			{
				driver=new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),caps);
			} catch (MalformedURLException e) 
			{
				e.printStackTrace();
			}
			
			try 
			{
				Runtime.getRuntime().exec("cmd /C " + "adb shell am start -n io.appium.settings/.Settings -e wifi off");
			} catch (IOException e) 
			{
				e.printStackTrace();
			}
			
			NetworkConnectionSetting networkConnection = new NetworkConnectionSetting(false, true, false);
			System.out.println("Hello "+networkConnection.wifiEnabled());

How will you run this on remote machines, i.e; perfecto cloud or etc… ADB is only for local connections.

You can use:

That was added with this PR: