Hi,
We are trying to create Appium test script for mobile GUI testing, and I am facing a problem that no instruction to guide us on how to start the Appium service before the test execution.
Currently, we are starting the Appium service manually in another terminal session before execute the Appium test of CodeceptJS, for example:
Terminal 1:
$ appium
[Appium] Welcome to Appium v1.20.2
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
^C[Appium] Received SIGINT - shutting down
[debug] [Appium] There are no active sessions for cleanup
[HTTP] Waiting until the server is closed
[HTTP] Received server close event
Terminal 2:
$ npm run codeceptjs
…
Is there any solution for starting the Appium service automatically before test?
We use dockerized Appium, for tests of native Android app and also mobile Chrome. When you build and run the docker container, it will be started again once you reboot your machine.
Dockerfile:
# Appium server for mobile tests
# Build image: 'docker-compose build --no-cache'
# Start container: 'docker-compose up -d'
# Ubuntu 20.04 LTS
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN=true
# Install prerequisities
RUN apt-get update && apt-get -qqy install \
curl \
ca-certificates \
openjdk-11-jre-headless \
# Next packages are needed for ChromeDriver to be working
libglib2.0-0 \
libx11-xcb1
# Install NodeJS
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN apt-get install -qqy nodejs
# Install Appium server
# ChromeDriver version must be compatible with Chrome version installed in emulator
# See the compatibility table at https://raw.githubusercontent.com/appium/appium-chromedriver/master/config/mapping.json
RUN npm install -g appium@1.15 --chromedriver_version="90.0.4430.24" --unsafe-perm=true --allow-root
# Set ANDROID and JAVA env
ENV ANDROID_HOME=/Android_Sdk
ENV JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64
# Appium port
EXPOSE 4723
CMD appium --log-timestamp
docker-compose.yml:
version: "3.7"
services:
appium:
image: at/appium
container_name: appium
build:
context: .
volumes:
- $HOME/Android/Sdk:/Android_Sdk
restart: always
network_mode: host # So that ADB docker's client can connect to ADB host's server
# https://dustinoprea.com/2018/12/05/use-adb-to-connect-to-your-android-device-from-a-docker-container/
Thanks for your reply, it’s not inconvenient when developing the test script in the local working machine.
If CodeceptJS provide the Appium tick off solution such as WebDriverIO, it is less cost for the not strong skill programming skill of QA.
And I also will try your solution as we are running deploy the dockerization during CI process.