Selenium is an open-source framework system for building the web user interface(UI) tests that can execute on Chrome, Edge, Firefox, and IE. When performing Selenium automation testing, it is essential to test a run in one execution runtime environment. These execution tests can also run in a multi-test run in a single performance environment. We should avoid running the automation tests in an isolation environment.

Selenium Tests in Docker 

Running Selenium tests in Docker containers supports executing code reviews at a more agile speed with the more conventional quality code, archives high test coverage, and generates an excellent quality product with the great quality standard code. 

Docker gives the versatility to perform tests with containers or divide the tests in development and deployment. There are many reasons to practice Selenium with Docker for web-based application testing. In this article, we will deep dive into how to execute Selenium tests in Docker to stimulate the Selenium test automation activity.

We can run the Selenium using these below environments.

  • Python, bound using Selenium WebDriver.
  • PyTest is a testing structure. Here we can use its framework structures per the user preference, like Nose or Junit). 
  • GeckoDriver (Firefox) or, ChromeDriver,  Headless Chrome
  • IntelliJ IDEA as IDE (Integrated development environment)
  • CI tool, like Jenkins or TeamCity. Add the plugins as per the user’s requirement, for example, GitHub repository connection, BlazeMeter for performance testing, Allure for reporting, etc.

Learn the Ins & Outs of Software Development

Caltech Coding BootcampExplore Program
Learn the Ins & Outs of Software Development

Why Should We Run Selenium Tests in Docker?

  • Scalable and Reliable: One of the most important advantages of Docker is its capability to scale. It’s vital because operating a Selenium grid on virtual machines and separate devices takes up additional computing expenses. Docker images take part in some custom resources. Using this, we can quickly review various nodes in a separate instance. Docker and Compose also manage the networking part efficiently.
  • Selenium supports you in running your tests locally, and you can easily configure your Windows manager. As expected, protecting the tests with Docker will allow you to migrate them to a distinctive workspace easily.
  • SeleniumHQ manages the entire range of Docker images. These images can be extracted down quickly and applied right away. We can find the catalog of images at Docker Hub or GitHub repository as per the below standards.
  1. Base - Here, we can develop our custom images.
  2. Hub - This is cloud-based registry assistance. Here we can connect to code repositories and design images, test, and collect.
  3. Node - Images practiced in correlation with Hub image and global Selenium grid. It is a workable solution to begin several node containers using a Hub image.
  4. Standalone - We can find Standalone images on the Selenium server. These images should be run on different ports (e.g., 4444, 4445, etc.) else it will result in port conflicts. Here we no need to maintain the Selenium server jar as it is automatically controlled using the Selenium hub container.
  • It provides the downloading of browser drivers and setting the classpaths.
  • You can designate and maintain the Selenium Grid, and it is simple to record nodes on the hub.
  • The differences between the environments are low, and multiple team members can practice identical containers, unlike the operating system.
  • Less burden of installations.

Run Selenium Standalone Chrome Docker Image Locally

ChromeDriver: ChromeDriver 2.32 works with Chrome 61 and performs well with headless Chrome.


npm i --save-dev selenium-webdriver chromedriver

Example 1:

const fst = require('fst');

const webdriver1 = require('selenium-webdriver1 );

const chromedriver = require('chromedriver');

const chromeCapabilities =;

chromeCapabilities.set('chromeOptions', {args: ['--headless']});

const driver = new webdriver1.Builder()




// For Navigating, please enter a search.


driver.findElement({name: 'q'}).sendKeys(webdriver1);

driver.findElement({name: 'btnG'}).click();

driver.wait(webdriver1.until.titleIs(webdriver1 - Google Search'), 1000);

// Take a screenshot of the results page. Save to disk.

driver.takeScreenshot().then(base64png => {

  fst.writeFileSync('screenshot.png', new Buffer(base64png, 'base64'));



WebDriverIO is a critical level API on the top standard of Selenium WebDriver.


npm i --save-dev webdriverio chromedriver

Example 2:

filter CSS characteristics on

const webdriverio = require('webdriverio');

const chromedriver = require('chromedriver');

const PORT = 9515;






(async () => {

const opts = {

  port: PORT,

  desiredCapabilities: {

    browserName: 'chrome',

    chromeOptions: {args: ['--headless']}



const browser = webdriverio.remote(opts).init();

await browser.url('');

const title = await browser.getTitle();

console.log(`Title: ${title}`);

await browser.waitForText('.num-features', 3000);

let numFeatures = await browser.getText('.num-features');

console.log(`Chrome has ${numFeatures} total features`);

await browser.setValue('input[type="search"]', 'CSS');

console.log('Filtering features...');

await browser.pause(1000);

numFeatures = await browser.getText('.num-features');

console.log(`Chrome has ${numFeatures} CSS features`);

const buffer = await browser.saveScreenshot('screenshot.png');

console.log('Saved screenshot...');




Here's How to Land a Top Software Developer Job

Full Stack Developer - MERN StackExplore Program
Here's How to Land a Top Software Developer Job

Run Selenium Tests on Docker

We can execute Selenium on the standalone or single container and a Grid of many containers.

  • Configure a Selenium Grid using Docker Compose: For instance, Zalenium is extensively utilized in this section as it implements a manageable and scalable container-based Selenium Grid, including video recording, live show, primary authentication, and dashboard.
  • We can configure Selenium Grid using Kubernetes. We can get the detailed documentation in Run Selenium UI tests using Docker containers.

Run Selenium Tests on Firefox Inside the Docker Container

For running the Selenium tests on Firefox inside the Docker container, use the below command:

docker pull selenium/standalone-firefox



We can download the container image for the particular version from the navigation to Docker Hub and can locate the particular image. For instance, the command docker will pull using selenium/standalone-chrome:87.0 and can download version 87.0 of Chrome as shown below.


After downloading the images, run the command docker images to check if the downloading was performed successfully. As shown below, we have the newest versions of Chrome and Firefox containers available for usage.



We hope this article helped you understand Selenium Docker. In this article, we discussed the concept of various repositories and selenium running the automated test cases using Google and Firefox browsers, along with examples that will be helpful to professional developers from Java and .net backgrounds, application architectures, cloud specialists, testers, and other learners looking to learn more about performing tests using the Selenium framework.

Besides pursuing varied courses provided by Simplilearn, you can also sign up on our SkillUp platform. This platform, a Simplilearn initiative, offers numerous free online courses to help with the basics of multiple programming languages, including cloud docker hub. You can also opt for our Post Graduate Program in Full Stack Web Development to improve your career prospects.

Our Software Development Courses Duration And Fees

Software Development Course typically range from a few weeks to several months, with fees varying based on program and institution.

Program NameDurationFees
Caltech Coding Bootcamp

Cohort Starts: 15 Apr, 2024

6 Months$ 8,000
Automation Test Engineer

Cohort Starts: 17 Apr, 2024

11 Months$ 1,499
Full Stack Developer - MERN Stack

Cohort Starts: 24 Apr, 2024

6 Months$ 1,449
Full Stack Java Developer

Cohort Starts: 14 May, 2024

6 Months$ 1,449