1

I am testing on MAC. So I would like to have one code for both iOS and Android.

abakunts
  • 25
  • 1
  • 3

1 Answers1

0

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.

jmp
  • 2,175
  • 2
  • 17
  • 16
  • Thanks for your answer, it's really helpful. Do you know whether Python Appium is enough for the whole automation of the app or I also need other frameworks for the full automation?, e.g Selenium. – abakunts Apr 22 '19 at 08:26
  • Appium is an extension of selenium so it should be fine just having appium. Is there something specific you're doing? – jmp Apr 22 '19 at 12:16
  • No I am in investigation phase trying to find the most easy way to automate testing using AWS device farm. Can I write the code using Python 3? Because I saw that it's only for python 2.7 https://docs.aws.amazon.com/devicefarm/latest/developerguide/test-types-android-appium-python.html – abakunts Apr 22 '19 at 15:06
  • just tested for python3, it's there on the host machine running the tests but it's just not the default. I didn't test this with iOS devices, however. – jmp Apr 23 '19 at 03:33
  • Thank you for your help and time – abakunts Apr 23 '19 at 20:27