A demonstration repository for running JavaScript Selenium tests inside Docker containers.
This project shows how to execute Selenium test scripts using Docker, enabling you to run tests in Chrome, Edge, and Firefox browsers without installing browser dependencies or headless browsers locally. All browsers run inside Docker containers, providing a portable and consistent test environment.
- Docker (Docker Desktop or similar)
- Node.js (Latest LTS version recommended)
-
Start Docker Desktop
Ensure Docker is running on your machine. -
Start Browser Containers
Navigate to the project directory and run:docker-compose upThis command launches the necessary browser containers for Selenium.
-
Run Selenium Tests
In a separate terminal, navigate to the project directory and execute:node test.jsThis runs the Selenium test scripts within the Docker browser environments.
- No Local Browser Dependency: Eliminates the need to install browsers on your host machine.
- Consistent Environment: Ensures tests are not impacted by changes or updates to browsers or local machine configurations.
- Easy Browser Version Control: Quickly run tests against specific or older browser versions by swapping Docker images.
- Machine Compatibility: Test environments remain the same regardless of where they're run, reducing "it works on my machine" issues.