Automate the Chromium web browser with Selenium and Python
466
This Docker image provides a streamlined, lightweight Alpine Linux environment equipped with the Chromium browser, Chromium WebDriver, and the Python Selenium package. It’s ideal for automated browser testing and headless web scraping.
unittest script for quick automated testingThis image includes a preconfigured Selenium test at /app/test_selenium.py that uses unittest and explicit waits for reliability.
docker run --rm agentlans/alpine-chromium-selenium
Expected output:
.
----------------------------------------------------------------------
Ran 1 test in X.XXXs
OK
You can mount your project directory and execute any Selenium script directly within the container.
Example test script (quick_test.py):
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--no-sandbox")
driver = webdriver.Chrome(options=chrome_options)
driver.get("https://www.example.com")
print(driver.title)
driver.quit()
Run it inside the container:
docker run --rm -v $(pwd):/app -w /app agentlans/alpine-chromium-selenium python3 quick_test.py
Expected output:
Example Domain
To build the image locally, you'll need the Dockerfile then run:
docker build -t agentlans/alpine-chromium-selenium .
These are preconfigured for immediate use with Selenium:
CHROME_BIN: Path to the Chromium browser binaryCHROME_PATH: Path to the Chromium installation directoryPATH: Includes binaries from the Python virtual environmentMIT License
Content type
Image
Digest
sha256:4c3cd0360…
Size
340 MB
Last updated
11 months ago
docker pull agentlans/alpine-chromium-selenium