Running Selenium with chromedriver inside a Windows container
Running Selenium for Web UI testing in a Windows container is a little bit tricky. I spent a week on this and finally could make it to work thanks to the idea in . Woohuu!
Let's take a look at this sample Java application that runs Selenium with chromedriver.
1. Make sure your Desktop Docker running with Windows Container mode
2. In your Dockerfile, make sure:
- Install the needed fonts (googlechrome) => this is the most important thing!
ADD files/fonts.tar /Fonts/
RUN @powershell -NoProfile -ExecutionPolicy Bypass -Command ".\Add-Font.ps1 Fonts"
- Enable Web-WebSockets feature using Powershell
- Install chocolatey to install openjdk8, and googlechrome
- Copy the chromedriver.exe driver into your working directory
ADD files/drivers/chromedriver.exe "C:/ProgramData/drivers"
3. Build your Docker image using Powershell with administrator privileges
PS C:\Users\Trinh Nguyen\projects\mycontainer> docker build . -t yourimage_uri:yourtag
4. Run your containerized application from Powershell
PS C:\Users\Trinh Nguyen\projects\mycontainer> docker run -p 8080:8080 yourimage_uri:yourtag
5. You can find the Dockerfile and supplementary files in .
Post a Comment