diff --git a/Appium/Dockerfile b/Appium/Dockerfile index b4aac08..b4ec8e6 100644 --- a/Appium/Dockerfile +++ b/Appium/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:focal-20230126 +FROM ubuntu:bionic-20230126 ENV DEBIAN_FRONTEND=noninteractive diff --git a/Appium/start.sh b/Appium/start.sh index b520179..d1af649 100755 --- a/Appium/start.sh +++ b/Appium/start.sh @@ -2,14 +2,16 @@ # It is workaround to access adb from androidusr echo "Prepare adb to have access to device" -sudo /opt/android/platform-tools/adb devices +sudo /opt/android/platform-tools/adb devices >/dev/null sudo chown -R 1300:1301 .android echo "adb can be used now" # Connect device via wireless if [ "${REMOTE_ADB}" = true ]; then echo "Connect device via wireless" - ./${APP_PATH}/wireless_autoconnect.sh + # Avoid lost connection + ${APP_PATH}/wireless_autoconnect.sh && \ + ${APP_PATH}/wireless_connect.sh fi # Command to start Appium @@ -18,15 +20,15 @@ command="xvfb-run appium --log $APPIUM_LOG" # Adding Selenium configurations if needed if [ "${CONNECT_TO_GRID}" = true ]; then - NODE_CONFIG_JSON="/${APP_PATH}/nodeconfig.json" + NODE_CONFIG_JSON="${APP_PATH}/nodeconfig.json" if [ "${CUSTOM_NODE_CONFIG}" != true ]; then - ./${APP_PATH}/generate_selenium_config.sh ${NODE_CONFIG_JSON} + ${APP_PATH}/generate_selenium_config.sh ${NODE_CONFIG_JSON} fi command+=" --nodeconfig ${NODE_CONFIG_JSON}" fi if [ "${DEFAULT_CAPABILITIES}" = true ]; then - DEFAULT_CAPABILITIES_JSON="/${APP_PATH}/defaultcapabilities.json" + DEFAULT_CAPABILITIES_JSON="${APP_PATH}/defaultcapabilities.json" command+=" --default-capabilities ${DEFAULT_CAPABILITIES_JSON}" fi diff --git a/Appium/wireless_autoconnect.sh b/Appium/wireless_autoconnect.sh index 865e1d6..69ba58a 100755 --- a/Appium/wireless_autoconnect.sh +++ b/Appium/wireless_autoconnect.sh @@ -10,7 +10,7 @@ if [ ! -z "${REMOTE_ADB}" ]; then while true; do #to avoid immediate run sleep ${REMOTE_ADB_POLLING_SEC} - /root/wireless_connect.sh + ${APP_PATH}/wireless_connect.sh done } diff --git a/Appium/wireless_connect.sh b/Appium/wireless_connect.sh index 3e78675..ccc12e6 100755 --- a/Appium/wireless_connect.sh +++ b/Appium/wireless_connect.sh @@ -1,17 +1,17 @@ #!/bin/bash if [ ! -z "${ANDROID_DEVICES}" ]; then - connected_devices=$(adb devices) IFS=',' read -r -a array <<<"${ANDROID_DEVICES}" for i in "${!array[@]}"; do array_device=$(echo ${array[$i]} | tr -d " ") #string contains check if [[ ${connected_devices} != *${array_device}* ]]; then echo "Connecting to: ${array_device}" - adb connect ${array_device} + adb connect ${array_device} >/dev/null 2>/dev/null + #Give time to finish connection + sleep 2 + adb devices echo "Success!" fi done - #Give time to finish connection - sleep 1 fi