1. Preparing the test environment
For the automated check to succeed we need to create the following situation:
-
The
database
container is running and has data -
webserver
is able to connect to thedatabase
-
Selenium grid is running
-
The Java environment to execute the tests will be provided by a Docker container too
2. Starting the selenium server
Assuming you have the database
and webserver
containers running, start the Selenium server by executing:
docker run --rm --name selenium -d --network training -p 4444:4444 -p 5900:5900 selenium/standalone-firefox-debug
3. Connect with VNC
In order to monitor test progress we can connect with VNC viewer to the Selenium node after we’ve started it.
The VNC server is listening on port 5900, the password is secret
.
4. Adjust SimpleTest
We’ve prepared a simple Java project to test whether the webserver
displays the correct message.
Adjust the message you added to the database in the SimpleTest.java file. This file can be found inside the selenium-grid-docker directory.
5. Execute your test
We will use the official Maven image (maven:3.3.9-jdk-8-alpine
) to build and execute our test.
This image provides a Java environment and Maven (a Java build tool) to execute the project. In order to make the project files, which are on your local machine, available to the container we will mount the selenium-grid-docker
directory as a volume for the container.
docker run -it --rm --name my-maven-project --network training -v "$PWD":/usr/src/mymaven -w /usr/src/mymaven maven:3.3.9-jdk-8-alpine mvn clean install
Make sure that your command prompt is in the selenium-grid-docker directory.
|
5.1. Additional Windows/Docker toolbox details
On Windows/GIT Bash/Cygwin you may get the following error the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty' .
Run the command again with winpty in front of it. Refer to this page for details.
|
Before we can mount a volume on Windows when using Docker Machine we need to make a shared folder in Virtual Box first. See step 3 of this page. |
6. Considerations
What are the implications of the `-v` flag in the command?