Tuesday, December 15, 2015

Set up Appium for beginners (Android & iOS)

Appium is an open source test automation tool to automate native and hybrid mobile apps. For more details about the tool please go through http://appium.io/

Below are the steps for setting up Appium in your test machine (with Eclipse):

Step-1: Install Java
Ensure you have java installed in your machine. If not installed, please install it as per the below steps.
  1. Download latest java from http://www.oracle.com/technetwork/java/javase/downloads/index.html or from http://java.com/en/download/
  2. Double click on the downloaded file and follow the instructions to finish the installation. Please note the installation directory.
  3. Once java is installed, you need to set the path for java as follows
    For path setting in Windows,
    For path setting in Mac, please follow the below instructions
    • Look for ".bash_profile" in your home folder
    • If hidden files are not shown by default, you won't see this file. So execute below 2 command to show hidden files in mac
    defaults write com.apple.finder AppleShowAllFiles YES
    killall Finder
    
    • Start up Terminal
    • Type "cd ~/" to go to your home folder
    • Type "touch .bash_profile" to create your new file if ".bash_profile" doesn't exist
    • Edit ".bash_profile" with your favorite editor (or you can just type "open -e .bash_profile" to open it in TextEdit.
    • Update the file with the installed java home location as below example format
    set JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home
    export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home
    export PATH=$PATH:${JAVA_HOME}:${JAVA_HOME}/bin
  4. To test java installation, open your command prompt(in windows) or terminal(in mac) and enter
  5. java -version
    • You will get the version of java you have installed as below example,
    java version "1.8.0_71"
    Java(TM) SE Runtime Environment (build 1.8.0_71-b15)
    Java HotSpot(TM) 64-Bit Server VM (build 25.71-b15, mixed mode)
    
Step-2: Download ADT bundle for Eclipse(Only if you want to test android application, not required for iOS application testing)
  1. You can download adt bundles (e.g. version 2014-07-02) from below sites:
  2. windows 32: https://dl.google.com/android/adt/adt-bundle-windows-x86-20140702.zip
    windows 64: https://dl.google.com/android/adt/adt-bundle-windows-x86_64-20140702.zip
    Mac 64: https://dl.google.com/android/adt/adt-bundle-mac-x86_64-20140702.zip
    Linux 86: https://dl.google.com/android/adt/adt-bundle-linux-x86-20140702.zip
    Linux 64: https://dl.google.com/android/adt/adt-bundle-linux-x86_64-20140702.zip
  3. Extract the downloaded zip file and extract them to a safe folder. Inside the folder you will find 2 folders. One is eclipse and another with SDK for android
  4. Set the PATH for android SDK. 
    • In Windows, create a system variable ANDROID_HOME and append the "tools" and "platform-tools" locations in PATH environment variable
    ANDROID_HOME=D://android/adt-bundle-windows-x86_64-20140702/sdk
    PATH=%ANDROID_HOME%//tools;%ANDROID_HOME%//platform-tools;
    • In Mac, append the below in ".bash_profile" file
    set ANDROID_HOME=/Applications/adt-bundle-mac-x86_64-20140702/sdk
    export ANDROID_HOME=/Applications/adt-bundle-mac-x86_64-20140702/sdk
    export PATH=$PATH:${JAVA_HOME}:${JAVA_HOME}/bin:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
  5. Then you need to test sdk installation in the system. To do this, navigate to "platform-tools" directory inside sdk from command line or terminal and type command
  6. adb devices
    • You should get the below message in the terminal or command prompt
    * daemon not running. starting it now on port 5037 *
    * daemon started successfully *
    List of devices attached 
    
    • If you won't see "List of devices attached" message in the output, you might not set the sdk path properly. Please check the steps once again and correct the missing ones to get it properly.
  7. If you want latest android versions, open SDK manager and update the required android versions.
Step-3: Install Appium
  1. Open terminal and type below command
  2. sudo chown -R `whoami` /usr/local
    • Click the enter key and enter system password if it asks
    • Note: Sometimes in Mac system, you may get command not found error. Then please ensure the below is added in your ".bash_profile". You can addend at the end of file.
    export PATH=$PATH:/usr/sbin
    export PATH=$PATH:/usr/bin
    export PATH=$PATH:/usr/local/bin
  3. Next type the below command
  4. ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    
    • Then click enter and follow the instructions to continue (provide system password is prompts)
    • Note: In mac machine, it may prompt for any dependant software (e.g. xcode) then please click on install, if you want to test an iOS application. If you want to test an android application you don't need to install it.
  5. Next install node by below command
  6. brew install node
    
    • and click enter. It downloads some files and installs them
    • To see node is installed successfully, please type below in command line
    node -v
    
    •  and click enter then you can see the version of the node installed
  7. Install appium by executing below command
  8. npm install -g appium
    
    •  and click enter, it will take some time to download all the appium related installations. 
  9. To test appium installation, use below command
  10. appium
    
    •  and click enter, it will show the version of appium running and will start the appium server from command line.
    info: Welcome to Appium v1.4.16 (REV ae6877eff263066b26328d457bd285c0cc62430d)
    info: Appium REST http interface listener started on 0.0.0.0:4723
    info: Console LogLevel: debug
    
    Now you can proceed with developing/executing android or iOS automated tests using appium.
    Happy testing!!!

8 comments:

  1. Thanks for sharing this information.It was very nice blog to learn about Appium.
    http://thecreatingexperts.com/appium-training-in-chennai/

    ReplyDelete
  2. Thanks for sharing this Information, Got to learn new things from your Blog on Appium training in chennai

    ReplyDelete
  3. This was so useful and informative. The article helped me to learn something new. iOS Training in Chennai

    ReplyDelete
  4. Hai Good information shared about IOS. Keep sharing updated ios tutorials. This blog post is really helpful.

    ReplyDelete
  5. Finding the time and actual effort to create a superb article like this is great thing. I’ll learn many new stuff right here! Good luck for the next post buddy..
    Embedded Training in Chennai

    ReplyDelete
  6. Thanks for sharing the great information. It helps to all the basic level to higher level of Appium Learners.

    ReplyDelete