Skip to content

Commit

Permalink
Cleaned up
Browse files Browse the repository at this point in the history
  • Loading branch information
budtmo committed May 29, 2017
1 parent 47ff7bf commit 0360c18
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 63 deletions.
29 changes: 19 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 5555:5555 -p 4723:4723 -

### 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:

- CONNECT\_TO\_GRID=True
Expand All @@ -113,15 +110,13 @@ It is also possible to connect appium server that run inside docker-android with
- SELENIUM_HOST="\<host\_ip\_address>"
- 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:

- 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

Expand All @@ -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-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
------------------------------------------

Expand Down Expand Up @@ -193,7 +199,10 @@ docker exec -it android-container tail -f /var/log/supervisor/docker-android.std
[robotium]: <https://github.com/RobotiumTech/robotium>
[docker android samsung]: <images/docker_android_samsung.png>
[docker android nexus]: <images/docker_android_nexus.png>
[selenium grid]: <images/selenium_grid.png>
[devices are connected with selenium grid]: <images/connected_with_grid.png>
[compose]: <images/compose.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>
[sms]: <images/SMS.png>
60 changes: 60 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 3 additions & 2 deletions example/android/python/app_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ def setUp(self):
'deviceName': 'Android Emulator',
'automationName': 'UIAutomator2',
'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):
self.driver.quit()
Expand Down
5 changes: 3 additions & 2 deletions example/android/python/msite_simple_chrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ def setUp(self):
'deviceName': 'Android Emulator',
'appPackage': 'com.android.chrome',
'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):
self.driver.get('http://targeturl.com')
Expand Down
4 changes: 2 additions & 2 deletions example/android/python/msite_simple_default_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ def setUp(self):
'deviceName': 'Android Emulator',
'appPackage': 'com.android.browser',
'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):
self.driver.get('http://targeturl.com')
Expand Down
16 changes: 0 additions & 16 deletions example/compose/README.md

This file was deleted.

31 changes: 0 additions & 31 deletions example/compose/docker-compose.yml

This file was deleted.

Binary file added images/compose.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/compose_selenium_grid.png
Binary file not shown.
Binary file added images/connected_devices.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/connected_with_grid.png
Binary file not shown.
Binary file removed images/selenium_grid.png
Binary file not shown.

0 comments on commit 0360c18

Please sign in to comment.