Code Monkey home page Code Monkey logo

android-appium-test-environment-setup's Introduction

How to set up Android test environment on Jenkins

Requirements

  • Install Java(1.8.0_144) Click here
  • Install Appium(1.8.1) Click here
  • If there is any issue while installing Brew, then Click here and follow all steps as per Appium document.
  • Install Android Studio(26.1.1) Link 1 or Link 2
  • Start Appium server programmatically Click here

Steps to set android path for ubuntu

$ whereis android

E.g  android: /var/lib/android-sdk/tools/android

$ vi ~/.bashrc (or vi ~/.rc depending on the shell)

# Insert Android path to shell
export ANDROID_HOME=/var/lib/android-sdk
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$PATH:$ANDROID_HOME/build-tools 

# Now check below command
$ adb devices

Nested virtualization for Google cloud VM Instances

Install KVM

Steps to Download system images for emulator

  • System images are pre-installed Android operating systems, and are only used by emulators.
  • For e.g: API Level 24-25 is Nougat.
$ cd $ANDROID_HOME/tools/bin
$ ./sdkmanager "system-images;android-25;google_apis;x86"
$ ./sdkmanager --licenses

Steps to Create Emulator


$ cd $ANDROID_HOME/tools/bin
$ ./avdmanager create avd -n <DeviceName> -k "system-images;android-25;google_apis;x86"

Verify Emulator

$ cd $ANDROID_HOME/tools/bin
$ ./avdmanager list avds

--------------------
Available Android Virtual Devices:
    Name: testEmulator
    Path: /var/lib/jenkins/.android/avd/credit.avd
  Target: Google APIs (Google Inc.)
          Based on: Android 6.0 (Marshmallow) Tag/ABI: google_apis/x86
--------------------

Jenkins environment configuration

  • Login to jenkins.
  • Click on Manage Jenkins from left menu.
  • Click on Configure System.
  • As per your configuration add below environment variables.

Name : ANDROID_HOME
Value: /var/lib/android-sdk

Name : PATH
Value: /home/linuxbrew/.linuxbrew/sbin:/home/linuxbrew/.linuxbrew/bin:/var/lib/android-sdk/tools:/var/lib/android-sdk/platform-tools:/var/lib/android-sdk/build-tools

Jenkins job configuration(Execute below script using shell)


# stop adb
adb kill-server

#Start adb
adb start-server


#Start the emulator
$ANDROID_HOME/tools/emulator -avd <DeviceName> -no-window -wipe-data &
EMULATOR_PID=$!


# Wait for Android to finish booting
WAIT_CMD="adb wait-for-device shell getprop init.svc.bootanim"
until $WAIT_CMD | grep -m 1 stopped; do
  echo "Waiting..."
  sleep 1
done


# Unlock the Lock Screen
adb shell input keyevent 82


# Clear and capture logcat
adb logcat -c
adb logcat > build/logcat.log &
LOGCAT_PID=$!

# Allow “unknown sources” from Terminal without going to Settings App
adb shell settings put global install_non_market_apps 1

# Go to android team project dir
cd /var/lib/jenkins/qa_automation/android_apps/AndroidTeamProject
git checkout -f develop;
git pull origin develop;
./gradlew installStagingDebug;

# Check devices
adb devices;

# Go to testing team project dir
cd ~/qa_automation/test_automation/TesterTeamProject;
mvn clean compile test 


# Stop the background processes
kill $LOGCAT_PID
kill $EMULATOR_PID

android-appium-test-environment-setup's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.