Cleaned up

This commit is contained in:
butomo1989 2017-05-29 14:34:35 +02:00
parent 47ff7bf223
commit 0360c181c0
12 changed files with 87 additions and 63 deletions

View file

@ -102,9 +102,6 @@ docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 5555:5555 -p 4723:4723 -
### Connect to Selenium Grid ### Connect to Selenium Grid
![][selenium grid]
![][devices are connected with selenium grid]
It is also possible to connect appium server that run inside docker-android with selenium grid by passing following environment variables: 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 - CONNECT\_TO\_GRID=True
@ -113,15 +110,13 @@ It is also possible to connect appium server that run inside docker-android with
- SELENIUM_HOST="\<host\_ip\_address>" - SELENIUM_HOST="\<host\_ip\_address>"
- SELENIUM_PORT=\<port\_number> - SELENIUM_PORT=\<port\_number>
```bash
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: To run tests for mobile browser, following parameter can be passed:
- MOBILE\_WEB\_TEST=True - MOBILE\_WEB\_TEST=True
Check [README.md](/example/compose/README.md) on how to run complete selenium grid using docker-compose ```bash
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 -e MOBILE_WEB_TEST=True --name android-container butomo1989/docker-android-x86-7.1.1
```
### Share Volume ### Share Volume
@ -131,6 +126,17 @@ If you want to use appium to test UI of your android application, you need to sh
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 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
``` ```
### Docker-Compose
![][compose]
![][connected_devices]
There is [example of compose file] to run complete selenium grid and docker-android container as nodes. [docker-compose] version [1.13.0] or higher is required to be able to execute that compose file.
```bash
docker-compose up -d
```
Control android emulator outside container Control android emulator outside container
------------------------------------------ ------------------------------------------
@ -193,7 +199,10 @@ docker exec -it android-container tail -f /var/log/supervisor/docker-android.std
[robotium]: <https://github.com/RobotiumTech/robotium> [robotium]: <https://github.com/RobotiumTech/robotium>
[docker android samsung]: <images/docker_android_samsung.png> [docker android samsung]: <images/docker_android_samsung.png>
[docker android nexus]: <images/docker_android_nexus.png> [docker android nexus]: <images/docker_android_nexus.png>
[selenium grid]: <images/selenium_grid.png> [compose]: <images/compose.png>
[devices are connected with selenium grid]: <images/connected_with_grid.png> [connected_devices]: <images/connected_devices.png>
[example of compose file]: <docker-compose.yml>
[docker-compose]: <https://docs.docker.com/compose/install/>
[1.13.0]: <https://github.com/docker/compose/releases/tag/1.13.0>
[adb_connection]: <images/adb_connection.png> [adb_connection]: <images/adb_connection.png>
[sms]: <images/SMS.png> [sms]: <images/SMS.png>

60
docker-compose.yml Normal file
View file

@ -0,0 +1,60 @@
# Note: It requires docker-compose 1.13.0
#
# Usage: docker-compose up -d
version: "2.2"
services:
# Selenium hub
selenium_hub:
image: selenium/hub:3.4.0
ports:
- "4444:4444"
# Docker-Android for Android application testing
nexus_7.1.1:
image: butomo1989/docker-android-x86-7.1.1
privileged: true
# Change path of apk that you want to test. I use sample_apk that I provide in folder "example"
volumes:
- $PWD/example/sample_apk:/root/tmp
# Increase scale number if needed
scale: 1
ports:
- 6080
environment:
- DEVICE=Nexus 5
- CONNECT_TO_GRID=True
- APPIUM=true
- SELENIUM_HOST=selenium_hub
# Docker-Android for mobile website testing with chrome browser
# Chrome browser exists only for version 7.0 and 7.1.1
samsung_galaxy_web_7.1.1:
image: butomo1989/docker-android-x86-7.1.1
privileged: true
# Increase scale number if needed
scale: 1
ports:
- 6080
environment:
- DEVICE=Samsung Galaxy S6
- CONNECT_TO_GRID=True
- APPIUM=true
- SELENIUM_HOST=selenium_hub
- MOBILE_WEB_TEST=True
# Docker-Android for mobile website testing with default browser
# Default browser exists only for version 5.0.1, 5.1.1 and 6.0
samsung_galaxy_web_5.1.1:
image: butomo1989/docker-android-x86-5.1.1
privileged: true
# Increase scale number if needed
scale: 1
ports:
- 6080
environment:
- DEVICE=Samsung Galaxy S6
- CONNECT_TO_GRID=True
- APPIUM=true
- SELENIUM_HOST=selenium_hub
- MOBILE_WEB_TEST=True

View file

@ -11,9 +11,10 @@ class SimpleAndroidUITests(unittest.TestCase):
'deviceName': 'Android Emulator', 'deviceName': 'Android Emulator',
'automationName': 'UIAutomator2', 'automationName': 'UIAutomator2',
'app': '/root/tmp/sample_apk_debug.apk', 'app': '/root/tmp/sample_apk_debug.apk',
'avd': 'samsung_galaxy_s6_7.1.1' 'browserName': 'android',
'avd': 'nexus_5_7.1.1'
} }
self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps) self.driver = webdriver.Remote('http://127.0.0.1:4444/wd/hub', desired_caps)
def tearDown(self): def tearDown(self):
self.driver.quit() self.driver.quit()

View file

@ -13,9 +13,10 @@ class MSiteChromeAndroidUITests(unittest.TestCase):
'deviceName': 'Android Emulator', 'deviceName': 'Android Emulator',
'appPackage': 'com.android.chrome', 'appPackage': 'com.android.chrome',
'appActivity': 'com.google.android.apps.chrome.Main', 'appActivity': 'com.google.android.apps.chrome.Main',
'avd': 'samsung_galaxy_s6_7.1.1' 'browserName': 'chrome',
'ignore-certificate-errors': True
} }
self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps) self.driver = webdriver.Remote('http://127.0.0.1:4444/wd/hub', desired_caps)
def test_open_url(self): def test_open_url(self):
self.driver.get('http://targeturl.com') self.driver.get('http://targeturl.com')

View file

@ -13,9 +13,9 @@ class MSiteDefaultBrowserAndroidUITests(unittest.TestCase):
'deviceName': 'Android Emulator', 'deviceName': 'Android Emulator',
'appPackage': 'com.android.browser', 'appPackage': 'com.android.browser',
'appActivity': 'com.android.browser.BrowserActivity', 'appActivity': 'com.android.browser.BrowserActivity',
'avd': 'samsung_galaxy_s6_6.0' 'browserName': 'browser'
} }
self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps) self.driver = webdriver.Remote('http://127.0.0.1:4444/wd/hub', desired_caps)
def test_open_url(self): def test_open_url(self):
self.driver.get('http://targeturl.com') self.driver.get('http://targeturl.com')

View file

@ -1,16 +0,0 @@
[docker-compose.yml](/example/compose/docker-compose.yml) file for setting up selenium grid.
-----------------------------------------------------
Example compose file which can be used to set up selenium grid hub with emulator nodes connected to it
![](/images/compose_selenium_grid.png)
Requirements
============
docker-compose
for `scale:` option docker-compose v1.13.0 and newer is required
Quick Start
===========
```bash
docker-compose up
```

View file

@ -1,31 +0,0 @@
version: "2.2"
services:
hub:
image: selenium/hub:3.4.0
ports:
- "4444:4444"
node_samsung_7.1.1:
image: butomo1989/docker-android-x86-7.1.1
privileged: true
scale: 2
ports:
- 6080
environment:
- DEVICE=Samsung Galaxy S6
- CONNECT_TO_GRID=True
- APPIUM=true
- SELENIUM_HOST=hub
node_nexus_web_7.1.1:
image: butomo1989/docker-android-x86-7.1.1
privileged: true
scale: 2
ports:
- 6080
environment:
- DEVICE=Nexus 5
- CONNECT_TO_GRID=True
- APPIUM=true
- SELENIUM_HOST=hub
- MOBILE_WEB_TEST=True

BIN
images/compose.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 607 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 448 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB