-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrun_tests_android.sh
More file actions
executable file
·68 lines (56 loc) · 1.65 KB
/
run_tests_android.sh
File metadata and controls
executable file
·68 lines (56 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
# Detect OS and set Python command
if [[ "$OSTYPE" == "darwin"* ]]; then
PYTHON_CMD="python3"
else
PYTHON_CMD="python"
fi
# Install dependencies
echo "Installing dependencies"
chmod 0755 requirements.txt
$PYTHON_CMD -m pip install -r requirements.txt
# Check if Appium uiautomator2 driver is installed
echo "Checking Appium uiautomator2 driver..."
if appium driver list --installed 2>&1 | tail -1 | grep -q "uiautomator2"; then
echo "uiautomator2 driver already installed"
else
echo "Installing uiautomator2 driver..."
appium driver install uiautomator2
fi
# Stop any existing Appium instances
echo "Stopping any existing Appium instances..."
pkill -f appium 2>/dev/null || true
sleep 2
# Start Appium server
echo "Starting Appium..."
appium --log-no-colors --log-timestamp -p 4723 --keep-alive-timeout 60 > appium.log 2>&1 &
# Wait for Appium to start
echo "Waiting for Appium to start..."
MAX_WAIT=30
COUNTER=0
while [ $COUNTER -lt $MAX_WAIT ]; do
if lsof -i :4723 >/dev/null 2>&1; then
echo "Appium started successfully!"
break
fi
echo "Waiting... ($COUNTER/$MAX_WAIT)"
sleep 1
COUNTER=$((COUNTER + 1))
done
if [ $COUNTER -eq $MAX_WAIT ]; then
echo "Error: Appium failed to start within $MAX_WAIT seconds"
exit 1
fi
ps -ef|grep appium
# Set environment variables for the test
export APPIUM_APPFILE=$PWD/app/TrashCat.apk
export APPIUM_URL="http://localhost:4723"
export APPIUM_DEVICE="Local Device"
export APPIUM_PLATFORM="android"
export APPIUM_AUTOMATION="uiautomator2"
# Clean up old screenshots
rm -rf screenshots
# Run tests
echo "Running tests"
$PYTHON_CMD -m pytest tests/ -s
echo "Tests done"