mirror of
https://github.com/appium/appium.git
synced 2026-01-21 09:39:52 -06:00
Added support for --udid to the reset scripts.
This commit is contained in:
31
reset.bat
31
reset.bat
@@ -11,6 +11,8 @@ SET doAndroid=0
|
||||
SET doVerbose=0
|
||||
SET doForce=0
|
||||
SET pigsFly=0
|
||||
SET chromedriver_version=
|
||||
SET udid=
|
||||
|
||||
:: Read in command line switches
|
||||
:loop
|
||||
@@ -22,7 +24,9 @@ IF "%~1" neq "" (
|
||||
IF "%1" == "--force" SET doForce=1
|
||||
IF "%1" == "--chromedriver-version" IF "%2" neq "" (
|
||||
SET "chromedriver_version=%2"
|
||||
shift
|
||||
)
|
||||
IF "%1" == "--udid" IF "%2" neq "" (
|
||||
SET "udid=%2"
|
||||
)
|
||||
shift
|
||||
goto :loop
|
||||
@@ -183,12 +187,25 @@ GOTO :EOF
|
||||
:: Function to uninstall an Android app
|
||||
:uninstallAndroidApp
|
||||
ECHO Attempting to uninstall android app %~1
|
||||
FOR /F "delims=" %%i in ('adb devices ^| find /v /c ""') DO SET deviceCount=%%i
|
||||
IF %deviceCount% GTR 2 (
|
||||
CALL :runCmd "adb uninstall %~1 | VER > NUL"
|
||||
) ELSE (
|
||||
ECHO No android devices detected, skipping uninstallation
|
||||
)
|
||||
FOR /F "delims=" %%i in ('adb devices ^| FINDSTR /R "device$" ^| find /v /c ""') DO SET deviceCount=%%i
|
||||
IF %deviceCount% GEQ 1 (
|
||||
GOTO :deviceExists
|
||||
) ELSE ECHO No android devices detected, skipping uninstallation
|
||||
GOTO :EOF
|
||||
|
||||
:deviceExists
|
||||
IF DEFINED udid (
|
||||
GOTO :udidSpecified
|
||||
) ELSE IF %deviceCount% EQU 1 (
|
||||
CALL :runCmd "adb uninstall %~1 | VER > NUL"
|
||||
) ELSE ECHO More than one device present, but no device serial provided, skipping uninstallation (use --udid)
|
||||
GOTO :EOF
|
||||
|
||||
:udidSpecified
|
||||
FOR /F "delims=" %%i in ('adb devices ^| FINDSTR /R "^%udid%" ^| find /v /c ""') DO SET specifiedDeviceCount=%%i
|
||||
IF %specifiedDeviceCount% EQU 1 (
|
||||
CALL :runCmd "adb -s %udid% uninstall %~1 | VER > NUL"
|
||||
) ELSE ECHO Device with serial %udid% not found, skipping installation
|
||||
GOTO :EOF
|
||||
|
||||
:: Function to run commands
|
||||
|
||||
13
reset.sh
13
reset.sh
@@ -44,6 +44,7 @@ do
|
||||
"--hardcore") hardcore=true;;
|
||||
"--chromedriver-version") chromedriver_version=$2;;
|
||||
"--chromedriver-install-all") chromedriver_install_all=true;;
|
||||
"--udid") udid=$2;;
|
||||
esac
|
||||
|
||||
if [[ -n "$2" ]] && [[ "$2" != --* ]]; then
|
||||
@@ -235,7 +236,17 @@ uninstall_android_app() {
|
||||
echo "* Attempting to uninstall android app $1"
|
||||
if (which adb >/dev/null); then
|
||||
if (adb devices | grep "device$" >/dev/null); then
|
||||
run_cmd adb uninstall $1
|
||||
if [[ ! -z $udid ]]; then
|
||||
if (adb devices | grep "^$udid" >/dev/null); then
|
||||
run_cmd adb -s $udid uninstall $1
|
||||
else
|
||||
echo "* Device with serial $udid not found, skipping"
|
||||
fi
|
||||
elif [[ $(adb devices | grep "device$" | wc -l) -eq 1 ]]; then
|
||||
run_cmd adb uninstall $1
|
||||
else
|
||||
echo "* More than one device present, but no device serial provided, skipping (use --udid)"
|
||||
fi
|
||||
else
|
||||
echo "* No devices found, skipping"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user