Search code examples
pythoniosseleniumnetwork-programmingappium

Manipulate iOS device's Wi-Fi programmatically


I am writing in automation script in xcode using Python, appium, and selenium and I need to be able to toggle WiFi on and off and switch to a different saved Network on a real iOS device. Is this possible? Maybe I can use surprocess to open Settings>Wi-Fi?


Solution

  • In java, I was able to do this as below:

     @Test
        public void testUntitled() {
            driver.executeScript("client:client.swipe(\"Down\", 0, 500)");
            driver.findElement(By.xpath("//*[@text='Wi-Fi']")).click();
            new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.xpath("((((//*[@text=' ']/*/*/*[@class='UIAView' and ./parent::*[@class='UIAView' and ./parent::*[@class='UIAWindow']]])[3]/*[@class='UIAView'])[1]/*[@class='UIAView'])[1]/*[@class='UIAView' and @width>0])[1]")));
            driver.executeScript("client:client.swipe(\"Up\", 0, 500)");
        }
    

    Below is how it looked on the physical device

    enter image description here

    Sorry, since I don't know python. But I hope you'll be able to modify java to python easily.