A sandbox to develop python projects based on Selenium.
This project uses a docker image that includes all required resources such as:
You can test environment with the following commands:
-
Docker build and login (from linux shell):
make build login # Build docker image and Login docker container
-
Run test.py script (from docker container)
./test.py # Run test.py script (open google chrome browser) exit # Exit from docker container
NOTE
The project include the .devcontainer folder to automate the docker build and develop within vscode.
The docker image can be manually built as follow:
# make build
docker build -t ricfio/python-selenium:3.12 .
The project docker image was built as a customization from:
mcr.microsoft.com/vscode/devcontainers/python:0-3.12-bullseye
# make run
docker run -it --rm --net host -e DISPLAY=unix$(DISPLAY) ricfio/python-selenium:3.12 google-chrome-stable --no-sandbox
This project uses some python packages that can be installed with pip:
pip install selenium
pip install webdriver-manager
The Google Chrome browser was installed in the docker image (linux debian based) as follow:
cd ~
sudo apt update
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb || true && sudo apt -y --fix-broken install
sudo apt clean
google-chrome-stable --version
You can run Google Chrome also inside a docker container (debian based) on Windows 10 using VcXsrv Windows X Server.
- Install the X-Server 'VcXsrv Windows X Server' (on Windows 10)
- Run 'XLaunch for Windows' (on Windows 10)
- Run Google Chrome from the docker container
Further details to install VcXsrv:
google-chrome-stable --no-sandbox --display=host.docker.internal:0.0 --disable-dev-shm-usage