I have started working on mobile test automation and had to do lot of research. I found it really difficult to get resources on BDD (Behavior Driven Development), Cucumber, Appium setup. After slogging for a month and documenting everything I did, I was finally able to start doing automation. I believe other testers could be suffering like me, so here are step by step instructions to set up Appium+Cucumber+Java. Enjoy and let me know in case of any questions

This page gives step by step instructions to set up your Mac/Windows machine with Cucumber+Jave+Appium framework.

TABLE OF CONTENTS

  • Components needed for ATDD Automation
  • Installation Instructions Mac and Windows
  • Android Specific Instructions
  • Steps to Ensure Environment is Setup Correctly for ATDD Automation
  • Steps for Manual Installation of Cucumber and Appium JAR files
  • Cucumber Learning Resources

COMPONENTS NEEDED FOR ATDD AUTOMATION

The following components need to be installed

  • Homebrew
  • Node.js
  • Appium (command line)
  • Appium UI application
  • Android Studio (With Android SDK)
  • Set up ANDROID_HOME
  • Android Emulator
  • Java JDK
  • Set up JAVA_HOME
  • Xcode 

INSTALLATION INSTRUCTIONS

Step 1- Install HomeBrew from this link – http://brew.sh/index.html. Copy and paste the command under “Install Homebrew” section in the Terminal/Command Line.

Step 2- Install Node.js and Appium Server.

For Mac Users:

Type the following commands in the Terminal/Command Line.

  • brew install node 
  • npm install -g appium 
  • npm install wd 

For Windows Users:

  • Go to https://nodejs.org/en/download/ 
  • Download Node.js
  • After installation of Node.js type in the below commands
  • npm install -g appium 
  • npm install wd 

Step 3- Install Appium UI application from this link – http://appium.io/downloads.html. Click the Desktop Apps based on Mac/Windows machine. Download and Install appium-1.4.13.dmg file or AppiumForWindows_1_4_16_1.zip based on Mac/PC user.

 NOTE: Sometimes you have problems when downloading appium through Chrome. So it is recommended you use Safari or Firefox

For Mac Users:

  • Ensure you drag the appium folder to the application folder when asked
  • Appium will get copied to the Applications folder

For Windows Users:

  • Double click on appium_installer.exe from the Download folder as show below

Step 4- Install Android Studio from this link – http://developer.android.com/sdk/index.html.

For Mac Users:

  • Click on “Download Android Studio” link and agree to the license.
  • After Download and Installation make sure to drag the Android Studio icon to the Application folder
  • Open Android Studio and Click on “I Do not…” option in the window and let packages download. Wait till the download is complete
  • Minimize Android Studio and go to Step 5

For Windows Users:

  • Open Android Studio and Click on “I Do not…” option in the window and let packages download. Wait till the download is complete
  • Minimize Android Studio and go to Step 5

Step 5- Install Java JDK form this link – http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html.

  • Navigate to “Java SE Development Kit 8u66” and download the necessary file based on Mac/Windows 
  • Then install it after download by double  clicking.

NOTE: Ensure Step 5 is Completed before going to Step 6

Step 6- In Terminal/Command Line type “open .bash_profile“.  We do this to set the JAVA_HOME and ANDROID_HOME path. Once the profile opens type paste the following information with the correct path information and save the file.

For Mac Users:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home

export ANDROID_HOME=/Users/<YOUR USERNAME>/Library/Android/sdk or

 /Users/<YOUR USERNAME>/Library/android-sdks (Based on where the Android SDK is installed)

To ensure the paths are set correctly, please type close the current terminal. Open a new terminal window and type the following

$JAVA_HOME in the terminal. The above JAVA_HOME path set should be displayed

$ANDROID_HOME in terminal. The above ANDROID_HOME path set should be displayed

NOTE: If you cannot find .bash_profile, you need to create one. You can create one by following the below steps

Go to cd /Users/<Username>

Type touch .bash_profile

Type open -a TextEdit.app .bash_profile

 For Windows Users:

Go to Start Menu-> Computer->System Properties->Advanced System Properties

Go to Advanced tab->Environment Variables

Set the JAVA_HOME and ANDROID_HOME Path

Usually JAVA_HOME is set to C:\Program Files\Java\<your jdk version>

ANDROID_HOME is under C:\Users\<your username>\android-sdk-windows

Step 7- (Not required for training but needed to run automation on iPhone simulator) Install Xcode from this link – https://developer.apple.com/xcode/download/.  For windows users please go through this video –

 https://www.youtube.com/watch?v=sb8BdYH4esQ as we need virtual machine to install Xcode unlike Mac Users.

Step 9- Navigate to the below sections based on your machine.

Android Specific Instructions

  • Open an android project in Android Studio. Keep clicking on Next button till the project loads up in the editor.
  • First time the project is opened and when asked for a SDK, please point it to JDK1.7 or 1.8 based on what JDK version you have.
  • The project will indicate missing libraries and may throw errors. Click on the prompt shown by Android Studio to download them automatically on the top right corner of the screen. If you face problems in this please go to last section in this page “Cucumber and Java JAR files and follow the step by step instructions to ensure libraries are installed correctly.
  • Go to Android Studio and open “SDK Manager” and ensure you install all the necessary packages
  • Go to Terminal/Command Line. Type in the following
    • $ANDROID_HOME and press Enter
    • Copy the path
    • Type cd <path name from above>
    • Type cd tools
    • Type ./android avd to open the “Android Virtual Device Manager”.
      • In the AVD Manager click the “Device Definitions” tab
      • Choose “Nexus 4” and select “Create AVD”

NOTE: You need to select “Google API’s Intel Atom (x86)” in the CPU/ABI: field. If you do not see it in the above screen, then go back to the android SDK manager and make sure the package “Intel x86 Atom_64 System Image” and “Intel x86 Atom System Image is installed

  • Click “OK” in the window which pops up
  • Click on the newly created device and then press “Start”. The emulator should open up showing the default android home page. This ensure that the emulator is set up correctly
  • Turning off locking on the emulator
    • Ensure locking is turned off on the android emulator. To turn off locking follow the below steps
      • Navigate to Settings-> Security->Screen Lock-> Select “None”
  • Go to Android Studio-> Preferences
    • Click on Plugins
    • Search for “Cucumber for Java” and you should see it checked in the list. If not install it by checking it.
    • Search for “Gherkin” and you should see it checked in the list, If not install it by checking it.
    • Click on “Apply” and “OK”
    • Now the cucumber and appium framework should be configured with Android Studio.  If not ensure you follow the JAR installation steps mentioned in the Cucumber and Appium JAR files section of the Wiki which can be found below

 

TO ENSURE THE ENVIRONMENT IS SET UP CORRECTLY – (PLEASE READ)

To ensure your laptop set up is correct please do the following-

  • Check 1– Ensure Appium is setup correctly

For Mac users:

Open the Terminal and type “appium” you should see some prompts. This ensures appium is set up correctly

For Windows Users:

Open the command prompt and type the below commands –

cd C:\Program Files (x86)\Appium\node_modules\appium\bin

node appium

This will launch the appium server and this ensures appium is setup correctly

Manual Installation of Cucumber and Appium JAR

Cucumber and Appium JAR files (Files need to get the Cucumber and appium framework in Android Studio)


When Android Studio is opened, you should have automatically got a prompt to import all the dependencies and files. If that did not work properly please import the JAR files manually into Android Studio (NOTE: Download the Cucumber and Appium related JAR Files and save it in a location) . The steps are provided below

  • Click on File-> Project Structure
  • Navigate to Platform Settings -> SDKs
  • Click on the folder “1.8” and click on the “+” sign as shown below
  • Navigate to the location where your downloaded the files and click “OK”
  • You should see your new JAR files added in the list
  • Then click “OK”
  • Go to Android Studio-> Preferences
  • Click on Plugins
  • Search for “Cucumber for Java” and you should see it checked in the list. If not install it by checking it.
  • Search for “Gherkin” and you should see it checked in the list, If not install it by checking it.
  • Click on “Apply” and “OK”
  • Now the cucumber and appium framework should be configured with Android Studio

 

CUCUMBER LEARNING RESOURCES