Files
tilbudgivern/tests/selenium/run_carpenter_tests.sh

101 lines
3.0 KiB
Bash
Executable File

#!/bin/bash
# Run Selenium Carpenter Quote Tests
# This script runs the complete UI test suite using Selenium
set -e
echo "🔨 Selenium Carpenter Quote Tests"
echo "=================================="
echo ""
# Check if Python 3 is installed
if ! command -v python3 &> /dev/null; then
echo "❌ Python 3 is required but not installed"
exit 1
fi
# Check if Chrome/Chromium is installed
if ! command -v google-chrome &> /dev/null && ! command -v chromium-browser &> /dev/null; then
echo "⚠️ Chrome/Chromium not found. Selenium requires Chrome."
echo " Install with: sudo apt-get install chromium-browser"
fi
# Check if virtual environment exists
if [ ! -d "../../.venv" ]; then
echo "⚠️ Virtual environment not found at ../../.venv"
echo " Creating virtual environment..."
python3 -m venv ../../.venv
fi
# Activate virtual environment
source ../../.venv/bin/activate
# Install/upgrade required packages
echo "📦 Installing/upgrading required packages..."
pip install -q --upgrade selenium requests
# Check if ChromeDriver is available
if ! command -v chromedriver &> /dev/null; then
echo "⚠️ ChromeDriver not found in PATH"
echo " Installing ChromeDriver..."
# Detect Chrome version and install matching ChromeDriver
CHROME_VERSION=$(google-chrome --version | grep -oP '\d+\.\d+\.\d+\.\d+' || chromium-browser --version | grep -oP '\d+\.\d+\.\d+\.\d+')
if [ ! -z "$CHROME_VERSION" ]; then
echo " Detected Chrome version: $CHROME_VERSION"
# You may need to download ChromeDriver manually for your version
echo " Please download ChromeDriver from: https://chromedriver.chromium.org/downloads"
fi
fi
# Check if servers are running
echo ""
echo "🔍 Checking if servers are running..."
if ! curl -s http://localhost:4031/health > /dev/null 2>&1; then
echo "❌ Backend server not running on port 4031"
echo " Start with: cd ../../backend && node unified-server.js"
exit 1
fi
if ! curl -s http://localhost:3000 > /dev/null 2>&1; then
echo "❌ Frontend server not running on port 3000"
echo " Start with: cd ../../frontend && npm start"
exit 1
fi
echo "✅ Backend server running"
echo "✅ Frontend server running"
echo ""
# Create screenshots directory
mkdir -p ../test-results/selenium-screenshots
# Run tests
echo "🚀 Running Selenium tests..."
echo ""
python3 carpenter_quote_test.py
# Check exit code
if [ $? -eq 0 ]; then
echo ""
echo "=================================="
echo "✅ ALL TESTS PASSED"
echo "=================================="
echo ""
echo "📸 Screenshots saved to: ../test-results/selenium-screenshots/"
echo "📄 Test results: ../test-results/selenium-screenshots/test_results.json"
echo ""
else
echo ""
echo "=================================="
echo "❌ SOME TESTS FAILED"
echo "=================================="
echo ""
echo "Check screenshots in: ../test-results/selenium-screenshots/"
exit 1
fi