Executing Selenium Scripts Using Docker Container

Modified on Thu, 4 Jul at 12:44 PM

TABLE OF CONTENTS

1. Overview

2. Installing Docker

3. Executing Selenium Scripts on Windows

3.1 Setting the Browser Type in the Application Settings File

3.2 Adding the Docker files into the algoQA script generated folder

3.3 Running the Container

1. Overview

Docker is an open source platform that helps you in developing, shipping and running applications. Docker allows you to package and run applications in a loosely isolated environment known as a container.


When working with Docker, you create and use images, containers, and various other components.
A container is an operational instance of an image that can be executed. For more information, refer to Docker Overview document.


2. Installing Docker

To install Docker Desktop  installer for windows, click here.


3. Executing Selenium Scripts on Windows

3.1 Setting the Browser Type in the Application Settings File

Perform the following:

  1. After generating the script, download it to your local folder. This folder must contain the script file that you have generated.

  2. Open the folder where you downloaded the script. For example, if your script is located at AlgoAFScript_202402121131\src\test\java, navigate to this folder. Applications.xml file will be available in the Java folder as shown:

  3. Open the Application Settings file and locate the setting related to the Browser Type. Set this setting to Headless Chrome to run the script in the headless mode, as shown: 


3.2 Adding the Docker files into the algoQA Script Generated Folder

Perform the following:

  1. Download the attached Docker file which creates an environment in a Docker container for running Maven tests using Cucumber. This Docker file creates an image and adds the required files and helps in running the container.

  2. Navigate to the Downloads folder > open the Docker file and save the Docker file into same folder where your script is generated, as shown:

3.3 Running the Container

To the run the container, you need to first build the Docker image and then execute the Docker image.

Perform the following:

  1. To build the docker image, run the following command in the command prompt:
    docker build -t <name>. Replace name with actual name (for example, test1). This command builds an image, as shown: 
    
  2. To verify if the image has been created successfully, run the following command in the command prompt:
    1. Docker images
    2. The following screenshot represents the docker image created, as shown:
      
      

  3. To execute the docker image, run the following command in the command prompt:
    docker run <image name>. Replace image name with the actual name (for example, test1, as shown). This command executes the Docker image and downloads all the necessary dependencies'.
    
    
    











Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article