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:5900Please 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 firefoxConnect to Firefox via VNC:
open vnc://user:secret@localhost:5901To run the tests with Safari on MacOS, follow these steps:
-
Download and install MJPEG Server as
mjpeg-serverin yourPATHand install FFmpeg via Homebrew:brew install ffmpeg
-
Add the
examplehost to your/etc/hostsfile:printf '127.0.0.1\t%s\n' example | sudo tee -a /etc/hosts
-
Start
safaridriverandmjpeg-serverwith 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
examplehost to your/etc/hostsfile:printf '127.0.0.1\t%s\n' example | sudo tee -a /etc/hosts
-
Start
appiumwith 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
ORIENTATIONenvironment variable:ORIENTATION=LANDSCAPE docker-compose run --rm wdio mobile-safari
To use a different iOS device than defined in the config, provide the
DEVICE_NAMEenvironment variable:DEVICE_NAME='iPad Air' docker-compose run --rm wdio mobile-safariTo use a different iOS version than defined in the config, provide the
PLATFORM_VERSIONenvironment 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
~/.profileto 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
appiumwith a Chromedriver version compatible with the version of Chrome running in your Android device. Ifappiumhas already been installed with an incompatiblechromedriverversion, you might want to uninstall and reinstall it with the proper--chromedriver_versionargument. -
Start
appiumwith the provided helper script:bin/appium.sh
-
Start the Android Virtual Device with a custom
/etc/hostsfile: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
ORIENTATIONenvironment 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
Zoomlevel is set to100%so that the native mouse events can be set to the correct coordinates. -
Create a
.envfile 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>
Make sure that the
DOCKER_HOST_IPis accessible from the Windows machine and theWINDOWS_HOST_IPis accessible from a Docker container (see also the FAQ). -
Edit the
examplehost entry in etc/windows.hosts and set its IP address to theSERVER_HOSTIP defined in the.envfile. -
Copy bin/webdriver.ps1 and etc/windows.hosts to the same folder in the Windows machine (e.g. the Desktop).
-
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 theTargetproperty to the following value:powershell -ExecutionPolicy ByPass -File webdriver.ps1Click "OK" to save the changes to the shortcut.
-
Double-Click on the webdriver shortcut to setup and start the servers.
AllownginxandMJPEGServerto 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
.envfile 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>
Make sure that the
DOCKER_HOST_IPis accessible from the Windows machine and theWINDOWS_HOST_IPis accessible from a Docker container (see also the FAQ). -
Edit the
examplehost entry in etc/windows.hosts and set its IP address to theSERVER_HOSTIP defined in the.envfile. -
Copy bin/webdriver.ps1 and etc/windows.hosts to the same folder in the Windows machine (e.g. the Desktop).
-
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 theTargetproperty to the following value:powershell -ExecutionPolicy ByPass -File webdriver.ps1Click "OK" to save the changes to the shortcut.
-
Double-Click on the webdriver shortcut to setup and start the servers.
AllownginxandMJPEGServerto 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 downReleased under the MIT license.