Showing posts from April, 2021

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 [1]. 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/ WORKDIR /Fonts/ RUN @powershell -NoProfile -ExecutionPolicy Bypass -Command ".\Add-Font.ps1 Fonts" Enable Web-WebSockets feature using Powershell RUN @powershell -NoProfile -ExecutionPolicy Bypass -Command "Add-WindowsFeature Web-WebSockets" Install chocolatey to install openjdk8, and googlechrome RUN @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString(''))" && SET "PATH=%

Build and run Windows container

Running Windows container... wait what? Windows??? WTF? Okay, take it easy genius! It gonna be alright! Microsoft has been working closely with Docker to add containerized applications for its OS platform. And, it's working nicely even though at first you will feel the pain in the ass. There are a couple of things you need to take into account working with Windows container First of all, you have to use a Windows machine to build and run Windows containers. Containers are using the underlying Operating System resources and drivers, so Windows containers can run on Windows only (Linux containers can run on Windows with WSL enabled). If you're using Docker Desktop on Windows 10, you have to use it with Windows Container enabled. There will be no GUI Windows environment (servercore or nanoserver) [1]. Of course, it's containers! There will be no "latest" tag for your Windows base docker image. Powershell is the King [2]. Just like any Linux container, you have to use