Enabling WIFI ::
    
  
  
public void enablewifi() throws InterruptedException{  
  NetworkConnectionSetting connection_wifi_on = new NetworkConnectionSetting(false, true, false);
  Thread.sleep(10000);
  Reporter.log("Enabled WIFI connection");
 }
Disable WIFI ::
public  void disbalewifi() throws InterruptedException, MalformedURLException{  
  DesiredCapabilities capabilities = new DesiredCapabilities();
  AndroidDriver<MobileElement> driver = new AndroidDriver<MobileElement>(new URL("http://localhost:4723/wd/hub"), capabilities);
  // init wi-fi and data enabled and airplane mode disabled
  NetworkConnectionSetting ncs = new NetworkConnectionSetting(false, true, true);
  driver.setNetworkConnection(ncs);
  // turn off wi-fi
  ncs.setWifi(false);
  driver.setNetworkConnection(ncs);
  NetworkConnectionSetting conn = new NetworkConnectionSetting(false, false, false);
  conn.setWifi(false);
  Thread.sleep(10000);
  Reporter.log("Disabled WIFI connection");
 }
No comments:
Post a Comment