- Use a standard docker container to execute selenium tests
- Easier to setup and recreate ... even easy to recreate the container for every test run which provides better repeatable test results
- Overhead to have many containers for each browser in minimal.
This documentation only applies to Magnolia 5.5.9 and below.
Execute UI Test using the standard selenium docker container
Prerequisites
- Docker
Run selenium server for firefox
$ docker run -d -p 4444:4444 -e SCREEN_WIDTH=1280 -e SCREEN_HEIGHT=1024 -e SCREEN_DEPTH=24 selenium/standalone-firefox:2.53.1-beryllium
Execute all UI tests
$ cd magnolia-bundle $ mvn clean install -Pui-tests,jetty9-standalone -DseleniumServerHostName=localhost -DcontainerHostName=192.168.10.40
Replace the containerHostName
with an IP or name which is accessible from the container (by default the container uses the same DNS as the host system)
Debug
To debug the container provides the option to connect via a VNC. macOS has already a good VNC Client (Screen Sharing) you can use monitor the test execution.
$ docker run -d -p 4444:4444 -p 5901:5900 -e no_proxy=localhost -e SCREEN_WIDTH=1280 -e SCREEN_HEIGHT=1024 -e SCREEN_DEPTH=24 selenium/standalone-firefox-debug:2.53.1-beryllium
Open Safari and enter
vnc://localhost:5901
The password is "secret"
The Grid
The standard selenium docker containers provide an easy to setup selenium grid. The selenium grid consists of multiple nodes with same or different browser setups which are all hidden behind a hub. This means for test executions nothing changes but the selenium server is able to provide multiple sessions with different capabilities.
Start up the HUB
$ docker run -d -p 4444:4444 --name selenium-hub selenium/hub:2.53.1-beryllium
Start up and register the nodes
$ docker run -d -e SCREEN_WIDTH=1280 -e SCREEN_HEIGHT=1024 -e SCREEN_DEPTH=24 --link selenium-hub:hub selenium/node-firefox:2.53.1-beryllium
If you want to debug, you have to use the -debug image for the nodes and map the VNC ports.
Execute UI tests in parallel
By default the selenium test are executed in sequence. We have to explicitly configure maven/surefire to execute our tests in parallel.
$ cd magnolia-bundle $ mvn clean install -Pui-tests,jetty9-standalone -DseleniumServerHostName=localhost -DcontainerHostName=192.168.10.40 -Dparallel=classes -DreuseForks=false -DforkCount=4
As the tests still operate on the same magnolia instance it might be a good idea to not execute test methods of the same class in parallel.
Monitor the grid
$ open http://localhost:4444/