Create a iOSdriver but pass the bundle id as com.apple.Preferences
This will open the setting page and you can do any action in setting page.
Code:
public static void main(String[] args) throws Exception {
IOSDriver driver = null;
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "XCUITest");
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "iOS");
capabilities.setCapability(MobileCapabilityType.APPIUM_VERSION, "1.6.5");
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "10.0");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "RDEiPhone");
capabilities.setCapability("newCommandTimeout", 60*5);
capabilities.setCapability("--session-override", true);
//desiredCapabilities.setCapability("preventWDAAttachments", true);
//capabilities.setCapability(MobileCapabilityType.LAUNCH_TIMEOUT, 500000);
capabilities.setCapability("showXcodeLog", false);
capabilities.setCapability("xcodeOrgId", "Pass your developer team id");
capabilities.setCapability("xcodeSigningId", "iPhone Developer");
capabilities.setCapability(MobileCapabilityType.UDID, "e010e19ee4428664afc53d50999c138c861ea22e");
//capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT , 2000);
//capabilities.setCapability(MobileCapabilityType.APP , "/Users/rderpg/Desktop/sukrit_chill_debug/19-817/iXpand Base Auto-3.ipa");
capabilities.setCapability("bundleId", "com.apple.Preferences");
//capabilities.setCapability("xcodeConfigFile", "/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Configurations/ProjectSettings.xcconfig");
capabilities.setCapability("usePrebuiltWDA", true);
capabilities.setCapability("clearSystemFiles", true);
//capabilities.setCapability("noReset", true);
capabilities.setCapability("updatedWDABundleId", "com.facebook.WebDriverAgentAppiumTest");
//launchAppiumServer1();
//launchAppiumServer();
try {
driver = new IOSDriver(new URL(“http://127.0.0.1:4723/wd/hub”),capabilities);
System.out.println(“jitu”);
driver.findElement(By.id(“Wi-Fi”)).click();
driver.findElement(By.xpath("//XCUIElementTypeSwitch")).click();
} catch (Exception e) {
System.out.println(e);
}
}