yazidisme / setup-appium-testng

Setup Android Test Automation using Appium and TestNG with Java Language in MacOS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Setup Android Test Automation using Appium and TestNG with Java Language in MacOS

1. Java Development Kit (JDK)

  • Download and install JDK
  • Type java -version in your Terminal to verify installation and find out your java version
  • See the output of java version

2. Android Studio

3. Homebrew

  • Install Homebrew using Terminal and enter the following command
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Follow the instructions until Homebrew installing success
  • Type brew --version to find out your homebrew version
  • See the output of homebrew version

4. Node.js

  • Install node.js using brew, type brew install node in your Terminal
  • Wait until node.js installing success
  • Type node --version to find out your node version
  • Type npm --version to find out your npm version
  • See the output of node and npm version

5. Setting the system variables

  • Create and open your .zshrc using Terminal
    $ cd ~/
    $ touch .zshrc
    $ open -e .zshrc
  • Set the Java and Android SDK paths in zshrc file
    export JAVA_HOME=/Library/Java/JavaVirtualMachines/JDK_VERSION_FOLDER/Contents/Home
    export ANDROID_HOME=/Users/SOME_FOLDERS/Library/Android/sdk
    export PATH=$PATH:$ANDROID_HOME/tools
    export PATH=$PATH:$ANDROID_HOME/tools/bin
    export PATH=$PATH/:$ANDROID_HOME/platform-tools
    export PATH=$PATH:$JAVA_HOME/bin
    
  • Save and exit your .zshrc
  • Run emulator or connecting your real device
  • Type adb devices in Terminal to find out name and connection of your devices
  • See the output of list of devices

6. Appium

  • Install Appium with npm in your Terminal using the following command
    $ npm install -g appium
  • To ensure that we are ready to use Appium, you can run the following command
    $ appium-doctor
  • Minimum requirements for android testing from appium-doctor
    • HOME is set to: /Users/some_folders
    • ANDROID_HOME is set to: /Users/some_folders/Library/Android/sdk ✔
    • JAVA_HOME is set to: /Library/Java/JavaVirtualMachines/jdk_version_folder/Contents/Home ✔
    • adb exists at: /Users/some_folders/Library/Android/sdk/platform-tools/adb ✔
    • android exists at: /Users/some_folders/Library/Android/sdk/tools/android ✔
    • emulator exists at: /Users/some_folders/Library/Android/sdk/tools/emulator ✔
    • Bin directory of $JAVA_HOME is set ✔

7. JAR files

8. Eclipse

  • Download and install Eclipse IDE on your macOS
  • Launch the Eclipse IDE
  • Create a new java project in Eclipse
  • In java setting (create new project), click libraries tab
  • Add all external jar files
    • gson.jar
    • java-client.jar
    • selenium-server-standalone.jar
    • selenium-java.jar or client-combined.jar
    • Add to attachment selenium-java-sources.jar or client-combined-sources.jar in selenium-java.jar
  • Finish

9. TestNG

Finally...
We are ready to write Appium test code
  • See the sample of java project
  • Before execute your android tests, device must be connected with adb devices and Appium must be opened in your Terminal.
  • Find out the app package and app activity in Terminal using the following command
    $ adb shell "dumpsys window windows | grep -E 'mCurrentFocus|mFocusApp'"
  • See the output result, there are com.google.android.youtube as app package and com.google.android.apps.youtube.app.WatchWhileActivity as app activity
  • Finding locators using uiautomatorviewer from Android Studio, type the following command in Terminal
    $ uiautomatorviewer
  • See the uiautomatorviewer

About

Setup Android Test Automation using Appium and TestNG with Java Language in MacOS

License:MIT License