1818TEST_TARGET=" $1 "
1919
2020# Set required environment variables for local testing
21- export DEVICE_UDID=" 6AF2014D-BAB3-4E5E-821B-1D908B9BDCA8 " # Use your actual simulator UDID
21+ export DEVICE_UDID=" 963A992A-A208-4EF4-B7F9-7B2A569EC133 " # iPhone 16e (currently booted)
2222export DEVICE_NAME=" iPhone 16"
2323export PLATFORM_VERSION=" 26.0"
2424export APP_BUNDLE_ID=" com.softwareone.marketplaceMobile"
@@ -39,6 +39,32 @@ echo ""
3939echo " 📱 Available simulators:"
4040xcrun simctl list devices | grep iPhone | grep Booted || echo " No booted simulators found"
4141
42+ # Check if Appium is running
43+ echo " "
44+ echo " 🚀 Checking Appium server status..."
45+ if ! curl -s " http://$APPIUM_HOST :$APPIUM_PORT /status" > /dev/null 2>&1 ; then
46+ echo " ⚠️ Appium server not running. Starting Appium..."
47+ appium --log-level warn > /tmp/appium.log 2>&1 &
48+ APPIUM_PID=$!
49+ echo " 📝 Appium PID: $APPIUM_PID "
50+
51+ # Wait for Appium to start
52+ echo " ⏳ Waiting for Appium to start..."
53+ for i in {1..30}; do
54+ if curl -s " http://$APPIUM_HOST :$APPIUM_PORT /status" > /dev/null 2>&1 ; then
55+ echo " ✅ Appium server is ready!"
56+ break
57+ fi
58+ if [ $i -eq 30 ]; then
59+ echo " ❌ Appium failed to start after 30 seconds"
60+ exit 1
61+ fi
62+ sleep 1
63+ done
64+ else
65+ echo " ✅ Appium server is already running"
66+ fi
67+
4268# Determine if target is a suite or spec file
4369if [[ " $TEST_TARGET " == * .js ]]; then
4470 TEST_ARGS=" --spec $TEST_TARGET "
5076 echo " 🚀 Starting WebDriver tests with suite: $TEST_TARGET "
5177fi
5278
53- # Change to app directory and run the test
54- cd app
55- npx wdio run wdio.conf.js $TEST_ARGS
79+ # Change to app directory and run tests
80+ cd " $( dirname " $0 " ) /../app"
81+ npx wdio run wdio.conf.js $TEST_ARGS
82+ TEST_EXIT_CODE=$?
83+
84+ # Stop Appium if we started it
85+ if [ ! -z " $APPIUM_PID " ]; then
86+ echo " "
87+ echo " 🛑 Stopping Appium server..."
88+ kill $APPIUM_PID 2> /dev/null || true
89+ fi
90+
91+ exit $TEST_EXIT_CODE
0 commit comments