I am testing on MAC. So I would like to have one code for both iOS and Android.
The answer is sort of. It'll depend on if the elements used in both the Android and iOS version of the app are the same. AWS Device Farm should allow us to find out which platform we're testing using the custom environment and it's environment variables.
https://docs.aws.amazon.com/devicefarm/latest/developerguide/custom-test-environment-env.html
Using the DEVICEFARM_DEVICE_PLATFORM_NAME
variable should allow us to do an if statement in the yml file to test which platform is being tested. Then from there you can execute whatever test command you would like.
Does this answer the question?
[UPDATE]
I executed the following commands in the custom environment mode and it looks like we can use python 3 with Android runs(not sure about iOS).
[DeviceFarm] python -c "import sys; print(sys.version_info[:])"
(2, 7, 6, 'final', 0)
[DeviceFarm] whereis python
python: /usr/bin/python2.7-config /usr/bin/python3.4m /usr/bin/python /usr/bin/python2.7 /usr/bin/python3.4 /etc/python /etc/python2.7 /etc/python3.4 /usr/lib/python2.7 /usr/lib/python3.4 /usr/bin/X11/python2.7-config /usr/bin/X11/python3.4m /usr/bin/X11/python /usr/bin/X11/python2.7 /usr/bin/X11/python3.4 /usr/local/lib/python2.7 /usr/local/lib/python3.4 /usr/include/python2.7 /usr/share/python /usr/share/man/man1/python.1.gz
[DeviceFarm] which python
/usr/bin/python
[DeviceFarm] python --version
Python 2.7.6
[DeviceFarm] python3 -c "import sys; print(sys.version_info[:])"
(3, 4, 3, 'final', 0)
[DeviceFarm] whereis python3
python3: /usr/bin/python3 /usr/bin/python3.4m /usr/bin/python3.4 /etc/python3 /etc/python3.4 /usr/lib/python3 /usr/lib/python3.4 /usr/bin/X11/python3 /usr/bin/X11/python3.4m /usr/bin/X11/python3.4 /usr/local/lib/python3.4 /usr/share/python3 /usr/share/man/man1/python3.1.gz
[DeviceFarm] which python3
/usr/bin/python3
[DeviceFarm] python3 --version
Python 3.4.3
It's just not the default option. I think we'll only be able to change this in the custom environment mode since the standard environment will run the tests on your behalf.