How to let Appium change IOS Preference setting?

My ios app is running with a custom field in system’s Preference, to indicate if a prod or a testing env should be used. When I am writing Appium automation codes, I of course want to access the Preference on this field and change it to different test environments. I however not sure how to access the Preference settings… I’m running on simulators.My language is Java. I also want to switch to different testing environments, so “No Reset” on appium may not be sufficient.

Any help will be appreciated!!!

1 Like

Something along the lines of this (depending on the language you are using, I am using Java):

capabilities.setCapability(“app”, “settings”); // “settings” or “com.apple.Preferences”

Note: This can only be used for iOS Simulator testing

Hi @Jamesdeath_D

Declare and initialize the settings for all the environments in Appropriate file(.properties) and pass the value of your environment to the code in before class

Env1:
os version…

Env2:
Os version

now change the value in base setup to env1 or env2 depends on requirement

Thnaks…

@jagadeeshkotha This looks interesting. Could you please provide a bit code snippet about passing the value of the environment to the code? I am not sure which methods to use. Thank you a lot!

@Wil_Collins Interesting. This will launch the settings app in one session, but I cannot open my own app is the same session right? If not so, how can I launch the app and go to settings? If so, how can I pass the settings between sessions? Thank you very much!

Not an elegant way but I used java robot class to change Settings- Env in simulator.

@Ankur interesting. Could you please provide a short code snippet on changing that? I appreciate it!

i think you cannon launch more than one session

@jagadeeshkotha you mentioned passing the value of env to the code in before class, right? I am just wondering if it is possible that you can show me a few lines of codes to do that change? Launching two sessions are my questions in repsonding to Wil’s comment :smile:

@Jamesdeath_D Each session can contain multiple tests. So what I did was construct a test that launches the settings app, interacts with it, and then is finished. I then inject this test (along with others depending on the necessary dependencies) into my suite (which may not be necessary in your case, you may just want to explicitly add the new test to your xml suite for execution) before the test that requires the settings change so that the settings are set for all subsequent tests. I also follow the main test with a cleanup that resets the settings for the remaining tests. If you want these settings to persist over sessions, you can use the --no-reset flag which will cause the simulator to remain open without clearing the cache.

1 Like

Thanks! Thats good idea!

@Jamesdeath_D, I have same requirement as you. Cloud you please give some help?

  1. operate iOS settings only support on iOS simulator?
  2. if only support on iOS simulator, cloud you please share detail steps? any ENV setting need to change ?