Skip to main content
Transform your testing process with: Real Device Features, Company-wide Licences, & App Percy

Test iOS App Settings

iOS app settings are app preferences that are accessible through the iOS Settings app. Your app preferences are accessible when you click your app name from the list of apps that appear on the Settings app.

App Automate supports updating the settings of an iOS app through an automated test script. An iOS app may require certain settings to be enabled to perform certain actions. For example, to capture images, an app requires access to the Camera app.

Important:
  • Currently, this feature is supported only on iOS 13 and above devices.
  • Updating an iOS app setting may lead to a marginal increase in the start time of a session in App Automate.

In this guide, you’ll learn:

Supported iOS app settings

App Automate supports the following types of iOS app settings:

  • App-specific permission settings: These are app settings added by the OS based on the permissions that a user grants the app. For example, settings related to the Camera, Location, etc., apps.
  • App settings added through iOS Settings bundle: These are the settings added by the app developer using the iOS Settings Bundle.

The following image shows the supported iOS app settings:

Supported iOS app settings

Update iOS app settings in an App Automate session

App-specific permission settings are added by the OS based on the permissions that a user grants the app.

These permission settings are set only when your app encounters the related permission pop-up on the screen.

In this section, you’ll learn:

Supported permission settings

Currently, App Automate supports the following permission settings:

  • Location
  • Camera
  • Contacts
  • Photos
  • Notifications

Update app-specific permission settings

Add the updateAppSettings action in the custom BrowserStack JavaScript executor and wrap any app-specific permission settings within the Permission Settings object.

The following example image and code shows how to set the Location permission to Always and enable the Precise Location setting such that location access is granted to your app.

iOS app settings example


// set Location Access to Always
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("browserstack_executor: {\"action\": \"updateAppSettings\", \"arguments\": {
    \"Permission Settings\": {
        \"Location\": {
            \"ALLOW LOCATION ACCESS\": \"Always\"
            }
        }
    }
}");

// enable the Precise Location feature
jse.executeScript("browserstack_executor: {\"action\": \"updateAppSettings\", \"arguments\": {
    \"Permission Settings\": {
        \"Location\": {
            \"Precise Location\": \"ON\"
            }
        }
    }
}");


// set Location Access to Always
await driver.execute("browserstack_executor: {\"action\": \"updateAppSettings\", \"arguments\": {\"Permission Settings\":{\"Location\":{\"ALLOW LOCATION ACCESS\": \"Always\"}}}}");

// enable the Precise Location feature
await driver.execute("browserstack_executor: {\"action\": \"updateAppSettings\", \"arguments\": { \"Permission Settings\":{\"Location\": {\"Precise Location\": \"ON\"}}}}")
# set Location Access to Always
driver.execute_script('browserstack_executor: {\"action\": \"updateAppSettings\", \"arguments\": {\"Permission Settings\": {\"Location\": {\"ALLOW LOCATION ACCESS\": \"Always\"}}} }')

# enable the Precise Location feature
driver.execute_script("browserstack_executor: {\"action\": \"updateAppSettings\", \"arguments\": {\"Permission Settings\": {\"Location\": {\"Precise Location\": \"ON\"}}} }")

caps["javascriptEnabled"] = "true" #include this capability for JavaScript executors to work

# set Location Access to Always
driver.execute_script("browserstack_executor: {\"action\": \"updateAppSettings\", \"arguments\": {
    \"Permission Settings\": {
        \"Location\": {
            \"ALLOW LOCATION ACCESS\": \"Always\"
            }
        }
    }
}")

# enable the Precise Location feature
driver.execute_script("browserstack_executor: {\"action\": \"updateAppSettings\", \"arguments\": {
    \"Permission Settings\": {
        \"Location\": {
            \"Precise Location\": \"ON\"
            }
        }
    }
}")

// set Location Access to Always
((IJavaScriptExecutor)driver).ExecuteScript("browserstack_executor: {\"action\": \"updateAppSettings\", \"arguments\": {\"Permission Settings\": {\"Location\": {\"ALLOW LOCATION ACCESS\": \"Always\"}}}}");

// enable the Precise Location feature
((IJavaScriptExecutor)driver).ExecuteScript("browserstack_executor: {\"action\": \"updateAppSettings\", \"arguments\": {\"Permission Settings\": { \"Location\": { \"Precise Location\": \"ON\" }}}}");

Example custom executors for supported app-specific permission settings

The following list provides a few examples of custom BrowserStack executor scripts that you can use to update the supported app-specific permission settings:

  • Location: To set the ALLOW LOCATION ACCESS permission to While Using the App for the app to access the device’s location.
    driver.executeScript("browserstack_executor: {\"action\": \"updateAppSettings\", \"arguments\": {\"Permission Settings\": {\"Location\": { \"ALLOW LOCATION ACCESS\": \"While Using the App\"}}}}");
    
  • Contacts: To enable the Contacts setting for the app to access the device’s contact list.
    driver.executeScript("browserstack_executor: {\"action\": \"updateAppSettings\", \"arguments\": {\"Permission Settings\": {\"Contacts\": \"ON\"}}}");
    
  • Camera: To enable the Camera setting for the app to access the device’s camera.
    driver.executeScript("browserstack_executor: {\"action\": \"updateAppSettings\", \"arguments\": {\"Permission Settings\": {\"Camera\": \"ON\"}}}");
    
  • Photos: To set the Photos permission to All Photos for the app to access the images stored in the Photos app.
    driver.executeScript("browserstack_executor: {\"action\": \"updateAppSettings\", \"arguments\": {\"Permission Settings\": {\"Photos\": \"All Photos\"}}}");
    
  • Notifications: To enable push notifications for your iOS app.
    driver.executeScript("browserstack_executor: {\"action\":\"updateAppSettings\", \"arguments\": { \"Permission Settings\": { \"Notifications\": { \"Allow Notifications\": \"ON\" } } } }")
    

Points to remember

  • Ensure that you use the JavaScript executor in a sequence to update dependent permission settings. For example, updating the Precise Location setting before the Location setting results in a test flakiness.
  • If you have configured some pop-ups in your iOS app, ensure to handle those pop-ups such that they do not interfere with our automation to update your app-specific permission settings.

These are the permission settings added by developers using the iOS Settings bundle during the development of an iOS app. To learn more about iOS Settings Bundle, check out the official Apple Documentation.

In this section, you will learn:

Update permission settings added via iOS Settings bundle

You can update permission settings, added via the iOS Settings bundle, in BrowserStack using either of the following ways:

  • Using the app update settings capability: It is used to update app settings at the beginning of the test.
  • Using the custom BrowserStack Javascript executor: It is used to update app settings in the middle of the test execution.

Use the information in either of the following tabs to update permission settings added via the Settings bundle:

Add the capability to your test script and add the required settings within this capability as key-value pairs to update the permission settings at the beginning of your test script.

Provided keys and values are validated from the app settings bundle in the app, and throw errors if any key or value is incorrect.

The following example image and code show how to set a few permission settings.

iOS app settings desired caps example

The following example code uses the browserstack.updateAppSettings capability in a test script to set Environment setting to QA_1 and Child Setting 1 to abc.

DesiredCapabilities capabilities = new DesiredCapabilities();
HashMap<String, Object> browserstackOptions = new HashMap<String, Object>();
HashMap<Object, Object> appSettings = new HashMap<Object, Object>();
appSettings.put("Environment","QA_1");

HashMap<Object, Object> childSettings = new HashMap<Object, Object>();
childSettings.put("Child Setting 1","abc");

appSettings.put("Child Settings",childSettings);

browserstackOptions.put("updateAppSettings",appSettings);
capabilities.setCapability("bstack:options",browserstackOptions);
var capabilities = {
   	'bstack:options' : {
   		"updateAppSettings" : {
            "Environment" : "QA_1",
            "Child Settings" : {
                "Child Setting 1" : "abc"
            }
        }
    }
}
desired_cap = {
   	'bstack:options' : {
   		"updateAppSettings" : {
            "Environment" : "QA_1",
            "Child Settings" : {
                "Child Setting 1" : "abc"
            }
        }
   	},
 }
capabilities = {
     'bstack:options' => {
        "updateAppSettings" => {
            "Environment" => "QA_1",
            "Child Settings" => {
                "Child Setting 1" => "abc"
            }
        }
    },
}
AppiumOptions capabilities = new AppiumOptions();
Dictionary<string, object> browserstackOptions = new Dictionary<string, object>();
Dictionary<object, object> appSettings = new Dictionary<object, object>();
appSettings.Add("Environment","QA_1");

Dictionary<object, object> childSettings = new Dictionary<object, object>();
childSettings.Add("Child Setting 1","abc");

appSettings.Add("Child Settings",childSettings);

browserstackOptions.Add("updateAppSettings",appSettings);
capabilities.AddAdditionalCapability("bstack:options",browserstackOptions);
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
HashMap<Object, Object> appSettings = new HashMap<Object, Object>();
appSettings.put("Environment","QA_1");

HashMap<Object, Object> childSettings = new HashMap<Object, Object>();
childSettings.put("Child Setting 1","abc");

appSettings.put("Child Settings",childSettings);

capabilities.setCapability("browserstack.updateAppSettings",appSettings);
var capabilities = {
	'browserstack.updateAppSettings':  {
        "Environment" : "QA_1",
        "Child Settings" : {
              "Child Setting 1" : "abc"
              }
    }
}
desired_cap = {
	'browserstack.updateAppSettings': {
        "Environment" : "QA_1",
        "Child Settings" : {
            "Child Setting 1" : "abc"
        }
    }
}
desired_caps = {
    'browserstack.updateAppSettings'=> {
        "Environment" => "QA_1",
        "Child Settings" => {
            "Child Setting 1" => "abc"
        }
    }
}
AppiumOptions capabilities = new AppiumOptions();
Dictionary<object, object> appSettings = new Dictionary<object, object>();
appSettings.Add("Environment","QA_1");

Dictionary<object, object> childSettings = new Dictionary<object, object>();
childSettings.Add("Child Setting 1","abc");

appSettings.Add("Child Settings",childSettings);

capabilities.AddAdditionalCapability("browserstack.updateAppSettings",appSettings);

Add the updateAppSettings action in the custom BrowserStack JavaScript executor to update permission settings in the middle of your test session.

Provided keys and values are validated from the app settings bundle in the app, and appropriate errors are thrown if any key or value is not found to be correct.

The following example image and code show how to set a few permission settings.

iOS app permission settings example with custom executor

The following example code uses the updateAppSettings action in the custom BrowserStack JavaScript executor to set Environment setting to QA_1 and Child Setting 1 to abc.

JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("browserstack_executor: {\"action\":\"updateAppSettings\", \"arguments\": {
    \"Environment\": \"QA_1\",
    \"Child Settings\" : {
        \"Child Setting 1\" : \"abc\"
    }
}}");

await driver.execute("browserstack_executor: {\"action\":\"updateAppSettings\", \"arguments\": {
    \"Environment\": \"QA_1\",
    \"Child Settings\" : {
        \"Child Setting 1\" : \"abc\"
    }
}}");

driver.execute_script('browserstack_executor: {\"action\":\"updateAppSettings\", \"arguments\": {
    \"Environment\": \"QA_1\",
    \"Child Settings\" : {
        \"Child Setting 1\" : \"abc\"
    }
}}')

caps["javascriptEnabled"] = "true" #include this capability for JavaScript executors to work
driver.execute_script("browserstack_executor: {\"action\": \"updateAppSettings\", \"arguments\":
{
    \"Environment\": \"QA_1\",
    \"Child Settings\" : {
        \"Child Setting 1\" : \"abc\"
        }
}}")

((IJavaScriptExecutor)driver).ExecuteScript("browserstack_executor: {\"action\":\"updateAppSettings\", \"arguments\": {
    \"Environment\": \"QA_1\",
    \"Child Settings\" : {
        \"Child Setting 1\" : \"abc\"
        }
}}");

Points to remember

  • The title of the keys displayed on your iOS app settings page must be unique.
  • We currently do not support updating values of the PSSliderSpecifier and PSGroupSpecifier keys, which are added using the iOS Settings bundle in your iOS app.

Check this page for a list of various JavaScript Executors that BrowserStack offers.

Need some help?

If you need any help with this feature, get in touch with us.

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback!

Talk to an Expert
Download Copy