docker-android/src/appium.sh

63 lines
1.5 KiB
Bash
Raw Normal View History

#!/bin/bash
2018-05-29 01:04:30 +01:00
if [ -z "$GENY_TEMPLATE" ]; then
2018-05-29 23:54:06 +01:00
GENY_TEMPLATE="/root/tmp/devices.json"
2018-05-29 01:04:30 +01:00
fi
function prepare_geny_cloud() {
2018-06-22 00:16:40 +01:00
contents=$(cat $GENY_TEMPLATE)
2018-05-29 01:04:30 +01:00
# Register
gmtool config username="${USER}" password="${PASS}"
gmtool license register "${LICENSE}"
# Start device(s)
echo "Creating device(s) based on given json file..."
for row in $(echo "${contents}" | jq -r '.[] | @base64'); do
get_value() {
echo ${row} | base64 --decode | jq -r ${1}
}
template=$(get_value '.template')
device=$(get_value '.device')
2018-06-19 00:20:15 +01:00
port=$(get_value '.port')
if [[ $port != null ]]; then
echo "Starting \"$device\" with template name \"$template\" on port \"$port\"..."
gmtool --cloud admin startdisposable "${template}" "${device}" --adb-serial-port "${port}"
else
echo "Starting \"$device\" with template name \"$template\"..."
gmtool --cloud admin startdisposable "${template}" "${device}"
fi
2018-05-29 01:04:30 +01:00
done
}
function run_appium() {
echo "Preparing appium-server..."
CMD="appium --log $APPIUM_LOG"
2018-06-20 22:30:54 +01:00
if [ "$CONNECT_TO_GRID" = true ]; then
2018-05-29 01:04:30 +01:00
NODE_CONFIG_JSON="/root/src/nodeconfig.json"
/root/generate_config.sh $NODE_CONFIG_JSON
CMD+=" --nodeconfig $NODE_CONFIG_JSON"
fi
2018-06-20 22:30:54 +01:00
if [ "$RELAXED_SECURITY" = true ]; then
CMD+=" --relaxed-security"
fi
echo "Preparation is done"
2018-05-29 01:04:30 +01:00
$CMD
}
2018-06-22 00:16:40 +01:00
if [ "$REAL_DEVICE" = true ]; then
2018-06-12 00:05:35 +01:00
echo "Using real device"
2018-05-29 01:04:30 +01:00
run_appium
2018-06-22 00:16:40 +01:00
elif [ "$GENYMOTION" = true ]; then
2018-06-12 00:05:35 +01:00
echo "Using Genymotion"
2018-05-29 01:04:30 +01:00
prepare_geny_cloud
run_appium
else
2018-06-12 00:05:35 +01:00
echo "Using Emulator"
2018-05-29 01:04:30 +01:00
python3 -m src.app
fi