This guide demonstrates how to set up a Dockerized environment for automating mobile app tests using Robot Framework and Appium. This approach streamlines test execution, ensures environment consistency, and eliminates the need for local tool installations.
- Appium Server container
- Robot Framework container
- Physical Mobile device
- Appium Inspector
- (optional) Scrcpy
- (optional) Visual Code with Dev Containers Extension
- Ensure Docker is installed and configured
- Ensure ADB is installed
- Device with developer mode active and USB Debugging enabled
Optional
- Enable device's Wireless Debugging
- Install Scrcpy
-
Open the terminal and navigate to your project directory
cd path/to/project
-
Connect the device via USB to your computer
Approve the connection on your device
-
(optional) Mirror the mobile device screen
# Check if device is connected (attached) adb devices # Restart the adb server in tcpip mode on port 5555 adb tcpip 5555 # Mirror the device via wifi (enter the ip of your device) scrcpy --tcpip=192.168.15.59:5555
-
Run appium server container and Robot container
# (First time) Build services docker compose build docker compose up -d # outputs # [+] Running 2/2 # ✔ Container appium Started # ✔ Container robot Started
-
Check if the device is connected to the Appium Server
# Executes "adb devices" commando inside appium docker docker exec appium adb devices
Or if you follow step 6:
# Kill adb server on your machine to disconnect the device adb kill-server # Check if the device is connected to the appium server docker exec appium adb devices # Mirror the device screen scrcpy --tcpip=192.168.15.59:5555
-
(Optional) Attach VS Code to the Robot container With the Dev Container extension, you can open any folder or repository inside a Docker container and take advantage of Visual Studio Code's full feature set.
-
Eventually you will ned to stop containers
docker compose down
Within the docker network, you can use the name of the container as an alias for the IP address.
Open Application
... remote_url=http://appium:4723
... platformName=Android
... automationName=UiAutomator2
Outside the docker network, you must provide the IP address. This is how you can identifying the IP address assigned to a container
docker inspect appium | grep IPAddress
# Result
# "SecondaryIPAddresses": null,
# "IPAddress": "",
# "IPAddress": "172.23.0.3",
-
Fill in the following data:
- Remote Host: The IP address of the Appium container
- Remote Port: 4723
- Capacility Builder
- platformName: Android
- automationName: UiAutomator2
-
Click the Start Session button
Eventually, you will need the package name of the tested app, you can achieve this using following commands:
# Enter the Appium container.
docker exec -it appium bash
# Connect to the Android device shell.
adb shell
# Get the package name of the app in focus.
dumpsys window | grep mCurrentFocus
This is a basic example. Customize it for your specific testing requirements.
Check these links for more information
- ADB official documentation
- Appium official documentation
- Appium Docker Image github repository
- Appium Inspector github repository
- Docker installation official documentation
- Robot Framework official documentation
- Robot Docker Image github repository
- Scrcpy github repository