Testing your website in a Continuous deployment environment by hand is the definition of insanity. If you are testing your website by hand, it will drive you insane quickly, if it has not already. Website testing is necessary to build and maintain quality websites, but many consider it to be an unglamorous task.
Clicking through every possible pathway by hand becomes untenable except for the smallest web apps. Luckily, there are tools that can automate these repetitive steps of testing. There are many tools for testing, but I want to focus on the Selenium family of testing tools. Specifically, Selenium 3 which is the latest version of the Selenium automated testing tool.
Selenium 3 is a Java-based application, and installing it comes with all the things that come with installing as Java application. When you install Selenium 3 on a server you have to install a Java runtime, Selenium Java , browser and anything other dependencies. Installing everything will take time, but there is a quicker way to install Selenium 3.
The quickest way to get Selenium 3 up and running is with Docker compose. If you have a fast internet connection, these steps take a few minutes. We have three part to this solution, Selenium 3 itself , Docker and finally Docker Compose to manage and run the app.
Docker is an application that automates the deployment of Linux applications by placing them inside software containers. A Docker container wraps your app with a complete filesystem and everything else it needs to run.
The Docker website contains much more information that I can go into in this article. If you are not familiar with Docker and Docker compose, you should take a moment and read about it here https://www.docker.com/.
Installing Docker and Docker Compose is straightforward on most modern versions of Linux.
Docker images are self-contained images of a filesystem with everything installed. What we need a docker image that contains Selenium and all the supporting files. Seleniumhq provides such pre-built images for hub nodes, worker nodes, and standalone versions.
Selenium is a software testing framework that works by automating browsers in order to test web applications. Selenium also has an IDE (Selenium IDE ) that lets you record and playback testing sessions to author tests without writing out your tests in a test scripting language.
“Selenium Grid” is a setup which provides a hub which allowing the running of multiple Selenium tests concurrently on any number of nodes. In this example, we are going to run a two node “Selenium Grid”, a hub and a single node.
What Seleniumhq.org has done is build Docker images that anyone can use. There are Docker images to test with Firefox and Chrome browsers , a standalone version Selenium 3 of as well as a Selenium hub. Docker Compose will automatically download the latest version of whatever pre-built image we specify in our compose file.
Docker Compose is the tool that will pull everything together. It is a tool for defining and running multi-container Docker applications. You define the services that make up your app in a file usually named docker-compose.yml
Docker compose uses that file to create and start all the services defined. In the following docker compose file, we define how our two Selenium 3 containers, a hub, and worker node, will interact and work together.
Now that we have all the pieces together, starting our Selinium 3 grid is a matter of running a single docker-compose command.
docker-compose up -d
Docker Compose will download the latest images, configure, and start them running. This may take a few minutes while everything is built for the first time.
Navigate to http://<ipaddress>:4444/grid/console in your web browser, replacing <ipaddress> with the address of the machine that is running the grid. If you are running on your local machine, you can use 127.0.0.1. You should see the Selenium Grid console which should look like this for a hub with a single node.
Was this post interesting? If so, please click the ❤ below to let me know , it really does help. Greg Coleman is a freelance devop based in Annapolis, Maryland that is planning a trip to an undisclosed location somewhere in the South East Asia looking for the perfect Unagi roll. You can contact me here https://gregorycoleman.github.io