Set network settings (FR)

Perfecto Command

mobile:network.settings:set

Purpose

Sets the status of the specified network settings: wifi, data (only for devices with a valid SIM card installed), and/or airplane-mode.

Restriction: This command is not supported for iOS devices.

Setting airplane mode is supported for devices running Android version 7.0 or earlier. Setting the radio mode works for devices running Android version 9.0 or earlier but is subject to Google not changing the implementation, so the command is not guaranteed to work in the future.

Tip: If the device does not reconnect when the radio signal is turned on, you may need to do one of the following:
  • Reboot the device
  • Turn airplane mode off and immediately back on

Parameters

Name Type Possible Values Description
wifi String enabled | disabled Enable/disable the device WiFi.
data String enabled | disabled

Enable/disable the device data from the mobile carrier. The device must have a SIM.

Available for Android version 2.3 to 4.4.

airplanemode String enabled | disabled

Enable/disable the device Airplane mode.

Tip: If this parameter does not work on the Android version you are working with, try using the command parameter of the mobile:handset:shell command instead, as follows:
Copy
Map<String, Object> params1 = new HashMap<>();
params1.put("command", "cmd connectivity airplane-mode enable");
driver.executeScript("mobile:handset:shell", params1);

This solution seems to work for Android versions 10 and later.

radioMode String enabled | disabled Enable/disable the device radio signal.

Return Value

None

Exceptions

None

Examples

Copy

Java sample

Map<String, Object> pars = new HashMap<>();
pars.put("airplanemode", "enabled");
driver.executeScript("mobile:network.settings:set", pars)
Copy

C# sample

Dictionary<String, Object> pars = new Dictionary<String, Object>();
pars.Add("airplanemode", "enabled");
driver.ExecuteScript("mobile:network.settings:set", pars);