How to turn on off wifi using appium in iOS devices

Start Application.
Swipe iOS screen.
After swiping I am not able to turn on or off wifi.

This works for android. Try if this class given by javaclient works for iOS also

NetworkConnectionSetting networkConnection = new NetworkConnectionSetting(false, true, false);
networkConnection.setData(true); // enable mobile data
networkConnection.setWifi(false); // close wifi
_driver.setNetworkConnection(networkConnection);
networkConnection = _driver.getNetworkConnection();
System.out.println("airplaneModeEnabled() :: " + networkConnection.airplaneModeEnabled() +
"\ndataEnabled() :: " + networkConnection.dataEnabled() +
"\nwifiEnabled() :: " + networkConnection.wifiEnabled()
);

If the airplane mode is enabled does it off wifi connection?
What is the driver you actually mean?
driver = new IOSDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);
Please can you reply pa.
driver.setNetworkConnection says driver what means…

Yes disable airplane mode and Mobile data mode. Just open WIFI mode.

NetworkConnectionSetting networkConnection = new NetworkConnectionSetting(false, true, false);

// Above statement will disable airplane mode ,Mobile data mode and enable WIFI

This is class constructor declaration
public NetworkConnectionSetting(boolean airplaneMode,
boolean wifi,
boolean data)

Check this page for more usage
http://appium.github.io/java-client/io/appium/java_client/NetworkConnectionSetting.html

error because of driver heres…

what error u r getting, can u share u r code ?? also tell u r using for iOS app ?

Hi amitjaincoer191,
Special thank you for quick reply.
When driver is set to iOS device,
driver = new IOSDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);
driver.setNetworkConnection(…);
driver.getBetworkConnection(…);
does not works…

Will you please suggest me with different solution. I am new to appium please can you guide me…

Error:
the method setNetworkConnection(NetworkConnectionSetting) is undefined for the type IOSDriver…

Yes the network connectivity does not work for IOS driver.
Can you help me with any other idea.
Please give me different solution…

Appium does not support this feature for iOS. Sorry!!! I don’t have any solution for this.

Hope any one else can help on this… good luck

When running the application,
Do swipe to get the settings option followed by tap
Will enable or disable wifi…

what u said works for Android
like

  1. Push current app to background by pressing HOME button
  2. Launch Settings app
  3. Tap Wifi option

But how u will reach to settings app to tap wifi option in iOS app?

driver.setAppInBackground(int seconds); // this will put app in background for time u specify in iOS app

Start application in iOS device.
Swipe from bottom.
Seetings option will be shown airplane mode, wifi, bluetooth, screen brightness, volume.
Tap wifi to enable or disable
Will change the wifi enable to disable and vice vorces…

How does Swiping from bottom brings “Settings” option into focus

Does your app have an option to do Settings ?

Can u share screen shot where u want to perform swipe which will bring Setting option into focus…

If u succeeded in opening Settings then u can enable wifi by inspecting in Appium Inspector…

When swiping from bottom to up you can enable wifi
precondition wifi password should be already saved in the device…

Yes it will work if u can reach to this screen, Just inspect all the steps using appium inspector and write code.

I think you can not have such luxury in iPhone thanks to Steve Jobs :). The first thing other than your app you can not inspect. Just simple test, do this things during recording your script using appium inspector. Appium inspector will not be able to locate this option.

You can using this