Compare commits

...
6 Commits
Author SHA1 Message Date
butomo1989 d2843d7260 Silent mode to reduce logs 2017-04-21 15:50:12 +02:00
butomo1989 67726cf735 Updated unit test 2017-04-21 15:27:54 +02:00
butomo1989 e59c28ebd8 Turn off appium server by default 2017-04-21 15:18:01 +02:00
butomo1989 7ce3cfba96 Using google_apis 2017-04-21 15:06:53 +02:00
butomo1989 63e64d219b Changed path of target apk 2017-04-21 13:46:04 +02:00
butomo1989 2ef82e3894 Added android 7.0 in the list 2017-04-21 11:23:24 +02:00
9 changed files with 52 additions and 21 deletions
+6 -6
View File
@@ -51,7 +51,7 @@ WORKDIR /root
# ubuntu-vm-builder # ubuntu-vm-builder
# bridge-utils # bridge-utils
#================== #==================
RUN apt-get update && apt-get install -y --no-install-recommends \ RUN apt-get -qqy update && apt-get -qqy install --no-install-recommends \
wget \ wget \
unzip \ unzip \
curl \ curl \
@@ -79,11 +79,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
#======= #=======
ENV NOVNC_SHA="b403cb92fb8de82d04f305b4f14fa978003890d7" \ ENV NOVNC_SHA="b403cb92fb8de82d04f305b4f14fa978003890d7" \
WEBSOCKIFY_SHA="558a6439f14b0d85a31145541745e25c255d576b" WEBSOCKIFY_SHA="558a6439f14b0d85a31145541745e25c255d576b"
RUN wget -O noVNC.zip "https://github.com/kanaka/noVNC/archive/${NOVNC_SHA}.zip" \ RUN wget -nv -O noVNC.zip "https://github.com/kanaka/noVNC/archive/${NOVNC_SHA}.zip" \
&& unzip -x noVNC.zip \ && unzip -x noVNC.zip \
&& rm noVNC.zip \ && rm noVNC.zip \
&& mv noVNC-${NOVNC_SHA} noVNC \ && mv noVNC-${NOVNC_SHA} noVNC \
&& wget -O websockify.zip "https://github.com/kanaka/websockify/archive/${WEBSOCKIFY_SHA}.zip" \ && wget -nv -O websockify.zip "https://github.com/kanaka/websockify/archive/${WEBSOCKIFY_SHA}.zip" \
&& unzip -x websockify.zip \ && unzip -x websockify.zip \
&& mv websockify-${WEBSOCKIFY_SHA} ./noVNC/utils/websockify \ && mv websockify-${WEBSOCKIFY_SHA} ./noVNC/utils/websockify \
&& rm websockify.zip \ && rm websockify.zip \
@@ -97,7 +97,7 @@ ENV PATH ${PATH}:${JAVA_HOME}/bin
ENV SDK_VERSION=25.2.3 \ ENV SDK_VERSION=25.2.3 \
ANDROID_HOME=/root ANDROID_HOME=/root
RUN wget -O android.zip https://dl.google.com/android/repository/tools_r${SDK_VERSION}-linux.zip \ RUN wget -nv -O android.zip https://dl.google.com/android/repository/tools_r${SDK_VERSION}-linux.zip \
&& unzip android.zip && rm android.zip && unzip android.zip && rm android.zip
ENV PATH ${PATH}:${ANDROID_HOME}/tools ENV PATH ${PATH}:${ANDROID_HOME}/tools
RUN echo y | android update sdk --no-ui -a --filter platform-tools RUN echo y | android update sdk --no-ui -a --filter platform-tools
@@ -107,7 +107,7 @@ ENV PATH ${PATH}:${ANDROID_HOME}/platform-tools
# Install latest nodejs, npm, appium # Install latest nodejs, npm, appium
#==================================== #====================================
RUN curl -sL https://deb.nodesource.com/setup_7.x | bash - \ RUN curl -sL https://deb.nodesource.com/setup_7.x | bash - \
&& apt-get update && apt-get install -y nodejs && rm -rf /var/lib/apt/lists/* && apt-get -qqy update && apt-get -qqy install nodejs && rm -rf /var/lib/apt/lists/*
ENV APPIUM_VERSION 1.6.3 ENV APPIUM_VERSION 1.6.3
RUN npm install -g appium@$APPIUM_VERSION && npm cache clean RUN npm install -g appium@$APPIUM_VERSION && npm cache clean
@@ -129,7 +129,7 @@ ENV PATH ${PATH}:${ANDROID_HOME}/build-tools
RUN rm ${ANDROID_HOME}/tools/emulator \ RUN rm ${ANDROID_HOME}/tools/emulator \
&& ln -s ${ANDROID_HOME}/tools/emulator64-${PROCESSOR} ${ANDROID_HOME}/tools/emulator && ln -s ${ANDROID_HOME}/tools/emulator64-${PROCESSOR} ${ANDROID_HOME}/tools/emulator
RUN echo y | android update sdk --no-ui -a -t android-${API_LEVEL},sys-img-${SYS_IMG}-android-${API_LEVEL} RUN echo y | android update sdk --no-ui -a -t android-${API_LEVEL},sys-img-${SYS_IMG}-google_apis-${API_LEVEL}
#================================================ #================================================
# noVNC Default Configurations # noVNC Default Configurations
+6 -6
View File
@@ -35,13 +35,13 @@ List of Docker images
|Linux|5.0.1|21|butomo1989/docker-android-x86-5.0.1|[![](https://images.microbadger.com/badges/image/butomo1989/docker-android-x86-5.0.1.svg)](https://microbadger.com/images/butomo1989/docker-android-x86-5.0.1 "Get your own image badge on microbadger.com")| |Linux|5.0.1|21|butomo1989/docker-android-x86-5.0.1|[![](https://images.microbadger.com/badges/image/butomo1989/docker-android-x86-5.0.1.svg)](https://microbadger.com/images/butomo1989/docker-android-x86-5.0.1 "Get your own image badge on microbadger.com")|
|Linux|5.1.1|22|butomo1989/docker-android-x86-5.1.1|[![](https://images.microbadger.com/badges/image/butomo1989/docker-android-x86-5.1.1.svg)](https://microbadger.com/images/butomo1989/docker-android-x86-5.1.1 "Get your own image badge on microbadger.com")| |Linux|5.1.1|22|butomo1989/docker-android-x86-5.1.1|[![](https://images.microbadger.com/badges/image/butomo1989/docker-android-x86-5.1.1.svg)](https://microbadger.com/images/butomo1989/docker-android-x86-5.1.1 "Get your own image badge on microbadger.com")|
|Linux|6.0|23|butomo1989/docker-android-x86-6.0|[![](https://images.microbadger.com/badges/image/butomo1989/docker-android-x86-6.0.svg)](https://microbadger.com/images/butomo1989/docker-android-x86-6.0 "Get your own image badge on microbadger.com")| |Linux|6.0|23|butomo1989/docker-android-x86-6.0|[![](https://images.microbadger.com/badges/image/butomo1989/docker-android-x86-6.0.svg)](https://microbadger.com/images/butomo1989/docker-android-x86-6.0 "Get your own image badge on microbadger.com")|
|Linux|7.0|24|*TODO* because still have a Bug|| |Linux|7.0|24|butomo1989/docker-android-x86-7.0|[![](https://images.microbadger.com/badges/image/butomo1989/docker-android-x86-7.0.svg)](https://microbadger.com/images/butomo1989/docker-android-x86-7.0 "Get your own image badge on microbadger.com")|
|Linux|7.1.1|25|*TODO* because still have a Bug|| |Linux|7.1.1|25|butomo1989/docker-android-x86-7.1.1|[![](https://images.microbadger.com/badges/image/butomo1989/docker-android-x86-7.1.1.svg)](https://microbadger.com/images/butomo1989/docker-android-x86-7.1.1 "Get your own image badge on microbadger.com")|
|OSX / Windows|5.0.1|21|butomo1989/docker-android-arm-5.0.1|[![](https://images.microbadger.com/badges/image/butomo1989/docker-android-arm-5.0.1.svg)](https://microbadger.com/images/butomo1989/docker-android-arm-5.0.1 "Get your own image badge on microbadger.com")| |OSX / Windows|5.0.1|21|butomo1989/docker-android-arm-5.0.1|[![](https://images.microbadger.com/badges/image/butomo1989/docker-android-arm-5.0.1.svg)](https://microbadger.com/images/butomo1989/docker-android-arm-5.0.1 "Get your own image badge on microbadger.com")|
|OSX / Windows|5.1.1|22|butomo1989/docker-android-arm-5.1.1|[![](https://images.microbadger.com/badges/image/butomo1989/docker-android-arm-5.1.1.svg)](https://microbadger.com/images/butomo1989/docker-android-arm-5.1.1 "Get your own image badge on microbadger.com")| |OSX / Windows|5.1.1|22|butomo1989/docker-android-arm-5.1.1|[![](https://images.microbadger.com/badges/image/butomo1989/docker-android-arm-5.1.1.svg)](https://microbadger.com/images/butomo1989/docker-android-arm-5.1.1 "Get your own image badge on microbadger.com")|
|OSX / Windows|6.0|23|butomo1989/docker-android-arm-6.0|[![](https://images.microbadger.com/badges/image/butomo1989/docker-android-arm-6.0.svg)](https://microbadger.com/images/butomo1989/docker-android-arm-6.0 "Get your own image badge on microbadger.com")| |OSX / Windows|6.0|23|butomo1989/docker-android-arm-6.0|[![](https://images.microbadger.com/badges/image/butomo1989/docker-android-arm-6.0.svg)](https://microbadger.com/images/butomo1989/docker-android-arm-6.0 "Get your own image badge on microbadger.com")|
|OSX / Windows|7.0|24|*TODO* because still have a Bug|| |OSX / Windows|7.0|24|butomo1989/docker-android-arm-7.0|[![](https://images.microbadger.com/badges/image/butomo1989/docker-android-arm-7.0.svg)](https://microbadger.com/images/butomo1989/docker-android-arm-7.0 "Get your own image badge on microbadger.com")|
|OSX / Windows|7.1.1|25|*TODO* because still have a Bug|| |OSX / Windows|7.1.1|25|butomo1989/docker-android-arm-7.1.1|[![](https://images.microbadger.com/badges/image/butomo1989/docker-android-arm-7.1.1.svg)](https://microbadger.com/images/butomo1989/docker-android-arm-7.1.1 "Get your own image badge on microbadger.com")|
Quick Start Quick Start
----------- -----------
@@ -51,12 +51,12 @@ Quick Start
2. Run docker-android 2. Run docker-android
```bash ```bash
docker run --privileged -d -p 6080:6080 -p 4723:4723 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" -e APPIUM=False --name android-container butomo1989/docker-android-x86-5.0.1 docker run --privileged -d -p 6080:6080 -p 4723:4723 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" --name android-container butomo1989/docker-android-x86-5.0.1
``` ```
**Optional arguments** **Optional arguments**
-v <android_project_or_apk>:/root : You need to share volume or apk file if for example you want to build the android project inside docker container or you want to run UI test by using appium. -v <android_project_or_apk>:/root/tmp : You need to share volume or apk file if for example you want to build the android project inside docker container or you want to run UI test by using appium.
-e APPIUM=True: If you want to use appium as UI test framework to test mobile website or android application -e APPIUM=True: If you want to use appium as UI test framework to test mobile website or android application
3. Verify the ip address of docker-machine. 3. Verify the ip address of docker-machine.
+5 -3
View File
@@ -1,7 +1,7 @@
Docker-Android-Appium Sample Docker-Android Sample UITests with Appium
---------------------------- -----------------------------------------
Example UI test to use docker-appium. Example UI test with [Appium] to use docker-android.
Requirements Requirements
============ ============
@@ -12,3 +12,5 @@ Quick Start
=========== ===========
1. pip install -r requirements.txt 1. pip install -r requirements.txt
2. python app_simple.py 2. python app_simple.py
[Appium]: <https://appium.io>
+2 -2
View File
@@ -9,8 +9,8 @@ class SimpleAndroidUITests(unittest.TestCase):
desired_caps = { desired_caps = {
'platformName': 'Android', 'platformName': 'Android',
'deviceName': 'Android Emulator', 'deviceName': 'Android Emulator',
'app': '/root/sample_apk_debug.apk', 'app': '/root/tmp/sample_apk_debug.apk',
'avd': 'nexus_5_5.0' 'avd': 'samsung_galaxy_s6_5.0.1'
} }
self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps) self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
@@ -0,0 +1,26 @@
import unittest
from appium import webdriver
class MSiteChromeAndroidUITests(unittest.TestCase):
def setUp(self):
desired_caps = {
'platformName': 'Android',
'deviceName': 'Android Emulator',
'appPackage': 'com.android.chrome',
'appActivity': 'com.google.android.apps.chrome.Main',
'avd': 'samsung_galaxy_s6_5.0.1'
}
self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
def test_open_url(self):
self.driver.get('http://targeturl.com')
def tearDown(self):
self.driver.quit()
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(MSiteChromeAndroidUITests)
unittest.TextTestRunner(verbosity=2).run(suite)
@@ -11,7 +11,7 @@ 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': 'nexus_5_5.0' 'avd': 'samsung_galaxy_s6_5.0.1'
} }
self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps) self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
+3 -1
View File
@@ -11,7 +11,7 @@ else
fi fi
if [ -z "$2" ]; then if [ -z "$2" ]; then
read -p "Android version (5.0.1|5.1.1|6.0|all): " ANDROID_VERSION read -p "Android version (5.0.1|5.1.1|6.0|7.0|7.1.1|all): " ANDROID_VERSION
else else
ANDROID_VERSION=$2 ANDROID_VERSION=$2
fi fi
@@ -32,6 +32,8 @@ declare -A list_of_levels=(
[5.0.1]=21 [5.0.1]=21
[5.1.1]=22 [5.1.1]=22
[6.0]=23 [6.0]=23
[7.0]=24
[7.1.1]=25
) )
declare -A list_of_processors=( declare -A list_of_processors=(
+2 -2
View File
@@ -59,7 +59,7 @@ def prepare_avd(device: str, avd_name: str):
:param device: Device name :param device: Device name
:param avd_name: Name of android virtual device / emulator :param avd_name: Name of android virtual device / emulator
""" """
cmd = 'echo no | android create avd -f -n {name} -t android-{api} -b {sys_img}'.format( cmd = 'echo no | android create avd -f -n {name} -t android-{api} -b google_apis/{sys_img}'.format(
name=avd_name, api=API_LEVEL, sys_img=SYS_IMG) name=avd_name, api=API_LEVEL, sys_img=SYS_IMG)
# Link emulator skins # Link emulator skins
@@ -167,7 +167,7 @@ def run():
cmd = 'emulator -avd {name}'.format(name=avd_name) cmd = 'emulator -avd {name}'.format(name=avd_name)
subprocess.Popen(cmd.split()) subprocess.Popen(cmd.split())
appium = str_to_bool(str(os.getenv('APPIUM', True))) appium = str_to_bool(str(os.getenv('APPIUM', False)))
if appium: if appium:
logger.info('Run appium server...') logger.info('Run appium server...')
appium_run(avd_name) appium_run(avd_name)
+1
View File
@@ -37,6 +37,7 @@ class TestApp(TestCase):
@mock.patch('subprocess.Popen') @mock.patch('subprocess.Popen')
def test_run_with_appium(self, mocked_avd, mocked_subprocess): def test_run_with_appium(self, mocked_avd, mocked_subprocess):
with mock.patch('src.app.appium_run') as mocked_appium: with mock.patch('src.app.appium_run') as mocked_appium:
os.environ['APPIUM'] = str(True)
app.run() app.run()
self.assertTrue(mocked_avd.called) self.assertTrue(mocked_avd.called)
self.assertTrue(mocked_subprocess.called) self.assertTrue(mocked_subprocess.called)