Using Docker for Automation Testing

What is Docker?

What are images and containers in docker?

How to install Docker

  1. Go on Docker Docs
  2. Check if your system supports Docker by going through the hardware prerequisites.
  1. Download and install Docker
  2. Once installed you will see the icon on your system, click on the icon and it will appear in your task manager.
  1. To confirm, run $docker — version in command prompt.

Exploring DockerHub

  • Repositories: Push and pull container images.
  • Teams & Organizations: Manage access to private repositories of container images.
  • Official Images: Pull and use high-quality container images provided by Docker.
  • Publisher Images: Pull and use high- quality container images provided by external vendors.
  • Builds: Automatically build container images from GitHub and Bitbucket and push them to Docker Hub.
  • Webhooks: Trigger actions after a successful push to a repository to integrate DockerHub with other services.

How to set up Docker Container for running automation Tests

Step 1: Getting Selenium images

Step 2: Download image into our machine

Step 3: Deploy image to the container

Explanation

  • docker run: starts a new container in machine
  • -d: runs the container in background
  • -p 4444:4444: running port for test cases in local : container port
    Essentially, it redirects all the test case runs to the container
  • -v /dev/shm:/dev/shm: to use hosts shared memory
  • selenium/standalone-chrome: image name
  • latest: image version

Step 4: Stop the container

Docker + Selenium (testNG)

Docker + Selenium Grid

How to create a hub and node — Docker compose file?

Conclusion

  • Run test cases on your systems if you don’t have the architecture you need
  • Run automation test cases parallely on various browsers
  • Eliminate the need to manage jars and downloading
  • Run tests at a scale due to its ease and flexibility

Engati

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store