Android in docker solution with noVNC supported and video recording
Find a file
ilya-netomedia bedf77e83d Update app.py
The Problem : Selenium grid 3.0.1 marking the node as down
Solution: Node config should be changed
2017-05-25 17:48:59 +03:00
devices Enable Samsung Galaxy S6 2017-03-16 16:33:26 +01:00
docker Set default browser, mobile web test parameter and docker compose example 2017-05-24 15:50:34 +03:00
example Set default browser, mobile web test parameter and docker compose example 2017-05-24 15:50:34 +03:00
images Set default browser, mobile web test parameter and docker compose example 2017-05-24 15:50:34 +03:00
src Update app.py 2017-05-25 17:48:59 +03:00
.gitignore First commit 2016-12-22 14:29:57 +01:00
.travis.yml Use build matrix to speed up build and push processes 2017-04-26 11:42:40 +02:00
LICENSE First commit 2016-12-22 14:29:57 +01:00
MAINTAINERS First commit 2016-12-22 14:29:57 +01:00
README.md Merge remote-tracking branch 'upstream/master' into appium_host_for_scale_support 2017-05-24 16:51:59 +03:00
release.sh Fix method name and build 6.0 without google_apis 2017-05-24 17:00:29 +03:00
requirements.txt Enable preinstallation android packages 2017-03-24 16:49:07 +01:00
setup.cfg Refactored code, added log and emulator skins 2017-02-27 14:53:48 +01:00
supervisord.conf Renamed log file 2017-04-26 14:19:46 +02:00
travis.sh Use build matrix to speed up build and push processes 2017-04-26 11:42:40 +02:00

Docker-Android

Build Status codecov Codacy Badge

Docker-Android is a docker image built to be used for everything related to mobile website testing and Android project.

Samsung Device Google Device

Purpose

  1. Run UI tests for mobile websites with appium
  2. Build Android project and run unit tests with the latest build-tools
  3. Run UI tests for Android applications with different frameworks (appium, espresso, robotium, etc.)
  4. Run monkey / stress tests
  5. SMS testing

Advantages compare with other docker-android projects

  1. noVNC to see what happen inside docker container
  2. Emulator for different devices / skins, such as Samsung Galaxy S6, LG Nexus 4, HTC Nexus One and more.
  3. Ability to connect to Selenium Grid
  4. Ability to control emulator from outside container by using adb connect
  5. Open source with more features coming (monkey test, support real devices with screen mirroring and video recording)

List of Docker images

Supported OS Android version API level Image name Image status
Linux 5.0.1 21 butomo1989/docker-android-x86-5.0.1
Linux 5.1.1 22 butomo1989/docker-android-x86-5.1.1
Linux 6.0 23 butomo1989/docker-android-x86-6.0
Linux 7.0 24 butomo1989/docker-android-x86-7.0
Linux 7.1.1 25 butomo1989/docker-android-x86-7.1.1
OSX / Windows 5.0.1 21 butomo1989/docker-android-arm-5.0.1
OSX / Windows 5.1.1 22 butomo1989/docker-android-arm-5.1.1
OSX / Windows 6.0 23 butomo1989/docker-android-arm-6.0
OSX / Windows 7.0 24 butomo1989/docker-android-arm-7.0
OSX / Windows 7.1.1 25 butomo1989/docker-android-arm-7.1.1

List of Devices

Type Device Name
Phone Samsung Galaxy S6
Phone Nexus 4
Phone Nexus 5
Phone Nexus One
Phone Nexus S
Tablet Nexus 7

Requirements

Docker is installed in your system.

Quick Start

  1. Run docker-android

    • For Linux OS, please use image name that contains "x86"

      docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" --name android-container butomo1989/docker-android-x86-7.1.1
      
    • For OSX and Windows OS, please use image name that contains "arm"

      docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" --name android-container butomo1989/docker-android-arm-7.1.1
      
  2. Verify the ip address of docker host.

    • For OSX, you can find out by using following command:

      docker-machine ip default
      
    • For different OS, localhost should work.

  3. Open http://docker-host-ip-address:6080 from web browser.

Run Appium Server

Appium is automation test framework to test mobile website and mobile application, including android. To be able to use appium, you need to run appium-server. You run appium server inside docker-android container by opening port 4723 and passing an environment variable APPIUM=TRUE.

docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 5555:5555 -p 4723:4723 -e DEVICE="Samsung Galaxy S6" -e APPIUM=True --name android-container butomo1989/docker-android-x86-7.1.1

Connect to Selenium Grid

It is also possible to connect appium server that run inside docker-android with selenium grid by passing following environment variables:

  • CONNECT_TO_GRID=True
  • APPIUM_HOST="<host_ip_address>"
  • APPIUM_PORT=<port_number>
  • SELENIUM_HOST="<host_ip_address>"
  • SELENIUM_PORT=<port_number>
docker run --privileged -d -p 6080:6080 -p 4723:4723 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" -e APPIUM=True -e CONNECT_TO_GRID=True -e APPIUM_HOST="127.0.0.1" -e APPIUM_PORT=4723 -e SELENIUM_HOST="172.17.0.1" -e SELENIUM_PORT=4444 --name android-container butomo1989/docker-android-x86-7.1.1

To run tests for mobile browser, following parameter can be passed:

  • MOBILE_WEB_TEST=True

Check README.md on how to run complete selenium grid using docker-compose

Share Volume

If you want to use appium to test UI of your android application, you need to share volume where the APK is located to folder /root/tmp.

docker run --privileged -d -p 6080:6080 -p 4723:4723 -p 5554:5554 -p 5555:5555 -v $PWD/example/sample_apk:/root/tmp -e DEVICE="Nexus 5" -e APPIUM=True -e CONNECT_TO_GRID=True -e APPIUM_HOST="127.0.0.1" -e APPIUM_PORT=4723 -e SELENIUM_HOST="172.17.0.1" -e SELENIUM_PORT=4444 --name android-container butomo1989/docker-android-x86-7.1.1

Control android emulator outside container

adb connect <docker-machine-ip-address>:5555

Note: You need to have Android Debug Bridge (adb) installed in your host machine.

SMS Simulation

  1. Using telnet

    • Find the auth_token and copy it.
    docker exec -it android-container cat /root/.emulator_console_auth_token
    
    • Access emulator using telnet and login with auth_token
    telnet <docker-machine-ip-address> 5554
    
    • Login with given auth_token from 1.step
    auth <auth_token>
    
    • Send the sms
    sms send <phone_number> <message>
    
  2. Using adb

    docker exec -it android-container adb emu sms send <phone_number> <message>
    
  3. You can also integrate it inside project using adb library.

Troubleshooting

All logs inside container are stored under folder /var/log/supervisor. you can print out log file by using docker exec. Example:

docker exec -it android-container tail -f /var/log/supervisor/docker-android.stdout.log