How to turn Wifi ON/OFF using Appium?

If you have worked on appium for the automation of native apps or mobile browser(firefoxOS, chromium or native), then this is not a weird thought to automate actions which are neither app specific nor browser specific. I'm talking about system features like launching settings and turning wifi ON/OFF, dialing a number using dialer.

All you need to know id the package name of settings app and its launcher activity. Once it is launched, you can do anything on the screen as you do for native apps.

Here is a sample test case to turn wifi ON using appium.

    public void turnOnWifi() {

        AppiumDriver driver = null;
        DesiredCapabilities capabilities = null;
        capabilities = new DesiredCapabilities();
        capabilities.setCapability("platformName", "Android");
        capabilities.setCapability("deviceName", "4a119f6b");
        capabilities.setCapability("appPackage", "com.android.settings");
        try {
            driver = new AndroidDriver(new URL(""),
        } catch (Exception e) {
            System.out.println("Unable to start driver.");
        try {
            WebElement wifiBtn = driver.findElement(

            if (wifiBtn.getAttribute("checked").equals(false)) {
            } else {
                System.out.println("Wifi Already ON");

        } catch (Exception e) {
            System.out.println("Error while turning ON Wifi");


  1. Hi, How can i turn on or off the wifi in IOS?

  2. Hei, how can I do the same with robot framework? I tried to put such a keyword with args:

    Open Application http://localhost:4723/wd/hub platformName=Android platformVersion=5.0 deviceName=${device_name} appPackage=com.android.settings appActivity=com.android.settings.Settings but got an error : WebDriverException: Message: A new session could not be created. (Original error: Activity used to start app doesn't exist or cannot be launched! Make sure it exists and is a launchable activity)


Recent Posts