Merge pull request #111 from devilankur18/custom_args

Able to pass custom arguments to Emulator
This commit is contained in:
Budi Utomo 2018-08-21 16:23:22 +02:00 committed by GitHub
commit 9a714e5fb3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View file

@ -122,6 +122,13 @@ To run tests for mobile browser, following parameter can be passed:
```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-8.1
```
### Custom Emulator Arguments
If you want to add more arguments for running emulator, you can ***pass an evnironemnt variable EMULATOR_ARGS*** while running docker command.
```bash
docker run --privileged -d -p 6080:6080 -p 4723:4723 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" -e EMULATOR_ARGS="-no-snapshot-load -partition-size 512" -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-8.1
```
### Back & Restore
If you want to backup/reuse the avds created with furture upgrades or for replication, run the container with two extra mounts

View file

@ -186,8 +186,8 @@ def run():
"""Run app."""
device = os.getenv('DEVICE', 'Nexus 5')
logger.info('Device: {device}'.format(device=device))
device_id = os.getenv('DEVICE_ID', str(uuid.uuid4()))
logger.info('Device Id: {device_id}'.format(device_id=device_id))
custom_args=os.getenv('EMULATOR_ARGS', '')
logger.info('Custom Args: {custom_args}'.format(custom_args=custom_args))
avd_name = '{device}_{version}'.format(device=device.replace(' ', '_').lower(), version=ANDROID_VERSION)
logger.info('AVD name: {avd}'.format(avd=avd_name))
@ -203,9 +203,9 @@ def run():
cfg.write('\ndisk.dataPartition.size={dp}'.format(dp=dp_size))
if is_first_run:
cmd = 'emulator/emulator @{name} -gpu off -prop emu.uuid={uuid} -verbose -wipe-data'.format(name=avd_name, uuid=device_id)
cmd = 'emulator/emulator @{name} -gpu off -verbose -wipe-data {custom_args}'.format(name=avd_name, custom_args=custom_args)
else:
cmd = 'emulator/emulator @{name} -gpu off -prop emu.uuid={uuid} -verbose'.format(name=avd_name, uuid=device_id)
cmd = 'emulator/emulator @{name} -gpu off -verbose {custom_args}'.format(name=avd_name, custom_args=custom_args)
appium = convert_str_to_bool(str(os.getenv('APPIUM', False)))
if appium:
subprocess.Popen(cmd.split())