Abstract: Learn how to set up Selenium Grid using Appium and Docker to run tests in parallel on multiple machines.
2024-05-30 by DevCodeF1 Editors
Setting up Selenium Grid and Appium with Docker for Local Machine
In this article, we will discuss how to set up Selenium Grid 4 and Appium with Docker on a local machine. This setup is useful for running automated tests on different platforms and devices. We will cover the key concepts and provide detailed instructions for setting up Selenium Grid and Appium with Docker.
What is Selenium Grid?
Selenium Grid is a tool that allows running automated tests on different machines and browsers. It enables running tests in parallel, reducing the overall time required for testing. Selenium Grid can be used with different programming languages and testing frameworks.
What is Appium?
Appium is an open-source tool for automating native, mobile web, and hybrid applications on iOS and Android platforms. It uses the WebDriver protocol to drive the automation of mobile applications, making it easy to write tests in different programming languages.
What is Docker?
Docker is a platform for developing, shipping, and running applications using containers. Containers are lightweight, portable, and self-contained units that include all the dependencies required to run an application. Docker makes it easy to set up and manage the infrastructure required for running automated tests.
Setting up Selenium Grid and Appium with Docker
To set up Selenium Grid and Appium with Docker, we need to perform the following steps:
- Install Docker on the local machine.
- Create a Docker image for Selenium Grid and Appium.
- Run the Docker containers for Selenium Grid and Appium.
- Configure the Selenium Grid and Appium to work together.
Step 1: Install Docker
To install Docker on the local machine, follow the instructions provided in the official Docker documentation.
Step 2: Create a Docker Image
To create a Docker image for Selenium Grid and Appium, we need to create a Dockerfile. The Dockerfile contains the instructions for building the Docker image. Here is an example of a Dockerfile for Selenium Grid and Appium:
FROM selenium/standalone-chrome:4.0.0-alpha-1-20220301RUN apk add --no-cache curl && \ curl -o appium.tar.gz https://github.com/appium/appium-docker/releases/download/v1.22.3/appium-docker-linux-x64.tar.gz && \ tar -xzf appium.tar.gz -C /usr/local/bin && \ rm appium.tar.gzEXPOSE 4444 4723CMD ["appium", "--relaxed-security", "--command-timeout", "3600"]
This Dockerfile uses the official Selenium Grid Docker image as the base image. It installs Appium and exposes the required ports for Selenium Grid and Appium. The command "CMD" specifies the command to run when the Docker container is started.
Step 3: Run the Docker Containers
To run the Docker containers for Selenium Grid and Appium, we need to use the following commands:
docker run -d --name selenium-grid -p 4444:4444 -p 5555:5555 selenium/standalone-chrome:4.0.0-alpha-1-20220301docker run -d --name appium -p 4723:4723 --link selenium-grid:hub my-selenium-grid-appium
The first command runs the Selenium Grid container. The "-d" option specifies that the container should run in the background. The "--name" option specifies the name of the container. The "-p" option maps the ports required for Selenium Grid. The second command runs the Appium container. The "--link" option specifies the name of the Selenium Grid container.
Step 4: Configure Selenium Grid and Appium
To configure Selenium Grid and Appium, we need to perform the following steps:
- Start the Selenium Grid and Appium containers.
- Access the Selenium Grid console using the URL http://localhost:4444/grid/console.
- Create a new node for Appium using the following command:
docker exec -it selenium-grid java -cp /opt/selenium/selenium-server.jar:/opt/selenium/lib/*:/opt/appium/node_modules/appium/build/lib/main.js org.openqa.grid.selenium.GridLauncherV3 \ -role node \ -nodeConfig /opt/appium/node_config.json \ -hub http://selenium-grid:4444/grid/register
This command creates a new node for Appium using the node configuration file "/opt/appium/node_config.json". The node configuration file specifies the capabilities required for running the automated tests.
In this article, we have discussed how to set up Selenium Grid and Appium with Docker on a local machine. We have covered the key concepts and provided detailed instructions for setting up Selenium Grid and Appium with Docker. We have also provided a sample Dockerfile for creating a Docker image for Selenium Grid and Appium.
References
Discover the steps to create a Docker container with Selenium Grid and Appium server, enabling you to execute tests on multiple emulators or real devices.
Creating an Interface for EPUB Uploads in Django: Checkbox for XHTML Contents Processing
This article explains how to create a Django interface for EPUB file uploads with an optional checkbox for XHTML contents processing.
Modifying Specific Plotly Traces in R Shiny using plotlyProxy
In this article, we will explore how to modify specific Plotly traces in R Shiny applications using the plotlyProxy function.
Temporary Error 403 Access Denied in AWS CloudFront with S3: A Solution for Hosting React Apps
Learn how to resolve the 403 Access Denied error when hosting a React app on AWS CloudFront with an S3 bucket.
Counting Business Days Between Two Dates in AnyLogic
Learn how to count business days between two dates in AnyLogic using the differenceInCalendarUnits() function with proper filtering.