Code Monkey home page Code Monkey logo

appium-docker-android's Introduction

Build and Push Docker Pulls

Appium Docker for Android

Why is this approach needed at first place?

  • Helps in quick & easier setup of automation environment for Appium + Android
  • Without this approach, you'll need to do each of the automation setup steps manually; which can be slow and error prone

Images Included:

  • appium/appium - Docker Image to run appium tests on real Android devices.
  • To execute in Android emulator's please visit docker-android

How to Build:

$ docker build -t "appium/appium:local" -f Appium/Dockerfile Appium

Quick Start

  1. Connect Android device to the machine via USB

  2. Run Appium-Docker-Android

    $ docker run --privileged -d -p 4723:4723  -v /dev/bus/usb:/dev/bus/usb --name appium-container appium/appium
    

    OR you can get the id of the device via this command ls -l /dev/serial/by-id and pass the device-id to container to have more security

    docker run --privileged -d -p 4723:4723 --device=/dev/<your-device-id> --name appium-container appium/appium
    
  3. Run following command to verify adb devices can detect the connected android device.

    $ docker exec -it appium-container adb devices
    

    On Windows OS, you need to specify the host to host.docker.internal

    $ docker exec -it appium-container adb -H host.docker.internal devices
    
  4. Run UI Test with following test configuration

    Push the apk file into the container
    $ docker cp /home/myuser/localfolder/app-debug.apk appium-container:/home/androidusr/sample.apk
    
    Desired Capabilities:
    
    private void androidSetup() throws MalformedURLException {
            caps.setCapability("deviceName", "Android");
            caps.setCapability("app", "/home/androidusr/sample.apk");
            //Get the IP Address of boot2docker
            //docker inspect $(docker ps -q) | grep IPA
            driver = new AndroidDriver<MobileElement>(new URL("http://192.168.99.100:32769/wd/hub"), caps);
    }
    

    On Windows OS, you need to set the capability appium:remoteAdbHost to host.docker.internal. This capability is supported by various drivers: UiAutomator2, Espresso, Flutter.

Additional configuration

Share Android identification key

Each time, you will (re)create container, connected to container devices will ask for authorization after first connection. To prevent that, you can share one identity through all created containers. To do that, you should:

  • Connect all devices to docker physical machine
  • Run adb devices
  • Authorize all devices (do not forget to check Always allow this computer)

Always allow this computer screenshot

  • run your containers with parameter -v ~/.android:/home/androidusr/.android

For example:

$ docker run --privileged -d -p 4723:4723 -v ~/.android:/home/androidusr/.android -v /dev/bus/usb:/dev/bus/usb --name appium-container appium/appium

Connect Each Device to a Separate Container

In certain use cases you may want to have a single Appium-Docker-Android container running for each device. To achieve this you must run adb kill-server and then provide the --device option to docker run:

$ docker run -d -p 4723:4723 --device /dev/bus/usb/XXX/YYY:/dev/bus/usb/XXX/YYY -v ~/.android:/root/.android --name device1 appium/appium
$ docker run -d -p 4724:4723 --device /dev/bus/usb/XXX/ZZZ:/dev/bus/usb/XXX/ZZZ -v ~/.android:/root/.android --name device2 appium/appium

Connect to Android devices by Air

Appium-Docker-Android can be connected with Android devices by Air.

To do that you need to configure android device, according to official manual

Then run docker container with following parameters:

  • REMOTE_ADB=true
  • ANDROID_DEVICES=<android_device_host>:<android_device_port> [,<android_device_host>:<android_device_port>]
  • REMOTE_ADB_POLLING_SEC=60 (default: 5, interval between polling the list of connected devices in order to connect to lost remote devices)
$ docker run -d -p 4723:4723 -e REMOTE_ADB=true -e ANDROID_DEVICES=192.168.0.5:5555,192.168.0.6:5555 -e REMOTE_ADB_POLLING_SEC=60

Additional Appium parameter

APPIUM_ADDITIONAL_PARAMS="", e.g. --relaxed-security --allow-insecure chromedriver_autodownload --allow-insecure adb_shell

Connect to Selenium Grid

Appium-Docker-Android can be connected with selenium grid by passing following parameters:

  • CONNECT_TO_GRID=true
  • APPIUM_HOST=<ip_address_of_appium_server>
  • APPIUM_PORT=<port_of_appium_server>
  • SELENIUM_HOST=<ip_address_of_selenium_hub>
  • SELENIUM_PORT=<port_of_selenium_hub>
$ docker run --privileged -d -p 4723:4723 -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 -v /dev/bus/usb:/dev/bus/usb --name appium-container appium/appium

Custom Node Config

The image generates the node config file, if you would like to provide your own config pass the following parameters:

  • CONNECT_TO_GRID=true
  • CUSTOM_NODE_CONFIG=true
  • -v <path_to_config>:/root/nodeconfig.json

Docker compose

There is an example of compose file to simulate the connection between selenium hub and appium server with connected device(s) in docker solution.

$ docker-compose up -d

appium-docker-android's People

Contributors

0penth3wind0w avatar andrcuns avatar arthurhd avatar budtmo avatar davirss avatar diemol avatar eyeojeff avatar irfanahmadein avatar jlipps avatar megolee avatar patrickduncan avatar pr4bh4sh avatar ranitdey avatar rarrouas avatar red-avtovo avatar rzrnt avatar saikrishna321 avatar srinivasantarget avatar vikramvi avatar weihongliang233 avatar xuanzhaopeng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

appium-docker-android's Issues

docker build failing now after broken udev-rules url

docker build failing on master with below error message

https://raw.githubusercontent.com/M0Rf30/android-udev-rules/ubuntu/master/51-android.rules:
2017-02-04 16:39:12 ERROR 404: Not Found.
The command '/bin/sh -c mkdir /etc/udev/rules.d   && wget --no-verbose $UDEV_REMOTE_FILE -O /etc/udev/rules.d/51-android.rules' returned a non-zero code: 8

reason : android-udev-rules remote file is removed at M0Rf30/android-udev-rules@2010aef

Not able to run the docker image step 8

I am new to docker and following the steps exactly as mentioned in the doc. I am successful till mounting my Android USB device. When i run this command

docker run --privileged -d -p 4723:4723 -v /dev/bus/usb:/dev/bus/usb --name container-appium appium/appium

i am getting this issue

9938ae1e839c5575963eaed5128c6569d9706aafa877dbcd74b2a6948748ba2d docker: Error response from daemon: Mounts denied: The path /dev/bus/usb is not shared from OS X and is not known to Docker. You can configure shared paths from Docker -> Preferences... -> File Sharing. See https://docs.docker.com/docker-for-mac/osxfs/#namespaces for more info. . and i am using mac sierra. Thanks for your help

issue after restarting the container

Once after restart the docker image - appium-test-machine,
And perform adb devices, docker exec -it container-appium adb devices
I am getting.
Error response from daemon: Container 79c6625c09eb91fcf98521f20fbec3f1bd4d679ab82a9728c0d0e8d2e3ca8a39 is not running
How to fix this ?

Bootstrap socket crash

Hi Budi,
Firstly i want to thanks you for amazing documents, I registered multiple devices on one container and
When I run tests, i get error message:
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Android bootstrap socket crashed: Error: This socket has been ended by the other party

Please help me.how Can i solve this issue

Thanks a lot

Unable to copy .apk file inside container-appium

I am able to perform,
docker cp /Users/loacl-macosx-path-to-apk/app-debug.apk container-appium:/opt
Above command doesnot give me any error response, but if navigate to

opt$ 
docker@appium-test-machine:/opt$ ls -l
total 20
-rwxr-xr-x    1 root     root            51 Jul 19 18:33 bootlocal.sh
-rwxr-xr-x    1 root     root          2383 Dec 10  2017 bootscript.sh
-rwxr-xr-x    1 root     root           286 Jan  5  2017 bootsync.sh
-rwxr-xr-x    1 root     root           137 Jan  5  2017 shutdown.sh
-rw-rw-r--    1 root     staff           31 Jul 19 18:33 tcemirror

I am not finding my apk file there. Is this expected ?

Running the container

Do we need to run docker run --privileged -d -p 4723:4723 -v /dev/bus/usb:/dev/bus/usb --name container-appium appium/appium every time before starting the automation ?

Device offline

Hallo! When I try to connect a device, I fail, and the device changes the port. While I can not understand the reason, the version of the container with the earlier version works fine.

appium/appium:latest
root@928b6be7f7ae:~# adb connect 34.148.34.58:7437
failed to authenticate to 34.148.54.28:7437

root@928b6be7f7ae:~# adb devices
List of devices attached
34.148.54.28::7437 offline

Adb server freeze when run test in parallel in Docker for Mac + USB 2.0 controller

I just start this topic when you start one docker-machine with multiple appium-docker-android containers , and run test in parallel

I found adb server will freeze just after several run when u start test in multiple containers. However I cannot figure out the reason...

I'd like to know whether you guys maybe also found this problem.

PS: when u run test only in ONE container, it works perfect.

Need Info - Why to use this and its benefits

Can you please add details about merits of using this over existing approach ?

e.g. In case of web automation, with Docker approach one can create in house grid setup on single powerful box to run test cases in parallel mode.

Similar clarification can be helpful.

Android real device๏ผšapp need permission๏ผˆlike locationใ€carmeraใ€root... ๏ผ‰ every times for running not only frist-run

The problem
desired_caps['noreset']=True
desired_caps['appPackage']=''
desired_caps['appActivity']=
"
I got configure the script like this,also grant the permission like location or root or carmera with hand operation after frist running app.
But,it always need permission when run app for second or third or more times

Environment
1ใ€Android mobile๏ผšMi 8
2ใ€Appium Docker for Android

Details
My confused
1ใ€Whatever app have to request the system permission every times for appium automation test with real device๏ผŸ๏ผˆThe app was already installed in the device for hand operation๏ผ‰
2ใ€If the answer is โ€˜yesโ€™๏ผŒhow can i allow all the permission like rootใ€locationใ€call... with using webdriver Element localization

RequestError: Error: socket hang up at new RequestError (/usr/lib/node_modules/appium/node_modules/request-promise-core/lib/errors.js:14:15)

## Adding the NodeSource signing key to your keyring...

+ curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
Warning: apt-key output should not be parsed (stdout is not a terminal)
OK

## Creating apt sources list file for the NodeSource Node.js 10.x repo...

+ echo 'deb https://deb.nodesource.com/node_10.x bionic main' > /etc/apt/sources.list.d/nodesource.list
+ echo 'deb-src https://deb.nodesource.com/node_10.x bionic main' >> /etc/apt/sources.list.d/nodesource.list

## Running `apt-get update` for you...

+ apt-get update
Get:1 https://deb.nodesource.com/node_10.x bionic InRelease [4584 B]
Hit:2 http://security.ubuntu.com/ubuntu bionic-security InRelease
Hit:3 http://archive.ubuntu.com/ubuntu bionic InRelease
Get:4 https://deb.nodesource.com/node_10.x bionic/main amd64 Packages [767 B]
Hit:5 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:6 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
Fetched 5351 B in 1s (3607 B/s)
Reading package lists...

## Run `sudo apt-get install -y nodejs` to install Node.js 10.x and npm
## You may also need development tools to build native addons:
     sudo apt-get install gcc g++ make
## To install the Yarn package manager, run:
     curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
     echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
     sudo apt-get update && sudo apt-get install yarn


debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libpython2.7-minimal:amd64.
(Reading database ... 27305 files and directories currently installed.)
Preparing to unpack .../0-libpython2.7-minimal_2.7.15~rc1-1ubuntu0.1_amd64.deb ...
Unpacking libpython2.7-minimal:amd64 (2.7.15~rc1-1ubuntu0.1) ...
Selecting previously unselected package python2.7-minimal.
Preparing to unpack .../1-python2.7-minimal_2.7.15~rc1-1ubuntu0.1_amd64.deb ...
Unpacking python2.7-minimal (2.7.15~rc1-1ubuntu0.1) ...
Selecting previously unselected package python-minimal.
Preparing to unpack .../2-python-minimal_2.7.15~rc1-1_amd64.deb ...
Unpacking python-minimal (2.7.15~rc1-1) ...
Selecting previously unselected package libpython2.7-stdlib:amd64.
Preparing to unpack .../3-libpython2.7-stdlib_2.7.15~rc1-1ubuntu0.1_amd64.deb ...
Unpacking libpython2.7-stdlib:amd64 (2.7.15~rc1-1ubuntu0.1) ...
Selecting previously unselected package python2.7.
Preparing to unpack .../4-python2.7_2.7.15~rc1-1ubuntu0.1_amd64.deb ...
Unpacking python2.7 (2.7.15~rc1-1ubuntu0.1) ...
Selecting previously unselected package libpython-stdlib:amd64.
Preparing to unpack .../5-libpython-stdlib_2.7.15~rc1-1_amd64.deb ...
Unpacking libpython-stdlib:amd64 (2.7.15~rc1-1) ...
Setting up libpython2.7-minimal:amd64 (2.7.15~rc1-1ubuntu0.1) ...
Setting up python2.7-minimal (2.7.15~rc1-1ubuntu0.1) ...
Setting up python-minimal (2.7.15~rc1-1) ...
Selecting previously unselected package python.
(Reading database ... 28053 files and directories currently installed.)
Preparing to unpack .../python_2.7.15~rc1-1_amd64.deb ...
Unpacking python (2.7.15~rc1-1) ...
Selecting previously unselected package nodejs.
Preparing to unpack .../nodejs_10.15.3-1nodesource1_amd64.deb ...
Unpacking nodejs (10.15.3-1nodesource1) ...
Processing triggers for mime-support (3.60ubuntu1) ...
Setting up nodejs (10.15.3-1nodesource1) ...
Setting up libpython2.7-stdlib:amd64 (2.7.15~rc1-1ubuntu0.1) ...
Setting up python2.7 (2.7.15~rc1-1ubuntu0.1) ...
Setting up libpython-stdlib:amd64 (2.7.15~rc1-1) ...
Setting up python (2.7.15~rc1-1) ...
npm WARN deprecated [email protected]: Moved to appium-android-driver
npm WARN deprecated [email protected]: Moved to io.appium.settings
npm WARN deprecated [email protected]: Moved to io.appium.settings
npm WARN deprecated [email protected]: core-js@<2.6.5 is no longer maintained. Please, upgrade to core-js@3 or at least to actual
version of core-js@2.
npm WARN deprecated [email protected]: Moved to appium-android-bootstrap
npm WARN deprecated [email protected]: cross-spawn no longer requires a build toolchain, use it instead
/usr/bin/appium -> /usr/lib/node_modules/appium/build/lib/main.js

> [email protected] install /usr/lib/node_modules/appium/node_modules/appium-chromedriver
> node install-npm.js

info Chromedriver Install Installing Chromedriver version '2.37' for platform 'linux' and architecture '64'
info Chromedriver Install Opening temp file to write chromedriver_linux64 to...
info Chromedriver Install Downloading https://chromedriver.storage.googleapis.com/2.37/chromedriver_linux64.zip...
RequestError: Error: socket hang up
    at new RequestError (/usr/lib/node_modules/appium/node_modules/request-promise-core/lib/errors.js:14:15)
    at Request.plumbing.callback (/usr/lib/node_modules/appium/node_modules/request-promise-core/lib/plumbing.js:87:29)
    at Request.RP$callback [as _callback] (/usr/lib/node_modules/appium/node_modules/request-promise-core/lib/plumbing.js:46:31)
    at self.callback (/usr/lib/node_modules/appium/node_modules/request/request.js:185:22)
    at Request.emit (events.js:189:13)
    at Request.onRequestError (/usr/lib/node_modules/appium/node_modules/request/request.js:881:8)
    at ClientRequest.emit (events.js:189:13)
    at TLSSocket.socketOnEnd (_http_client.js:426:9)
    at TLSSocket.emit (events.js:194:15)
    at endReadableNT (_stream_readable.js:1125:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/appium/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node install-npm.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-04-05T01_26_12_153Z-debug.log
The command '/bin/sh -c curl -sL https://deb.nodesource.com/setup_10.x | bash &&     apt-get -qqy install nodejs &&     npm install -g appium@${APPIUM_VERSION} --unsafe-perm=true --allow-root &&     exit 0 &&     npm cache clean &&     apt-get remove --purge -y npm &&     apt-get autoremove --purge -y &&     rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* &&     apt-get clean'
returned a non-zero code: 1
PS D:\Documents\code\docker\appium\appium-docker-android>

Cannot run adb command

docker-machine --version

0.11.0

Create docker

docker-machine create --driver vmwarefusion appium-test-machine

Get appium/appium

docker@appium-test-machine:~$ docker run --privileged -d -p 4723:4723  -v /dev/bus/usb:/dev/bus/usb --name container-appium appium/appium
Unable to find image 'appium/appium:latest' locally
latest: Pulling from appium/appium
bd97b43c27e3: Pull complete 
6960dc1aba18: Pull complete 
2b61829b0db5: Pull complete 
1f88dc826b14: Pull complete 
73b3859b1e43: Pull complete 
6c8edd7bef99: Pull complete 
92bcf1dd83d3: Pull complete 
fd1899cf6bd3: Pull complete 
52a115f9495b: Pull complete 
3ec5d10ba228: Pull complete 
d537468e7c38: Pull complete 
4ef145e4c267: Pull complete 
a6b1588c78cf: Pull complete 
Digest: sha256:4dfb8854f1df95d3090ba8b7fb3eb4e07ee06878f2c8ec0e5778de3fe7f426a6
Status: Downloaded newer image for appium/appium:latest
c30d10172588807e3c28587a5e770d5d9aaa4b01160173369e695424d0ecd859
docker@appium-test-machine:~$ docker exec -it container-appium bash "adb"
/root/platform-tools/adb: /root/platform-tools/adb: cannot execute binary file

Could u have a look why I cannot execute adb? Is it because I use VMFusion?

Error start session: Appium 1.9.0 + docker container

The problem

Hi! I wanna perform my test in parallel at some devices with docker. I launched docker container, which sees only 1 necessary device. But when I try to create appium driver I receive "[GET http://localhost:8200/wd/hub/status] with no body" error.

Environment

Appium version Appium v1.9.1
Desktop OS/version used to run Appium: 16.04.1-Ubuntu
Node.js version: 6.4.1
Mobile platform/version under test: Android 7.0
Real device or emulator/simulator: Real device
Docker container: docker pull appium/appium (with updated appium and node.js)
https://hub.docker.com/r/appium/appium/
Link to Appium logs

https://gist.github.com/aikuznetsov/50abddf6dfc0ea9a04fdb5a704c66f05

Code To Reproduce Issue [ Good To Have ]

Start docker container: docker run --rm -d --device /dev/bus/usb/003/075:/dev/bus/usb/003/075 -v ~/.android:/root/.android --name device1 appium/appium

Attempt to create driver:
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", deviceID);
capabilities.setCapability("model", "SM_A310F");
capabilities.setCapability("udid", deviceID);
capabilities.setCapability("automationName", "uiautomator2");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "7.0");
capabilities.setCapability("newCommandTimeout", "0");
capabilities.setCapability("appPackage", HOTSPOTSHIELD);
capabilities.setCapability("appActivity", HSS_MAIN_ACTIVITY);

use the adb from anther container

The appium is running in container-appium
docker run --privileged -d -p 4723:4723 -v /dev/bus/usb:/dev/bus/usb --name container-appium appium/appium

I understand it will start an adb server in the container,
however is it possible to use the adb outside of this container for example use the adb server running in the physic machine(ubuntu 18.04)?

Question, Connect Each Device to a Separate Container

Hi,
I have connect 3 devices to the host.
But unfortunately, i didn't success to find the devices when i ssh to the container, just find the first device.

May it related to the command:
$ docker run -d -p 4723:4723 --device /dev/bus/usb/XXX/YYY:/dev/bus/usb/XXX/YYY -v ~/.android:/root/.android --name device1 appium/appium

What is the XXX/YYY ? can anyone help me ?
How i can recognize the local USB to share it with the docker ?

Here is my usb connected devices to the virtual box:
screen shot 2018-07-01 at 12 10 32 pm

Thanks,

Device Not Shown

I tried to execute command : docker exec -it container-appium adb devices and it doesn't show up any devices
docker@appium-test-machine:~$ docker exec -it container-appium adb devices
List of devices attached

It only shows List of devices attached and nothing else.
Can you please help how can it would be available.?

Move bats installation and test scripts outside of final docker image

I propose to remove bats installation and copying of tests directory inside container in favor of adding bats as submodule in repo and only mounting tests dir instead of copying it permanently.
While it doesn't add much difference megabyte wise, it does keep Dockerfile and container a little bit cleaner and without only integration test specific stuff. WDYT? @SrinivasanTarget @butomo1989

Not finding my android device

hi,
please take a look at my docker compose file:

`
appium-android:
image: appium/appium
privileged: true
container_name: appium
volumes:
- /Volumes:/dev/bus/usb
- ./app/1media.apk:/app/1media.apk
- ~/.android:/root/.android
ports:
- 4723:4723

java-maven:
image: iamranit/appiumdockertest:3.0.0
container_name: appiumdockertest
volumes:
- /Users/ranit/Downloads/Result:/test-output/

command: ptest -p config.ini -t test-ui
links:
- appium-android:localhost

`

with this when I am running the docker compose file , everything is working properly except its not finding my android device. Error wile running:

Starting appium ... done Starting appiumdockertest ... done Attaching to appium, appiumdockertest appium | [Appium] Appium support for versions of node < 8 has been deprecated and will be removed in a future version. Please upgrade! appium | [Appium] Welcome to Appium v1.8.1 appium | [Appium] Non-default server args: appium | [Appium] log: /var/log/appium.log appium | [Appium] Appium REST http interface listener started on 0.0.0.0:4723 appium | [HTTP] --> POST /wd/hub/session appium | [HTTP] {"capabilities":{"alwaysMatch":{"appium:deviceName":"Android","appium:app":"/app/1media.apk","appium:autoGrantPermissions":"true","platformName":"Android","appium:automationName":"uiautomator2"},"firstMatch":[{}]},"desiredCapabilities":{"deviceName":"Android","app":"/app/1media.apk","platformName":"Android","automationName":"uiautomator2","autoGrantPermissions":"true"}} appium | [debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{"deviceName":"Android","app":"/app/1media.apk","platformName":"Android","automationName":"uiautomator2","autoGrantPermissions":"true"},null,{"alwaysMatch":{"appium:deviceName":"Android","appium:app":"/app/1media.apk","appium:autoGrantPermissions":"true","platformName":"Android","appium:automationName":"uiautomator2"},"firstMatch":[{}]}] appium | [debug] [BaseDriver] Event 'newSessionRequested' logged at 1534157095987 (03:44:55 GMT-0700 (PDT)) appium | [Appium] Creating new AndroidUiautomator2Driver (v1.12.0) session appium | [Appium] Capabilities: appium | [Appium] platformName: Android appium | [Appium] deviceName: Android appium | [Appium] app: /app/1media.apk appium | [Appium] autoGrantPermissions: true appium | [Appium] automationName: uiautomator2 appium | [debug] [BaseDriver] W3C capabilities {"alwaysMatch":{"platformNa... and MJSONWP desired capabilities [object Object] were provided appium | [debug] [BaseDriver] Creating session with W3C capabilities: {"alwaysMatch":{"platformNa... appium | [BaseDriver] Boolean capability passed in as string. Functionality may be compromised. appium | [BaseDriver] Capability 'autoGrantPermissions' changed from string to boolean. This may cause unexpected behavior appium | [BaseDriver] Session created with session id: dd90abaa-e9ba-4411-9e54-a33b9aaa2ac9 appium | [BaseDriver] Using local app '/app/1media.apk' appium | [debug] [UiAutomator2] Checking whether app is actually present appium | [debug] [AndroidDriver] Getting Java version appium | [AndroidDriver] Java version is: 1.8.0_171 appium | [ADB] Checking whether adb is present appium | [ADB] Found 1 'build-tools' folders under '/root' (newest first): appium | [ADB] /root/build-tools/28.0.0 appium | [ADB] Using adb from /root/platform-tools/adb appium | [AndroidDriver] Retrieving device list appium | [debug] [ADB] Trying to find a connected android device appium | [debug] [ADB] Getting connected devices... appium | [debug] [ADB] 0 device(s) connected appium | [debug] [ADB] Could not find devices, restarting adb server... appium | [debug] [ADB] Restarting adb appium | [debug] [ADB] Killing adb server on port 5037 appium | [debug] [ADB] Getting connected devices... appium | [debug] [ADB] 0 device(s) connected appium | [debug] [ADB] Could not find devices, restarting adb server... appium | [debug] [ADB] Restarting adb appium | [debug] [ADB] Killing adb server on port 5037 appium | [debug] [ADB] Getting connected devices... appium | [debug] [ADB] 0 device(s) connected appium | [debug] [ADB] Could not find devices, restarting adb server... appium | [debug] [ADB] Restarting adb appium | [debug] [ADB] Killing adb server on port 5037 appium | [debug] [ADB] Getting connected devices... appium | [debug] [ADB] 0 device(s) connected appium | [debug] [ADB] Could not find devices, restarting adb server... appium | [debug] [ADB] Restarting adb appium | [debug] [ADB] Killing adb server on port 5037 appium | [debug] [ADB] Getting connected devices... appium | [debug] [ADB] 0 device(s) connected appium | [debug] [ADB] Could not find devices, restarting adb server... appium | [debug] [ADB] Restarting adb appium | [debug] [ADB] Killing adb server on port 5037 appium | [debug] [ADB] Getting connected devices... appium | [debug] [ADB] 0 device(s) connected appium | [debug] [ADB] Could not find devices, restarting adb server... appium | [debug] [ADB] Restarting adb appium | [debug] [ADB] Killing adb server on port 5037 appium | [debug] [ADB] Getting connected devices... appium | [debug] [ADB] 0 device(s) connected appium | [debug] [ADB] Could not find devices, restarting adb server... appium | [debug] [ADB] Restarting adb appium | [debug] [ADB] Killing adb server on port 5037 appium | [debug] [ADB] Could not find devices, restarting adb server... appium | [debug] [ADB] Restarting adb appium | [debug] [ADB] Killing adb server on port 5037 appium | [debug] [ADB] Could not find devices, restarting adb server... appium | [debug] [ADB] Restarting adb appium | [debug] [ADB] Killing adb server on port 5037 appium | [debug] [ADB] Could not find devices, restarting adb server... appium | [debug] [ADB] Restarting adb appium | [debug] [ADB] Killing adb server on port 5037 appium | [debug] [ADB] Could not find devices, restarting adb server... appium | [debug] [ADB] Restarting adb appium | [debug] [ADB] Killing adb server on port 5037 appium | [debug] [ADB] Could not find devices, restarting adb server... appium | [debug] [ADB] Restarting adb appium | [debug] [ADB] Killing adb server on port 5037 appium | [debug] [ADB] Could not find devices, restarting adb server... appium | [debug] [ADB] Restarting adb

any help?

[Question] Not able to run docker image step 9

Hello,

Everything until step8 worked smooth but it seems i cannot pass step 9.

I moved to docker image and get the ip:

docker@appium-test-machine:~$ docker inspect $(docker ps -q) | grep IPA
            "SecondaryIPAddresses": null,
            "IPAddress": "172.17.0.2",
                    "IPAMConfig": null,
                    "IPAddress": "172.17.0.2",
docker@appium-test-machine:~$  

But when i add it to my tests i cannot run my demo test:

        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Pixel2");
        capabilities.setCapability(MobileCapabilityType.APP, "/opt/sdk.apk");
        androidDriver = new AndroidDriver<MobileElement>(new URL("http://172.17.0.2:4723/wd/hub"), capabilities);
org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Original error: Failed to connect to /172.17.0.2:4723
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'Lucians-MacBook.local', ip: '172.16.118.39', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.2', java.version: '1.8.0_144'
Driver info: driver.version: AndroidDriver

What i am missing? until here works as expected.

Thank you in advance.

an X display is required for keycode conversions

Looks like xvfb is still needed when running tests with chromedriver even on real device. Here is the error I get:

[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"79836eb8083f234038177a3804fb0282","status":13,"value":{"message":"unknown error: an X display is required for keycode conversions, consider using Xvfb\n  (Session info: chrome=58.0.3029.83)\n  (Driver info: chromedriver=2.28.455506 (18f6627e265f442aeec9b6661a49fe819aeeea1f),platform=Linux 4.11.2-1-ARCH x86_64)"}}

The issue is mentioned here. I created a fix based on solution mentioned in linked issue, will add PR shortly.

Optimize the dockerFile

  • Reduce the Android API's to latest 4 or 5 version
  • Eliminate Ant
  • Install Node (probably latest) directly
  • PATH setup [Environment variable's]
  • Reduce image Size (Currently it is > 3GB)
  • Expose all port's

Unable to connect to 2 real devices

Hi,
Could you have a look.

I'm using your docker-compose file to start appium docker https://github.com/appium/appium-docker-android/blob/master/examples/docker-compose.yml.

I connect 2 real devices and I start the docker-compose file like this:
docker-compose up -d --scale appium_android_device=2
When I check the selenium grid server, one container receives 2 devices while the other receives no device.
When I run test, one container is crashed with this message:
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Android bootstrap socket crashed: Error: This socket has been ended by the other party

Please help me.

Thanks.

boot android emulator on container up

Currently booting the container does not bring up android emulator

[saikrisv@insaikrisv-2 Desktop ]$ docker exec -it d4ba0f64b861 bash
root@d4ba0f64b861:/opt/node# appium -v
1.6.3
root@d4ba0f64b861:/opt/node# adb devices
List of devices attached
* daemon not running. starting it now on port 5037 *
* daemon started successfully *

root@d4ba0f64b861:/opt/node# adb devices
List of devices attached

root@d4ba0f64b861:/opt/node#

Cannot figure out why it is unable to auto connect android device by air

Hey,

docker-machine version 0.11.0

Following command doesn't work:

docker run -d -t -i -e REMOTE_ADB=True -e ANDROID_DEVICES=172.16.101.218:5555 -e CONNECT_TO_GRID=True -e APPIUM_HOST="127.0.0.1" -e APPIUM_PORT=4723 -e SELENIUM_HOST="172.16.101.221" -e SELENIUM_PORT=4444 -p 4723:4723 --name container-appium appium/appium

Also I check the log of container by following command, I cannot see any logs print out by generate_config.sh

docker logs container-appium

But if I do following will works:

docker run -d -t -i -e CONNECT_TO_GRID=True -e APPIUM_HOST="127.0.0.1" -e APPIUM_PORT=4723 -e SELENIUM_HOST="172.16.101.221" -e SELENIUM_PORT=4444 -p 4723:4723 --name container-appium appium/appium
docker exec -it container-appium adb connect 172.16.101.218:5555

Failed to establish a new connection Error

I am getting MaxRetryError: HTTPConnectionPool(host='192.168.99.100', port=4723): Max retries exceeded with url: /wd/hub/session (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x106cdea90>: Failed to establish a new connection: [Errno 61] Connection refused',))
While running the my automation suite.

Run on the Windows OS

Hello,
Am completely new to the dockers when am trying to run dockers compose with the following yml file
`version: '2'

services:

Selenium hub

selenium_hub:
image: selenium/hub
ports:
- 4444:4444

Appium Docker Android

appium_android_device:
image: appium/appium
depends_on:
- selenium_hub
privileged: true
volumes:
- /dev/bus/usb:/dev/bus/usb
- ~/.android:/root/.android
environment:
- CONNECT_TO_GRID=true
- SELENIUM_HOST=selenium_hub
# Enable it for msite testing
#- BROWSER_NAME=chrome`

ERROR

ERROR: for appiumrequired_appium_android_device_1 Cannot create container for service appium_android_device: b'Mount denied:\nThe source path "\\dev\\bus\\usb:/dev/bus/usb"\nis not a valid Windows path'

ERROR: for appium_android_device Cannot create container for service appium_android_device: b'Mount denied:\nThe source path "\\dev\\bus\\usb:/dev/bus/usb"\nis not a valid Windows path'
ERROR: Encountered errors while bringing up the project.

Complete log

PS C:\Users\DELL\Desktop\Appium Required> docker-compose up -d
Starting appiumrequired_selenium_hub_1 ... done
Creating appiumrequired_appium_android_device_1 ... error

ERROR: for appiumrequired_appium_android_device_1 Cannot create container for service appium_android_device: b'Mount denied:\nThe source path "\\dev\\bus\\usb:/dev/bus/usb"\nis not a valid Windows path'

ERROR: for appium_android_device Cannot create container for service appium_android_device: b'Mount denied:\nThe source path "\\dev\\bus\\usb:/dev/bus/usb"\nis not a valid Windows path'
ERROR: Encountered errors while bringing up the project.

Unable to query screen elements

I am using the appium-docker-android tool to run my tests and when I am running them, I am not able to query for screen elements. It always fails during this portion. Is anyone else having similar issues?

running simple example to test appium docker

Hi ,
i am pretty new with dockers but working with appium a long time, what i am trying to do is to run appium through docker with usb , i install what i needed with your code (create a hub on selenium grid and node with node js , in ports 4444 and 4723 as usual) , i create java project that contain the creation of the instance , here is a snippet of the code :

public static void main(String[] args) throws MalformedURLException {

    DesiredCapabilities capabilities = new DesiredCapabilities();

    capabilities.setCapability("deviceName","Android");
    capabilities.setCapability("app","app-debug.apk");
    capabilities.setCapability("platformName","Android");
    capabilities.setCapability("platformVersion","5.0");
    capabilities.setCapability("appWaitPackage","com.***.****");   
    capabilities.setCapability("appWaitActivity","com.***.***.***.****");

    AndroidDriver driver = new AndroidDriver<MobileElement>(new 
                                                                    URL("http://127.17.0.3:4723/wd/hub"),capabilities);
}

i create a new docker that run the java jar that created after compile the project

FROM java:8
EXPOSE 8080
ADD /target/test-1.0-SNAPSHOT.jar test-1.0-SNAPSHOT.jar
ADD /target/lib/ /lib/
ADD app-debug.apk app-debug.apk
ENTRYPOINT ["java","-jar","test-1.0-SNAPSHOT.jar"]

when i running the code with expose to the port 8080 , i get connect refuse .. can you advise ?

Exception in thread "main" org.openqa.selenium.WebDriverException: org.apache.http.conn.HttpHostConnectException: Connect to 127.17.0.3:4723 [/127.17.0.3] failed: Connection refused: connect
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info host: '4bb330d0f54c' , ip: '172.17.0.3 , os.name: 'Linux' , os.arch: 'amd64' , os.version: '4.4.104-boot2docker' , java.version: '1.8.0._111'
Driver info: driver.version: AndroidDriver
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:177)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:250)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:137)
at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:38)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:88)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:112)
at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:73)
at main.main(main.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to 127.17.0.3:4723 [/127.17.0.3] failed: Connection refused: connect
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:159)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:359)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:139)
at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:87)
at io.appium.java_client.remote.AppiumProtocolHandShake.createSession(AppiumProtocolHandShake.java:114)
at io.appium.java_client.remote.AppiumProtocolHandShake.createSession(AppiumProtocolHandShake.java:76)
at io.appium.java_client.remote.AppiumCommandExecutor.doExecute(AppiumCommandExecutor.java:111)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:162)
... 17 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:75)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
... 32 more

Need info

Why do we mount - "~/.android:/root/.android". I was wondering what's actually happening here, I am a bit unsure of its use. The container seems to perfectly run my tests without it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.