/android-ios-cucumber-example

iOS & Android UI Automated Tests using Appium & Cucumber

Primary LanguageJava

Setup

Setup appium

  1. Install homebrew:

    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

  2. Install node using homebrew:

    brew install node

  3. Install appium for command line:

    npm install -g appium

  4. Make sure you have Android Studio (and Android SDK) and Xcode installed

  5. Install carthage (used for iOS):

    brew install carthage

  6. Use Appium Desktop to inspect the UI elements

Run the following commands to make sure you have the correct versions for:

  • npm -v
  • node -v
  • appium -v
  • rvm -v (Only if you use rvm)

Setup automation project

  1. Checkout the project

  2. Download and install JDK 1.8.

  3. Add the environment paths

  • Type defaults write com.apple.finder AppleShowAllFiles YES in terminal to view hidden files

  • Alt+Right click on finder and click relaunch to activate changes

  • Navigate to your user's directory

  • If you don't have a .bash_profile file, you can create one by following these steps:

    • Start up Terminal
    • Type cd ~/ to go to your home folder
    • Type touch .bash_profile to create your new file.
    • Edit .bash_profile with your favorite editor (or you can just type open -e .bash_profile to open it in TextEdit.
  • Add the following to the bash_profile:

    • export ANDROID_HOME={path to your android sdk}
    • export JAVA_HOME=/Library/Java/JavaVirtualMachines/{jdk version}/Contents/Home/
    • export PATH=${JAVA_HOME}/bin:$PATH
  1. Import the project in IntelliJ IDEA (using import from external model Gradle) and do a Gradle sync

  2. Install Cucumber for Java plugin

  • From the menu, select IntelliJ IDEA -> Preferences
  • Go to Plugins
  • Click Install JetBrains plugins
  • Select Cucumber for Java and click install
  • You will have to restart IntelliJ
  1. Duplicate all .properties files from /src/test/resources/config/ into /src/test/resources/config/local/ and update the new files with the values specific to your machine (usually the same way you've set up Appium UI app).

  2. Run tests

  • Right-click on a test class/feature file and select Run
  • Use the appropriate value for the PLATFORM key in the global.properties should be added (Android or iOS)

NOTE In case you encounter connection problems with the Appium server, you should update rvm to the last version:

`rvm get head`
  1. If you encounter any errors, you can use the appium doctor:

    npm install -g appium-doctor

    appium-doctor --[android/ios]

  2. Some tests do not work when the keyboard is visible. You may need to disable the software keyboard on your emulator, by using:

adb shell settings put secure show_ime_with_hard_keyboard 0

  1. On iOS due to the way we're querying the list of acquaintances you will notice performance issues when using AcquaintNativeiOS.app since the UITableView (the list) has many entries. This is by design - meant to highlight performance considerations. Feel free to point to AcquaintNativeiOS-shortlist.app to see the difference in impact.

Additional links

Appium

Cucumber