Executing Selenium Scripts Using Docker
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.
Executing Selenium Scripts Using Docker 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.
Installing Docker
To install Docker Desktop installer for windows, click here.
Executing Selenium Scripts on Windows
Setting the Browser Type in the Application Settings File
Perform the following:
- After generating the script, download it to your local folder. This folder must contain the script file that you have generated.
- 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.

- 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.
You can run scripts in incognito mode in chrome and firefox, to run scripts in incognito mode in edge, please add webdriver path in application settings

Adding the Docker files into the algoQA Script Generated Folder
Perform the following:
- 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.
- Navigate to the Downloads folder > open the Docker file and save the Docker file into same folder where your script is generated.

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:
- To build the docker image, run the following command in the command prompt:
Replace name with actual name (for example, test1). This command builds an image.
docker build -t <name>
- To verify if the image has been created successfully, run the following command in the command prompt:
- To execute the docker image, run the following command in the command prompt:
Replace image name with the actual name (for example, test1, as shown). This command executes the Docker image and downloads all the necessary dependencies'.
docker run <image name>
Attachment
Dockerfile .txt
TXT, 144 Bytes