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.
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
@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!
@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
@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.