TESTAR and Appium for Mobile Systems - TESTARtool/TESTAR_dev GitHub Wiki
Local architecture
Appium is an open-source test automation framework that extracts the information of mobile system elements and sends commands to interact with them. TESTAR integrates the java-client plugin of Appium in order to implement the AndroidDriver to test Android mobile systems and the IOSDriver to test iOS mobile systems.
Preparing a mobile emulator
Unlike Desktop and Web applications, for mobile applications, it is necessary to prepare an environment that allows us to run the desired system under test. Users can connect a real mobile device to a computer or prepare different Android or iOS virtual emulators. We recommend starting with the official Android Studio IDE.
Android Studio contains the Android Virtual Device (AVD) feature, which allows specifying the Android version and hardware characteristics to launch a simulated device. Once you have configured an AVD, you will be able to run a simulated mobile on your host computer.
Installing Appium
You can install Appium on your computer using the NPM package manager.
-
Install NodeJS and NPM: NodeJS is a run-time environment software that allows to execution of programs written in JavaScript. And Node Package Manager (NPM) is an application and repository for developing and sharing JavaScript projects and their code (like Appium). Since NPM is included by default in NodeJS, what you need is to download and install NodeJS in your system
-
Install Appium with npm: Once NPM is installed in your system, you can install the Appium project by opening a command prompt and typing:
npm i -g appium@next
After the installation, verify you are using some Appium version 2.0.0 by typing:
appium --version
- Install Appium uiautomator2 driver: Appium is already installed with NPM, but you also need to install a mobile driver to connect and interact with mobile environments. You can type the command:
appium driver install uiautomator2
Finally, to verify the driver installation, you can type:
appium driver list --installed
Running Appium
To verify Appium is installed correctly, you can launch the Appium server in a command prompt by executing:
appium --relaxed-security --session-override --base-path /wd/hub
For security reasons, Appium client sessions can not request feature enablement via capabilities. However, we use the --relaxed-security
parameter for local testing purposes to disable this security temporarily. The command --session-override
is used to re-run multiple test instances. Furthermore, we use the --base-path /wd/hub
to enable the path direction on which TESTAR requests the connection with Appium.
Running TESTAR with mobile applications
The user needs to configure the file ./settings/android_generic/DesiredCapabilities.json
to indicate to TESTAR:
- to which
deviceName
we want to connect (AVD name created). - the
platformName
that corresponds with the mobile platform (Android). - the
app
to test (local APK). - the
automationName
that corresponds with the Appium mobile driver (UiAutomator2). - the
appWaitActivity
to use a starting state to initialize the testing process.
Once the mobile device is ready, the Appium server initialized, and the DesiredCapabilities.json
configured, we can launch TESTAR to SPY mobile applications or to GENERATE test sequences.
Docker architecture
Deploy virtual mobile emulator and Appium
Following the budtmo/docker-android project, we provide a docker-compose-android.yml file that allows to deploy and connect Docker containers to deploy a virtual mobile emulator and Appium as a remote service.
- INFO: Running the Android emulator requires a Linux Host with KVM enabled
- RUN:
docker-compose -f docker-compose-android.yml up
You can connect to port 6080 through the browser (on which these Docker services are deployed) to check that the mobile emulator and the Appium server are running.
Running TESTAR with dockerized mobile applications
In case of running the emulator and Appium inside docker containers, the user needs to configure the file ./settings/android_generic/DesiredCapabilitiesDockerEmulator.json
to indicate to TESTAR:
- to which
deviceName
we want to connect (Docker emulator name created). - the
platformName
that corresponds with the mobile platform (Android). - the
app
to test (remote raw APK link that allows Appium to connect and download the application). - the
automationName
that corresponds with the Appium mobile driver (UiAutomator2). - the
appWaitActivity
to use a starting state to initialize the testing process. - the
isEmulatorDocker
flag to indicate TESTAR we expect a remote docker container. - the
ipAddressAppium
to remotely connect with the IP address of the Appium docker container.
Once the docker containers with the device emulator and Appium are running and the DesiredCapabilitiesDockerEmulator.json
is configured, we can modify the SUT connector value and launch TESTAR SPY or GENERATE modes.