#!/bin/bash #Author: Eric Sherman #Purpose: Sets up running appium locally. Copies in the proper appium.txt files, stops and restarts appium processes. os=$1 device_or_simulator=$2 appium_source=$3 #can pass anything. if non-null then we assume run from appium source appium_source_dir="../../../appium_from_github.d/appium" #Takes whichever iphone you have attachec and prints it out. Only allows for 1 at a time. apk="./apps/XXX-debug.apk" ios_app_for_device="./apps/XXXe.app" android_pkg_name="com.XXXX.XX"" bundle_id="com.XX.XX"" #Get the udid dynamically udid=`system_profiler SPUSBDataType | sed -n -e '/iPad/,/Serial/p' -e '/iPhone/,/Serial/p' | grep "Serial Number:" | awk -F ": " '{print $2}'` function Usage { echo "Usage: ../$(basename $0) os platform appium_source " echo -e "\tos: " echo -e "\tplatform: " echo -e "\tappium_source: if left blank, we assume not running appium from source" echo -e "\t\tExample: $(basename $0) ios nosauce simulator source //runs test in iOS 8 simulator using local appium source" exit 0 } function wrongDirUsage { echo -e "You are not in the appium directory where the features subdirectory is!!" exit 0 } #Function that kills old appium processes function killAppium { for i in `ps -ef | egrep 'appium|node' | grep -v $$ | awk '{print $2}'` do echo "killing process $i" kill -9 $i done echo "Waiting for pids to stop on their own..." sleep 1 } function run_appium_ios { #Currently commented out. Need to figure out a better way to dynamically determine what ipa we want in here if [ "$device_or_simulator" == "device" ] then #Run from source or not? if test "$appium_source" != "" then cd $appium_source_dir node . -U ${udid} --app "${bundle_id} --no-reset" else #appium -U ${udid} --app "${bundle_id} --native-instruments-lib " appium -U ${udid} --app "${bundle_id} --no-reset" fi else if test "$appium_source" != "" then cd $appium_source_dir node . --no-reset else appium --no-reset fi fi } function run_appium_android { echo "reinstalling apk from ./apps directory" adb uninstall ${android_pkg_name} adb install -r "${apk}" if test "$appium_source" != "" then cd $appium_source_dir node . --no-reset else appium --no-reset fi } ###### #MAIN ###### #Usage checks if [ ! -d "./features" ] then echo -e "You are not in the appium directory where the features subdirectory is!!" exit 0 fi if test "$device_or_simulator" == "" || test "$os" == "" then Usage fi #Bring down old appium processes killAppium #Start Appium if [ $os == "android" ] then run_appium_android else run_appium_ios fi