AWS Device Farm
Developer Guide (API Version 2015-06-23)

Working with Appium Python for Web Applications and AWS Device Farm

Device Farm provides support for Appium Python for web applications.

What Is Appium Python?

Appium is an open-source tool for automating native, mobile web, and hybrid applications on platforms like web applications. For more information about Appium, see Introduction to Appium.

Version Information

Currently, Device Farm supports Appium versions 1.6.3 and 1.4.16 and Python version 2.7.6 (pip version 1.5.4).


If desired, you can use the rules field in the create-device-pool command or the the CreateDevicePool API to specify the APPIUM_VERSION.

Prepare Your Web Application Appium Python Tests

The Appium Python tests for your web application must be contained in a .zip file.

Build the Appium Python Test Package

The Appium Python test packages you upload to Device Farm must be in .zip format and contain all the dependencies of your test. The following instructions show you how to meet these requirements.


The instructions below are based on Linux x86_64 and Mac. In the currently supported scheme, Device Farm requires that the packaging of your Appium Python tests be done on Linux x86_64 if your tests contain non-universal Python wheels dependencies. For the platform on which you execute a command, the wheels tools gather your .whl dependent files under the wheelhouse/ folder. When you execute the Python wheel command on any platform other than Linux x86_64, you would gather the flavor of a non-universal wheel dependency for that particular platform and may cause undesired effects. This would most likely lead to errors when executing your tests on Device Farm.

  1. We strongly recommend that you set up Python virtualenv for developing and packaging tests so that unnecessary dependencies are not included in your app package.


    • Do not create a Python virtualenv with the --system-site-packages option, because it will inherit packages from /usr/lib/pythonx.x/site-packages or wherever your global site-packages directory is. This can lead to you including dependencies in your virtual environment that are not needed by your tests.

    • You should also verify that your tests do not use dependencies that are dependent on native libraries, as these native libraries may or may not be present on the instance where these tests run.

  2. Install py.test in your virtual environment.

    An example flow of creating a virtual environment using Python virtualenv and installing pytest in that virtual environment would look like the following:

    $ virtualenv workspace $ cd workspace $ source bin/activate $ pip install pytest
  3. Store all Python test scripts under the tests/ folder in your work space.

    ─ workspace └─ tests/ (your tests go here)
  4. Make sure you have py.test installed in your virtual environment and test cases are discoverable by the following command, which you should run from your virtual environment workspace folder.

    $ py.test --collect-only tests/

    Make sure the output of py.test command shows you the tests that you want to execute on Device Farm.

  5. Go to your work space and run the following command to generate the requirements.txt file:

    $ pip freeze > requirements.txt
  6. Go to your work space and run the following command to generate the wheelhouse/ folder:

    $ pip wheel --wheel-dir wheelhouse -r requirements.txt
  7. You can use the following commands to clean all cached files under your tests/ folder:

    $ find . -name '__pycache__' -type d -exec rm -r {} + $ find . -name '*.pyc' -exec rm -f {} + $ find . -name '*.pyo' -exec rm -f {} + $ find . -name '*~' -exec rm -f {} +
  8. Zip the tests/ folder, wheelhouse/ folder, and the requirements.txt file into a single archive:

    $ zip -r tests/ wheelhouse/ requirements.txt

    Your work space will eventually look like this:

    ─ workspace ├─ tests/ ├─ ├─ requirements.txt └─ wheelhouse/

Upload Your Web Application Appium Python Tests

Use the Device Farm console to upload your tests.

  1. Sign in to the Device Farm console at

  2. If you see the AWS Device Farm console home page, choose Get started.

  3. If you already have a project, you can upload your tests to an existing project or choose Create a new project.

                Your projects page in the Device Farm console


    If the list of projects is not displayed, then on the secondary navigation bar, for Projects, choose the name of the project where you want to upload your tests.

    To create a project, follow the instructions in Create a Project.

  4. If the Create a new run button is displayed, choose it.

  5. On the Choose your application page, choose Web application (the HTML5 button).

                Choose the web application button in the Device Farm console
  6. In the Run name field, type a name for your run.


    Give the run a name that will help you identify a specific build of your app (for example, Beta-0.1). For more information, see Working with Test Runs.

  7. Choose Appium Python to configure your test.

  8. Next, choose Upload to upload your .zip file.

    Device Farm processes your .zip file before continuing.

  9. Choose the Appium version you are using from the Appium version dropdown list.

  10. Choose Next step, and then complete the instructions to select devices and start the run.

Taking Screenshots in Web Application Appium Python Tests

You can take screenshots as part of your Appium Python tests for your web application.

When Device Farm runs your Appium Python test, the service sets the SCREENSHOT_PATH property to a fully qualified path on the local file system where Device Farm expects Appium screenshots to be saved. The test-specific directory where the screenshots are stored is defined at runtime. The screenshots are pulled into your Device Farm reports automatically. To view the screenshots, in the Device Farm console, choose the Screenshots section.

The following example shows how to use and consume the SCREENSHOT_PATH property to capture an Appium screenshot that is pulled into your Device Farm report.

screenshot_folder = os.getenv('SCREENSHOT_PATH', '') self.driver.save_screenshot(screenshot_folder + "/screenshot.png")

Additional Considerations for Web Application Appium Python Tests

Device Farm does not modify Appium Python tests for your web application.