This guide will walk you through the steps necessary to test a locally-built Chrome extension using Selenium in Python with Docker.
- Docker (latest version recommended)
- Python 3.x
- Git
git clone https://github.com/turbo-src/selenium-chrome-extension-testing.git
cd selenium-chrome-extension-testing
This command clones the project from GitHub and navigates into the project directory.
python -m venv venv
source venv/bin/activate
After running this command, your shell prompt should change to show the name of the activated environment.
pip install -r requirements.txt
This command installs the required Python packages specified in requirements.txt
into the virtual environment.
docker run -d -p 4444:4444 -p 7900:7900 --shm-size="2g" selenium/standalone-chrome:latest
This command starts a new container with the Selenium standalone Chrome server.
With the Selenium server running in Docker and your Python virtual environment activated, you can now run your test script:
python test_selenium.py
When you are done, you can deactivate the virtual environment:
deactivate
After running this command, the shell prompt will return to normal, indicating that the virtual environment is deactivated.
To stop the Selenium server running in the Docker container:
docker stop $(docker ps -q -f ancestor=selenium/standalone-chrome:latest)
docker rmi selenium/standalone-chrome:latest
This command removes the Docker image named selenium/standalone-chrome:latest
.