Set default browser, mobile web test parameter and docker compose example
This commit is contained in:
parent
333c2b2a90
commit
5501a20426
|
@ -116,6 +116,12 @@ It is also possible to connect appium server that run inside docker-android with
|
|||
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
|
||||
|
||||
### 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***.
|
||||
|
|
|
@ -110,12 +110,14 @@ ARG API_LEVEL=21
|
|||
ARG PROCESSOR=x86
|
||||
ARG SYS_IMG=x86_64
|
||||
ARG IMG_TYPE=google_apis
|
||||
ARG BROWSER=android
|
||||
ENV ANDROID_VERSION=$ANDROID_VERSION \
|
||||
BUILD_TOOL=$BUILD_TOOL \
|
||||
API_LEVEL=$API_LEVEL \
|
||||
PROCESSOR=$PROCESSOR \
|
||||
SYS_IMG=$SYS_IMG \
|
||||
IMG_TYPE=$IMG_TYPE
|
||||
IMG_TYPE=$IMG_TYPE \
|
||||
BROWSER=$BROWSER
|
||||
RUN echo y | android update sdk --no-ui -a --filter build-tools-${BUILD_TOOL}
|
||||
ENV PATH ${PATH}:${ANDROID_HOME}/build-tools
|
||||
|
||||
|
|
|
@ -123,12 +123,14 @@ ARG API_LEVEL=21
|
|||
ARG PROCESSOR=x86
|
||||
ARG SYS_IMG=x86_64
|
||||
ARG IMG_TYPE=google_apis
|
||||
ARG BROWSER=android
|
||||
ENV ANDROID_VERSION=$ANDROID_VERSION \
|
||||
BUILD_TOOL=$BUILD_TOOL \
|
||||
API_LEVEL=$API_LEVEL \
|
||||
PROCESSOR=$PROCESSOR \
|
||||
SYS_IMG=$SYS_IMG \
|
||||
IMG_TYPE=$IMG_TYPE
|
||||
IMG_TYPE=$IMG_TYPE \
|
||||
BROWSER=$BROWSER
|
||||
RUN echo y | android update sdk --no-ui -a --filter build-tools-${BUILD_TOOL}
|
||||
ENV PATH ${PATH}:${ANDROID_HOME}/build-tools
|
||||
|
||||
|
|
16
example/compose/README.md
Normal file
16
example/compose/README.md
Normal file
|
@ -0,0 +1,16 @@
|
|||
[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
|
||||
```
|
31
example/compose/docker-compose.yml
Normal file
31
example/compose/docker-compose.yml
Normal file
|
@ -0,0 +1,31 @@
|
|||
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_selenium_grid.png
Normal file
BIN
images/compose_selenium_grid.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 49 KiB |
11
release.sh
11
release.sh
|
@ -110,11 +110,16 @@ function build() {
|
|||
fi
|
||||
|
||||
for v in "${versions[@]}"; do
|
||||
# Find image type
|
||||
# Find image type and default web browser
|
||||
if [ "$v" == "5.0.1" ] || [ "$v" == "5.1.1" ]; then
|
||||
IMG_TYPE=android
|
||||
BROWSER=browser
|
||||
elif [ "$v" == "6.0" ]; then
|
||||
IMG_TYPE=google_apis
|
||||
BROWSER=browser
|
||||
else
|
||||
IMG_TYPE=google_apis
|
||||
BROWSER=chrome
|
||||
fi
|
||||
echo "[BUILD] IMAGE TYPE: $IMG_TYPE"
|
||||
level=${list_of_levels[$v]}
|
||||
|
@ -127,10 +132,10 @@ function build() {
|
|||
echo "[BUILD] Dockerfile: $FILE_NAME"
|
||||
docker build -t $image_version --build-arg ANDROID_VERSION=$v --build-arg BUILD_TOOL=$LATEST_BUILD_TOOL \
|
||||
--build-arg API_LEVEL=$level --build-arg PROCESSOR=$p --build-arg SYS_IMG=$sys_img \
|
||||
--build-arg IMG_TYPE=$IMG_TYPE -f $FILE_NAME .
|
||||
--build-arg IMG_TYPE=$IMG_TYPE --build-arg BROWSER=$BROWSER -f $FILE_NAME .
|
||||
docker build -t $image_latest --build-arg ANDROID_VERSION=$v --build-arg BUILD_TOOL=$LATEST_BUILD_TOOL \
|
||||
--build-arg API_LEVEL=$level --build-arg PROCESSOR=$p --build-arg SYS_IMG=$sys_img \
|
||||
--build-arg IMG_TYPE=$IMG_TYPE -f $FILE_NAME .
|
||||
--build-arg IMG_TYPE=$IMG_TYPE --build-arg BROWSER=$BROWSER -f $FILE_NAME .
|
||||
done
|
||||
done
|
||||
}
|
||||
|
|
|
@ -106,11 +106,13 @@ def appium_run(avd_name: str):
|
|||
logger.info('Connect to selenium grid? {connect}'.format(connect=grid_connect))
|
||||
if grid_connect:
|
||||
try:
|
||||
mobile_web_test = str_to_bool(str(os.getenv('MOBILE_WEB_TEST', False)))
|
||||
default_web_browser = os.getenv('BROWSER')
|
||||
appium_host = os.getenv('APPIUM_HOST', local_ip)
|
||||
appium_port = int(os.getenv('APPIUM_PORT', 4723))
|
||||
selenium_host = os.getenv('SELENIUM_HOST', '172.17.0.1')
|
||||
selenium_port = int(os.getenv('SELENIUM_PORT', 4444))
|
||||
browser_name = os.getenv('BROWSER', 'Chrome')
|
||||
browser_name = default_web_browser if mobile_web_test else 'android'
|
||||
create_node_config(avd_name, browser_name, appium_host, appium_port, selenium_host, selenium_port)
|
||||
cmd += ' --nodeconfig {file}'.format(file=CONFIG_FILE)
|
||||
except ValueError as v_err:
|
||||
|
|
|
@ -44,7 +44,7 @@ class TestAppium(TestCase):
|
|||
def test_config_creation(self):
|
||||
from src import CONFIG_FILE
|
||||
self.assertFalse(os.path.exists(CONFIG_FILE))
|
||||
app.create_node_config('test', 'Chrome', '127.0.0.1', 4723, '127.0.0.1', 4444)
|
||||
app.create_node_config('test', 'android', '127.0.0.1', 4723, '127.0.0.1', 4444)
|
||||
self.assertTrue(os.path.exists(CONFIG_FILE))
|
||||
os.remove(CONFIG_FILE)
|
||||
|
||||
|
|
Loading…
Reference in a new issue