6.0+16
Testing Android applications (Preview)
16.1
Preconditions and known restrictions
16.1.1
Preconditions

In order to perform Android tests, the following preconditions need to be fulfilled for the machine QF-Test is running on:

  • A physical machine with enough power (not an old scrap mill :-)). It might be even necessary to enable hardware acceleration (typical via the bios) if the emulator works too slow. Further details can be found at https://developer.android.com/studio/run/emulator-acceleration.
  • Android SDK command line tools need to be available on your machine, even better an installation of Android Studio as described later.
  • Either a real Android mobile device needs to be connected via USB cable and USB debugging need to be enabled for this device (instructions follow),
  • Or an Android emulator needs to be installed, running an adequate Android Virtual Device (AVD) (instructions see below).
  • The Android API Level of the real or virtual Android device needs to be greater or equal 24, which means Android Version Nougat or later. (See also following table.)
16.1.2
List of supported Android versions
NameVersion No.Release dateAPI Level
Nougat7.0 - 7.1.2August 22, 201624 - 25
Oreo8.0 - 8.1August 21, 201726 - 27
Pie9August 6, 201828
Android 1010September 3, 201929
Android 1111September 8, 202030
Table 16.1:  Supported Android versions
16.1.3
Known restrictions

Note There are some restrictions within this preview version listed below:

  • Toast components are not supported yet.
  • No automatic scrolling for getting outside components shown on the screen to allow easy access.
16.2
Installing Android Studio for emulator and virtual devices (AVD)
16.3
Connecting to a real Android device

To use a real Android device for testing it needs to have USB debugging enabled and connected to the machine via USB cable.

Also an Android SDK is required on your machine. Even though it may be sufficient to just install a dedicated package for the Android SDK command line tools we strongly recommend install the full Android Studio as described in section 16.2

Enable USB debugging

Please activate USB debugging for your real device. Typically following steps are necessary:

  1. Navigate to "Setings" -> "About 'Device'".
  2. Click seven times at Build-Number, then "Settings" -> "Developer options" will get visible
  3. There activate the option "USB debugging"

The reference documentation how to activate USB debugging can be found at https://developer.android.com/studio/debug/dev-options.

Connect to PC via USB cable

  • After connecting the Android device to the PC, you may be asked on the device whether to allow USB debugging from this PC and whether to allow this permanently. You need to confirm this.
16.4
Create a QF-Test setup sequence for Android testing
  • As always when creating a setup sequence, open the "Quickstart Wizard" via the "Extras" menu or the toolbar button.
  • Select "An Android application".

    Figure 16.8:  Quickstart wizard screen to select the application type
16.4.1
Usage of an Android emulator
16.4.2
Usage of an Android real device via USB
16.5
Record actions and checks for Android
  • Please press on the Record Button to see what is going to happen for Android testing in QF-Test.
  • A special recording windows will open showing the content of either the emulator or the real device. This special window is necessary, as it is currently not possible to directly capture events from the emulator or real device. So you need to capture actions and checks via this special window.
  • It offers buttons for resizing the content area. Please also note that the content area just shows an image of the device screen. It needs to be updated manually by using the refresh button. There is also an auto refresh tooblar toggle button on the most right.

    Figure 16.20:  QF-Test Android recording window
  • Now you can try and record and also replay actions or checks. It may feel a bit clumsy in the beginning, but you will get used to the recording window soon.
  • Despite these Android recording specifics, QF-Test should work and behave as with any other GUI Technology, except for the known restrictions described in subsection 16.1.3.
  • Goodies:

    The recording window also has some goodies to mention. In the bottom line left it shows the mouse coordinates, which may become handy if you need to work with absolute mouse clicks. On the right, it indicates the type of the last highlighted component.

    There is a toolbar button on the recording window to open a hierarchy spy window displaying all visible components including the size and coordinates. This is more to help tracking down issues with component recording and recognision issues, but may become handy here and there.

    Figure 16.21:  Android hirarchy spy window
16.6
Android utility procedures

There are a number of Android utility procedures available in the standard library and are located in respecitive "android" package.

Some are similar to those avaialbe for other UI technologies but some are very specific for mobile testing e.g. for performing guestures or swipe actions, scrolling and setting of a certain component status.

Figure 16.22:  Android utility procedures