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

Working with Appium Node.js for Web Applications and AWS Device Farm

This section describes how to configure, package, and upload your Appium Node.js tests to Device Farm. Appium is an open source tool for automating native and mobile web applications. For more information, see Introduction to Appium on the Appium website.

Version Information

  • You can use any Node.js version when you run Appium Node.js tests on Device Farm. Specify the Node.js version in the test spec YAML file.

  • Device Farm supports Appium server versions 1.6.5 and later. You can choose any Appium version by using the avm command. For example, to use Appium server version 1.9.1, add these commands to your test spec YAML file:

    phases: install: commands: # To install a newer version of Appium such as version 1.9.1: - export APPIUM_VERSION=1.9.1 - avm $APPIUM_VERSION - ln -s /usr/local/avm/versions/$APPIUM_VERSION/node_modules/.bin/appium /usr/local/avm/versions/$APPIUM_VERSION/node_modules/appium/bin/appium.js

    For more information, see Uploading a Custom Test Spec Using the AWS CLI and Create a Test Run in AWS Device Farm.

Prerequisites for Packaging Your Tests

To package your Appium Node.js tests and upload them to Device Farm, you must install the following on your local machine:

  • Node Version Manager (nvm)

    Use this tool when you develop and package your tests so that unnecessary dependencies are not included in your test package.

  • Node.js

  • npm-bundle (installed globally)

To install prerequisites on macOS or Linux

  1. Run this command to install nvm:

    curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash

    After the installation is complete, reload your terminal by signing out and then signing in again.

    Note

    nvm is loaded as a function for the bash shell only.

  2. Run this command in the bash shell to verify that nvm is installed correctly. You can switch to the bash shell by using /bin/bash.

    command -v nvm

    You should see nvm as output.

    For more information, see nvm on GitHub.

  3. Run this command to install Node.js:

    nvm install node

    You can specify a particular version of Node.js, as shown here:

    nvm install 11.4.0
  4. Run this command to verify that you are using the specified version:

    node -v
  5. Run this command to install npm-bundle globally:

    npm install -g npm-bundle

Step 1: Create a Zipped Test Package File

The Appium Node.js test packages that you upload to Device Farm must be in .zip format and contain all the dependencies of your test.

  1. Check out your project.

    Make sure you are at the root directory of your project. You can see package.json at the root directory.

  2. Run this command to install your local dependencies.

    npm install

    This command also creates a node_modules folder inside your current directory.

    Note

    At this point, you should be able to run your tests locally.

  3. Run this command to package the files in your current folder into a *.tgz file. The file is named using the name property in your package.json file.

    npm-bundle

    This tarball (.tgz) file contains all your code and dependencies.

  4. Run this command to bundle the tarball (*.tgz file) generated in the previous step into a single zipped archive:

    zip -r MyTests.zip *.tgz

    This is the MyTests.zip file that you upload to Device Farm in the following procedure.

Step 2: Upload Your Test Package to Device Farm

Use the Device Farm console to upload your tests.

  1. Sign in to the Device Farm console at https://console.aws.amazon.com/devicefarm.

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

  3. You can upload your tests to an existing project or choose Create a new project.

    Tip

    If the list of projects is not displayed, 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 in AWS Device Farm.

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

  5. On the Choose your application page, choose web application ( 
        HTML 5 web icon.
    ).

    
        Choose an application in the Device Farm console.
  6. In Run name, enter a name for your run.

    Tip

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

  7. Choose Appium Node.js to configure your test.

  8. To add your Appium test scripts to the test run, choose Upload.

  9. Choose the MyTests.zip file you created in the previous procedure.

  10. Follow the instructions to choose a test spec.

    If you are using the default test spec, change the test execution command in the test section of the test spec YAML file.

  11. Choose devices and start the run.

    For more information, see Create a Test Run in AWS Device Farm.

Note

Device Farm does not modify Web application Appium Node.js tests.