Reputation: 623
Problem When the app I am testing is launched, the app looks up the IP of the current user to detect the country of origin. Depending on the country, an URL to the backend is changed. I want to be able to emulate any region in my test.
What I want to do I would like to be able to send something to the application on startup, such as an environment variable or a launch argument that then can be handled inside the application.
After some googling I found this: http://nshipster.com/launch-arguments-and-environment-variables/
But I am unable to find if it is possible to send these variables when launching the app through Appium.
Any ideas?
Upvotes: 4
Views: 2096
Reputation: 3146
So, in theory, you can modify the files in the simulator via Appium's client libraries ... However, after a lengthy search, I couldn't find where the Simulator keeps its "Custom Locations..." If you can find where those live, I'm sure you can modify the xml file that sets it like is done here
But here is a non-appium, potentially automate-able solution.
... make an AppleScript! (obviously OSX & iOS only fix for this issue. I will keep my eyes out for a way to configure the simulator's current location by modifying files on the sim..)
This apple script will throw an error if the simulator isn't already running - so launch it first - and then have your tests run this script in their setup code.
tell application "iPhone Simulator"
activate
end tell
tell application "System Events"
tell process "iPhone Simulator"
tell menu bar 1
tell menu bar item "Debug"
tell menu "Debug"
tell menu item "Location"
click
tell menu "Location"
click menu item "Custom Location…"
end tell
end tell
end tell
end tell
end tell
tell window 1
set value of text field 1 to "40.765477"
set value of text field 2 to "-73.745398"
click button "OK"
end tell
end tell
end tell
Upvotes: 1