pipeline {
    agent any

    stages {
        stage('Install Chrome and ChromeDriver') {
            steps {
                // Install Chrome and ChromeDriver if necessary (Linux environment)
                sh 'sudo apt-get update'
                sh 'sudo apt-get install -y google-chrome-stable'
                sh 'wget https://chromedriver.storage.googleapis.com/$(curl -s https://chromedriver.storage.googleapis.com/LATEST_RELEASE)/chromedriver_linux64.zip'
                sh 'unzip chromedriver_linux64.zip'
                sh 'sudo mv chromedriver /usr/local/bin/'
            }
        }
        stage('Run Tests') {
            steps {
                // Run the tests in a headless Chrome environment
                sh 'mvn test'
            }
        }
    }
}

