Last April, Genymotion team went to the Appium Conference in London and met Budi, open-source enthousiast, contributor to the Appium project on Github who did a talk on his Docker-Android project. We started working together on an integration of Genymotion Cloud.
In this article, we’ll explain what are the main advantages of using Docker-android with Genymotion Cloud to run Android mobile automated tests, then we will provide tutorials.
Genymotion Cloud hosts cloud-based Android emulators running in a SaaS fashion or as virtual images on AWS, GCP or Alibaba Cloud (PaaS). The integration so far has been done with SaaS & PaaS (only AWS).
Docker-Android is a docker image built to be used for everything related to Android mobile website or application testing. All the tools needed (devices, framework, Android SDK…) are packaged in the image. It is free and open source and supports other features such as video recording.
The main goal is to help the user focus on writing the UI tests by leveraging the advantages of using a docker :
- Having a ready to test infrastructure that will run the same environment everywhere it is deployed (your local machine, server) : You get rid of all the hassle of installing the tools needed (Appium, Selenium Grid, AWS CLIs, Android SDK, Genymotion tools…) but also maintaining them. For example if you update the version of one tool it could break the integration.
- Being able to switch between cloud platforms easily : e.g. from Genymotion Cloud SaaS to AWS. All the integrations are done in one single docker container.
- No knowledge is needed on how to use tools to start Genymotion devices in the cloud and integrate it with Appium and Selenium. All these mechanisms are done in the background, letting the users focus on writing their tests.
1/ Start the devices on which you wish to run your test on Genymotion Cloud
First, you need to define the devices with a JSON file :
template is the name of the template of the device you wish to start
deviceis the name of the device
port (optional) is the adb port if you need a persistent one. This is indeed quite handy for running appium tests without changing the device name in your tests every time you need to run those tests.
You can refer to this device.json file.
Then, start the docker container with those commands :
export PASS="xxx"docker run -it --rm -p 4723:4723 -v $PWD/genymotion/example/sample_devices:/root/tmp -e TYPE=SaaS -e USER=$USER -e PASS=$PASS budtmo/docker-android-genymotion
$PWD : path where your device.json file is stored. For example, if you pulled the docker-android project, the path is
If you’d like to use appium with selenium hub, you can use
docker-compose. Please refer to this geny.yml file. Then use this command to start the docker instead of docker run. Your current path must be
export USER="xxx" && export PASS="xxx" && docker-compose -f geny.yml up -d
- PaaS (AWS)
First, you need to define the devices with a JSON file :
You need to define for each instance the region (region field e.g eu-west-1 for Ireland) where it will run and the type of instance (instance field e.g t2.small).
Please refer to the product page for the complete list of compatible instance type.
By default, if you fill the android_version field (5.1 / 6.0 / 7.0 / 8.0), it will start the latest image available on the market. If you prefer to start preconfigured images you can use AMI field instead which is the AMI ID of the template.
Regarding security groups, if you don’t put any SG field, it will by default create one with those Inbound SSH, HTTP, HTTPS/WSS & WebRTC and Outbound rules on 0.0.0.0/0.
For a custom security group :
- an existing one, put the group ID in the SG field, e.g
- non existing one, input blocks like this for inbound and outbound rules
You can refer to this aws.json file
Then start the docker container with this command :
docker run -it --rm -p 4723:4723 -v $PWD:/root/tmp -v $PATH_AWS:/root/.aws -e TYPE=aws butomo1989/docker-android-genymotion
$PWD: path where your aws.json file is stored. For example, if you pulled the docker-android project, the path is
If you’d like to use appium with selenium hub, you can use docker-compose. Please refer to this geny.yml file. Then use this command to start the docker instead of docker run. Your current path must be
docker-compose -f geny.yml up -d
2/ Run your appium tests
Once the docker container is started, devices are launched and connected to adb in the container with the appium server port 4723 or the selenium hub 4444 port exposed depending on which command you used to start the container. No further configurations is needed, just run your tests as usual.
These are the adb serials of the devices started to identify them (UDID DesiredCapability) on which your tests will run against :
If you defined the
porte.g. 38727, the adb serial is
localhost:38727. If not it will be a random port.
Each device defined in the json file will get a port number starting from 5555. For example, if you start 2 devices, the adb serials will respectively be
localhost:5556for the first and second device in the list.
If you want to verify the devices connected to adb, you can always run
adb devices inside the container :
docker exec $ID adb devices
$ID is the ID of the container
3/ Stop your devices
Once your tests are finished, stopping the docker will automatically stop the instances. You don’t need to tear them down manually.
docker stop $(docker ps -a -q)
We plan in the future to integrate with GCP & Alibaba Cloud. Please leave in the comments which one you would like first! :)
Thanks budi utomo for reviewing the article.
Sign up on Genymotion Cloud SaaS for a free trial