Docker setup for WebdriverIO with automatic screenshots, image diffing and screen recording support for containerized versions of Chrome and Firefox, Safari Mobile and Chrome Mobile via Appium and Safari on MacOS as well as Internet Explorer and Microsoft Edge on Windows 10.
Run the tests with Chrome:
docker-compose run --rm wdio [chrome]
Connect to Chrome via VNC:
open vnc://user:secret@localhost:5900
Please Note:
To be able to see Chrome running via VNC or screen recordings, disable headless
mode in chrome.js.
Run the tests with Firefox:
docker-compose run --rm wdio firefox
Connect to Firefox via VNC:
open vnc://user:secret@localhost:5901
To run the tests with Safari on MacOS, follow these steps:
-
Download and install MJPEG Server as
mjpeg-server
in yourPATH
and install FFmpeg via Homebrew:brew install ffmpeg
-
Add the
example
host to your/etc/hosts
file:printf '127.0.0.1\t%s\n' example | sudo tee -a /etc/hosts
-
Start
safaridriver
andmjpeg-server
with the provided helper script:bin/safaridriver.sh [screen index]
-
Run the tests with Safari:
docker-compose run --rm wdio safari
To run the tests with Mobile Safari on iOS Simulator, follow these steps:
-
Install Xcode from the Mac App Store.
-
Install the Xcode Command Line Tools:
xcode-select --install
-
Install Node.JS and Carthage via Homebrew:
brew install node carthage
-
Make sure the necessary Appium dependencies for iOS testing are installed:
npx appium-doctor --ios
-
Install Appium as global NPM package:
npm install -g appium
-
Add the
example
host to your/etc/hosts
file:printf '127.0.0.1\t%s\n' example | sudo tee -a /etc/hosts
-
Start
appium
with the provided helper script:bin/appium.sh
-
Run the tests with Mobile Safari:
docker-compose run --rm wdio mobile-safari
To run the tests in landscape orientation, provide the
ORIENTATION
environment variable:ORIENTATION=LANDSCAPE docker-compose run --rm wdio mobile-safari
To use a different iOS device than defined in the config, provide the
DEVICE_NAME
environment variable:DEVICE_NAME='iPad Air' docker-compose run --rm wdio mobile-safari
To use a different iOS version than defined in the config, provide the
PLATFORM_VERSION
environment variable:PLATFORM_VERSION=12.1 docker-compose run --rm wdio mobile-safari
To run the tests with Mobile Chrome on Android Simulator, follow these steps:
-
Download Android Studio and on first start, follow the instructions to install the Android SDK and Emulator.
-
Add the following lines to your
~/.profile
to make the JDK included in Android Studio and the installed Android SDK available to Appium:export JAVA_HOME='/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home' export PATH="$JAVA_HOME/bin:$PATH" export ANDROID_HOME=~/Library/Android/sdk
-
brew install node
-
Make sure the necessary Appium dependencies for Android testing are installed:
npx appium-doctor --android
-
Install Appium as global NPM package:
npm install -g appium [--chromedriver_version=VERSION]
Make sure to configure
appium
with a Chromedriver version compatible with the version of Chrome running in your Android device. Ifappium
has already been installed with an incompatiblechromedriver
version, you might want to uninstall and reinstall it with the proper--chromedriver_version
argument. -
Start
appium
with the provided helper script:bin/appium.sh
-
Start the Android Virtual Device with a custom
/etc/hosts
file:bin/android-emulator.sh -hosts etc/android.hosts
-
Run the tests with Mobile Chrome:
docker-compose run --rm wdio mobile-chrome
To run the tests in landscape orientation, provide the
ORIENTATION
environment variable:ORIENTATION=LANDSCAPE docker-compose run --rm wdio mobile-chrome
Please Note:
This guide assumes that a system with Windows 10 has been set up, e.g. using the
"MSEdge on Win10" virtual machine image (which also includes Internet Explorer)
from
Microsoft's Free VMs
site.
To run the tests with Internet Explorer, follow these steps:
-
Set "Change the size of text, apps, and other items" to 100% in Windows Display Settings.
If the option is grayed out, make sure the graphics configuration allows changing the scaling setting (see e.g. Parallels article #123951). -
Make sure the Internet Explorer
Zoom
level is set to100%
so that the native mouse events can be set to the correct coordinates. -
Create a
.env
file in the same directory as docker-compose.yml and add the following environment variables:SERVER_HOST=<DOCKER_HOST_IP> SERVER_PORT=8080 WINDOWS_HOST=<WINDOWS_HOST_IP> WINDOWS_ASSETS_DIR=C:\Users\<USERNAME>\Desktop\assets\
Make sure that the
DOCKER_HOST_IP
is accessible from the Windows machine and theWINDOWS_HOST_IP
is accessible from a Docker container (see also the FAQ).
Also make sure thatWINDOWS_ASSETS_DIR
points to a valid folder path and ends with a backslash. -
Edit the
example
host entry in etc/windows.hosts and set its IP address to theSERVER_HOST
IP defined in the.env
file. -
Copy bin/webdriver.ps1 and etc/windows.hosts to the same folder in the Windows machine (e.g. the Desktop).
Also copy the files in theassets
directory to the folder defined asWINDOWS_ASSETS_DIR
. -
Create a shortcut to
webdriver.ps1
(via "Right-Click" → "Create shortcut"), then open the properties dialog for the shortcut (via "Right-Click" → "Properties") and set theTarget
property to the following value:powershell -ExecutionPolicy ByPass -File webdriver.ps1
Click "OK" to save the changes to the shortcut.
-
Double-Click on the webdriver shortcut to setup and start the servers.
Allownginx
andMJPEGServer
to communicate on all networks in the Windows Defender Firewall dialog. -
Run the tests with Internet Explorer:
docker-compose run --rm wdio ie
Please Note:
This guide assumes that a system with Windows 10 has been set up.
The scripted installation of
MicrosoftWebDriver
also requires 17763
as minimum Windows build version.
To run the tests with Microsoft Edge, follow these steps:
-
Create a
.env
file in the same directory as docker-compose.yml and add the following environment variables:SERVER_HOST=<DOCKER_HOST_IP> SERVER_PORT=8080 WINDOWS_HOST=<WINDOWS_HOST_IP> WINDOWS_ASSETS_DIR=C:\Users\<USERNAME>\Desktop\assets\
Make sure that the
DOCKER_HOST_IP
is accessible from the Windows machine and theWINDOWS_HOST_IP
is accessible from a Docker container (see also the FAQ).
Also make sure thatWINDOWS_ASSETS_DIR
points to a valid folder path and ends with a backslash. -
Edit the
example
host entry in etc/windows.hosts and set its IP address to theSERVER_HOST
IP defined in the.env
file. -
Copy bin/webdriver.ps1 and etc/windows.hosts to the same folder in the Windows machine (e.g. the Desktop).
Also copy the files in theassets
directory to the folder defined asWINDOWS_ASSETS_DIR
. -
Create a shortcut to
webdriver.ps1
(via "Right-Click" → "Create shortcut"), then open the properties dialog for the shortcut (via "Right-Click" → "Properties") and set theTarget
property to the following value:powershell -ExecutionPolicy ByPass -File webdriver.ps1
Click "OK" to save the changes to the shortcut.
-
Double-Click on the webdriver shortcut to setup and start the servers.
Allownginx
andMJPEGServer
to communicate on all networks in the Windows Defender Firewall dialog. -
Run the tests with Microsoft Edge:
docker-compose run --rm wdio edge
Stop and remove the container set:
docker-compose down
Released under the MIT license.