Manage and run automated tests
An IDE made for testing
CLI & continuous integration support
Automated test scope modeling and maintenance
Resource-aware, intelligent scheduling

Integrated reporting and issue tracking
Verify complex test data

Manage and run automated tests
An IDE made for testing
CLI & continuous integration support
Automated test scope modeling and maintenance
Resource-aware, intelligent scheduling

Integrated reporting and issue tracking
Verify complex test data

Manage and run automated tests
An IDE made for testing
CLI & continuous integration support
Automated test scope modeling and maintenance
Resource-aware, intelligent scheduling

Integrated reporting and issue tracking
Verify complex test data

Hand over the testing to QiTASC
Services tailored to your project

Project and feature-specific training
Personalized support from our experts

Hand over the testing to QiTASC
Services tailored to your project

Project and feature-specific training
Personalized support from our experts

Hand over the testing to QiTASC
Services tailored to your project

Project and feature-specific training
Personalized support from our experts
Test your systems and software
Verify server-side functionality
Verify charging Systems
Test network behavior and functionality
Life-cycle and migration testing
Ensure IFRS compliance standards
Automate & test smart devices
Ensure that data is transmitted correctly
Test your systems and software
Verify server-side functionality
Verify charging Systems
Test network behavior and functionality
Life-cycle and migration testing
Ensure IFRS compliance standards
Automate & test smart devices
Ensure that data is transmitted correctly
Test your systems and software
Verify server-side functionality
Verify charging Systems
Test network behavior and functionality
Life-cycle and migration testing
Ensure IFRS compliance standards
Automate & test smart devices
Ensure that data is transmitted correctly

Access all QiTASC manuals & tutorials

QiTASC articles & videos
QiTASC research material

Access all QiTASC manuals & tutorials

QiTASC articles & videos
QiTASC research material

Access all QiTASC manuals & tutorials

QiTASC articles & videos
QiTASC research material

Meet QiTASC's teams and the management
Learn about what drives our research and development

View our current openings
Contact & Impressum

Meet QiTASC's teams and the management
Learn about what drives our research and development

View our current openings
Contact & Impressum

Meet QiTASC's teams and the management
Learn about what drives our research and development

View our current openings
Contact & Impressum

intaQt Apptest Tutorial

QiTASC's documentation team is creating new tutorials to help users get comfortable using intaQt's features.

Apptest Tutorial - Introduction

This tutorial will teach you how to run an Apptest with intaQt Studio. Please read below for software requirements and install all of the specified QiTASC products along with the Appium Desktop App.

For reference material, please refer to the intaQt manual’s UI Steps chapter.

Required QiTASC Products

The following products must be installed using the QiTASC Cockpit in order to execute Apptests:

  • intaQt (with Android SDK)
  • intaQt Studio
  • appium

For installation instructions, please refer to the manual’s intaQt Installation section.

Additionally, Java and Android environment variables must be set for the Appium Desktop app to work. If you have not already configured these, you can find instructions in our manual’s section, Set Environment Variables.

Appium Desktop App Installation

The Appium Desktop app lets you find an app’s UI elements, including XPaths, which you can then use to automate tests in intaQt Studio. Download the most current version here. After installing the software, you will find this icon on your desktop:

alt text

Phone & App Setup

The following section provides information about setting up your phone and installing an application to test on it.

Connect Your Phone

Connect an Android phone via USB port to your PC. The phone must allow USB Debugging, which can be enabled in the Developer Options menu. Your phone may show a dialog asking if you trust the computer it is connected to as a debugger. Check the box to “remember” your choice and confirm Yes.

Download an App to Test

This tutorial will demonstrate how to test an app using the Selendroid Test App as an example. Download it here.

If you want to try out other apps, the Appendix contains additional information about how to get an app’s APK onto the PC for testing with Appium.

Install the App on Your Phone

If the Selendroid Test App is not yet on your phone, you can install it with adb install <path-to-apk>. For example:

Windows Users

adb install selendroid-test-app-0.10.0.apk



Linux and Mac OS Users

adb install Users/yourUserName/selendroid-test-app-0.10.0.apk

Now that you have installed the required applications and connected an Android phone to your PC, we’ll create a project and directory structure in intaQt Studio.

Create an intaQt Project

To execute an Apptest, you first need to run the following products:

  • intaQt
  • intaQt Studio

The easiest way to do this is to open a Command Line/Terminal session and navigate to the QiTASC directory.

The enter the following:

Windows Users

qitasc start intaqt
qitasc start intaqt-studio

Linux and Mac OS Users

./qitasc start intaqt
./qitasc start intaqt-studio

Run intaQt Studio

After launching the three products, intaQt Studio will start. First, select Create New Project.

alt text

The following view will appear. Select intaQt and click the Next button.

alt text

Next, name your project FirstAppTest and click Finish.

alt text

An empty intaQt Studio will appear – a Connected icon should be visible in the bottom right corner:

alt text

Create Resources Directory

Create a directory to store your APK file in. Although this is not necessary, we recommend this type of structure to help keep your Apptest projects organized.

First, right-click on the project name FirstAppTest on the left side of the window. Select New -> Directory. Name the new directory resources. Then, create a subdirectory by right-clicking on the resources folder and again selecting New -> Directory. Name this one apks.

alt text

Add APKs to the Resources Directory

Drag and drop the Selendroid Test App apk into the newly-created apks folder in intaQt Studio:

alt text

Now that you have created a new intaQt project and imported your app’s APK file, we’ll move on to using Appium Desktop to get the UI elements you need to test.

Configure Appium to Recognize the App

Addressing an app’s UI element is crucial to Apptest. We’ll use the Appium Desktop App to get this information. Open Appium. If this is your first time using it, the application may take some time to load. Once the following window appears, click the Start Server button.

alt text

A new window will appear. Click the magnifying glass in the upper right corner of the top bar to start your session:

alt text

The window is for configuring your phone and the Selendroid app for the Appium Session. Click on the + button to add each new field:

alt text

Add the following configurations:

Name Value
platformName Android
deviceName AndroidPhone
automationName uiautomator2
app <APK filepath> (see below)
appWaitActivity <foreground activity after startup (see below>)

Find the app value:

  • Return to intaQt Studio and right-click the APK file that you previously imported into the resources/apks folder.
  • Select Copy Path.
  • Paste the path into the app value field.

alt text

Find the appWaitActivity value:

  • Start the Selendroid Test app.
  • Open up a Command Prompt/Terminal session and enter the following command:
adb shell dumpsys window

Now, let’s use the Command Prompt/Terminal search function to find mCurrentFocus:

alt text

The entire string is:

mCurrentFocus=Window{eb0d905 u0 io.selendroid.testapp/io.selendroid.testapp.HomeScreenActivity}

However, we are only interested in the Activity described. Copy the following from the Command Prompt/Terminal:

io.selendroid.testapp.HomeScreenActivity

Return to Appium and paste the string into the appWaitActivity value field. When you’re finished, your Appium configuration window should look like this:

alt text

Save the configuration so that you can use it later:

alt text

Next, click the Start Session button:

alt text

The session may take a couple of minutes to start, but subsequent starts will be faster. If you encounter an error, such as an incorrect path or name, a message will pop up on the configuration page. The Server log window, in the background window, will contain more details.

Once the session has fully started, a window showing the Selendroid Test App will appear:

alt text

Next we will use Appium Desktop to find the XPaths that we need to build our intaQt Studio test case.

Find the XPaths

After configuring your Appium session, you can start using it to find the addresses of UI elements in the Selendroid app.

Determine the Element’s XPath

The app that we’re using contains a UI element that allows the user to enter text. Let’s assume that we want to use intaQt to automate this action. First, we need to address the input field.

Using Appium Desktop, move your mouse over the Selendroid Test App text field and click it. Some XML will appear in Appium’s middle section, and the right-hand section contains a table of attributes as well as three Find By criteria, which can be used to address the element.

alt text

We’ll use the element’s XPath: //android.widget.EditText[@content-desc="my_text_fieldCD"].

Verify the XPath

Alternately, you can use the search function to find which element an XPath belongs to. Click the magnifier glass at the top of the Appium Desktop window and select XPath from the Locator Strategy drop-down menu:

alt text

Enter the XPath from above and click Search.

alt text

Appium Desktop returns one element for this search term. The element will also appear highlighted on the left-hand side of the window.

alt text

Searching for a less-specific XPath may result in a list of matching elements XPath. For example, the Selendroid Test App uses six buttons – if we write an XPath expression like //android.widget.Button without specifying any other attribute, Appium will give us the following result:

alt text

Now that you’ve gained some insight into using Appium Desktop to find UI elements, we’ll go back to intaQt Studio and put together our test case.

We can also use an index if we want to select a specific Element from the list without expression a specific condition about it. For example, //android.widget.Button[2]. This will allow us in intaQt to iterate through a list of elements on the screen - but this is an advanced topic.

Create the Test Case

So far we have downloaded the required application, created a project in intaQt Studio and configured the Appium Desktop app to find XPaths from the Selendroid Test App.

Now that we’re back in intaQt Studio, we need a simple Appium configuration file. Right click on your project’s name, which is on the left side of the window. Select New and then File. Name the file Appium.conf and enter the configuration properties, which are the same that we used when configuring the Appium Desktop app:

Appium {
    isActive = true
    apps = [
        {
            name="io.selendroid.testapp",
            path="resources/apks/selendroid-test-app-0.10.0.apk",
            	capabilities	{
            	appWaitActivity	=	"io.selendroid.testapp.HomeScreenActivity"
            	automationName	=	"uiautomator2"
            }
        }
    ]
}

Note: The isActive parameter must be set to true in order to enable tests running Appium. This tells intaQt to start the Appium Server when running the test case.

Create the Feature File

Create a directory called Features by again right-clicking on the project name and selecting Directory. Then right-click on the Features directory, select New -> Feature. Name the file entertext and the Scenario Enter text and press 2nd button. A Feature File template will appear:

alt text

Write the Test - Get a Phone

First, we’ll write a step under the # Prerequisites section that tells intaQt we need a phone:

Given an Android phone as A

Write the Test - Open the App

Next, we need to open the app on the phone. On a second line, write the following step:

And open app io.selendroid.testapp on A

Note: The app name io.selendroid.testapp must match the string that we defined for the name configuration in the Appium.conf file (see above).

Write the Test - Enter Text into the Input Field

Under the # Execution section write a step that tells intaQt to type text into the app:

Then on A, enter "some text" into the input field

This tells intaQt that we want to interact with phone A. You will notice that the text is red: this is because it isn’t recognized by intaQt. In that case, we need to create a custom step – a Stepdef – for it.

Write the Test - Create a Stepdef

Custom steps are stored in separate files. Create another directory called stepdefs. Right-click on the folder, select New -> UI Steps. Enter testapp_stepdefs as the name. This will create a file called testapp_stepdefs.ui, which tells intaQt that it is a file that uses the UI Steps language.

The following Stepdef template will appear:

alt text

Edit the Stepdef’s first line so that it matches the step we’ve used in the Feature File:

stepdef "enter {} into the input field" / text /
end

The stepdef takes one parameter called text. This will allow us to specify any text that we want in the Feature File.

Go back to the Feature File where you have already used the step. You will notice, that although we have now a definition for this step, it will still be highlighted red. We need one last configuration to solve this. Create a new empty file in the project root directory called Glue.conf and paste the following in it:

Glue {
    path = ["stepdefs"]
}

This configuration tells intaQt to look in the stepdefs directory to find our custom Stepdefs. If you return to the Feature File, you will see that the step is now white.

Write the Test - Create the View

We will now write a View to select the Selendroid Test App’s input field. Underneath your Stepdef, write the following:

view InputFieldView
	elem inputField := "//*[@resource-id='io.selendroid.testapp:id/my_text_field']"
end

This View contains the following:

  • We have named the View InputFieldView
  • InputFieldView contains a UI element indicated by the keyword elem and assigned the name inputField.
  • A := is written next to inputField, followed by its XPath address, which we found using the Appium Desktop App.

Note: A best practice is to make a screenshot of the phone’s screen showing the screen with the elements you’ve described in the View:

  • Save this screenshot in a file that has the same name as the View (here it would be InputFiledView.png).
  • It is easy to understand the code later if you have an image of how the phone’s screen looks that you can compare against the XPaths described in your .ui files.
  • The screenshot can be taken directly from the Appium Desktop App window. Crop it to the phone’s screen.

Important! The double quotes within the XPath must be replaced with single quotes as shown above, while the entire XPath is enclosed in double quotes.

Write the Test - Use the Stepdef to Address the View

Next we’ll add a line that lets our Stepdef wait for the View to appear:

stepdef "enter {} into the input field" / text /
	await InputFieldView
end

This only makes the Stepdef wait for the View, but it does not yet interact with it. The next step is to add a View action that works with our element, inputField. Add a line to InputFieldView and expand the View to the following:

view InputFieldView
	elem inputField := "//*[@resource-id='io.selendroid.testapp:id/my_text_field']"
	action (inputField) enterText := type
end

This new line defines an Action towards the inputField:

  • Actions are indicated by an action keyword.
  • Next to the action keyword, specify the element that we want to address within brackets: (inputField). This tells intaQt that the action we define will interact with that element.
  • We have named the action enterText.
  • A := is written next to enterText followed by type, which is one of the built-in actions that you can use in UI Steps.

Note: To see a list of supported Actions, suggestions for action types, type CTRL-SPACE.

Write the Test - Modify the Stepdef

Revise your stepdef to the following:

stepdef "enter {} into the input field" / text /
    v := await InputFieldView
    v.enterText(text)
end

Now we are assigning the View to a variable, v:

  • The View found by the await statement will be written into this variable.
  • On the next line, we perform the Action we defined, enterText on the View.
  • This action takes a single parameter, (text), which we specified in the first row of the stepdef.

Close Appium Desktop App

Important! Before proceeding to the next step, make sure that you have closed the Appium Desktop App. Otherwise, you will have two Appium Servers running at the same time (in the Desktop App and by intaQt Studio), which can interfere with test case execution.

End the Appium Desktop session, then click the || sign in the black log output window’s upper right corner. Next, click the X and close everything until you see the Start Server button that appears after launching Appium Desktop.

Run the Feature File

After closing the Appium Desktop app, return to your Feature File in intaQt Studio. Click the green Run button located on the top right side of the window:

alt text

Alternately, right click on the Feature File and select Run 'entertext.feature'. Your Feature File and directory structure should look like the example below, and there should be no red text or warnings, such as for typos or undefined steps:

alt text

As the text is executing, you will see the Selendroid Test App launch on your phone and "some text" will be entered into the field.

To finish off this tutorial, we’ll add one additional step that pushes a button after entering the text.

Write the Feature File - Add the “Press Button” Step

This final step adds a button-pressing action as well as a wait statement. Update your Feature File so that it contains the new steps:

Feature: entertext

  Scenario: Enter Text and press 2nd button

      # Prerequisites
    Given an Android phone as A
    And open app io.selendroid.testapp on A

    # Execution
    Then on A, enter "some text" into the input field
    And on A, press the second button

      # Verification
    And wait for 5 seconds

Next you will need to do two additional tasks:

  • Update the View so that it contains the additional Element (the second button in the Selendroid App) and the Action performed on it (a click).
  • Create a new Stepdef that defines the press the second button step from the Feature File and links it to the View.

You will need to return to the Appium Desktop app to find the button’s XPath. Remember to close Appium before executing your updated test case.

If you have trouble finding the correct XPath or run into any errors, compare your test case with our Stepdef below.

Stepdef Example

stepdef "enter {} into the input field" / text /
    v := await InputFieldView
    v.enterText(text)
end

stepdef "press the second button"
    v := await InputFieldView
    v.pressButton()
end

view InputFieldView
    elem inputField := "//*[@resource-id='io.selendroid.testapp:id/my_text_field']"
    elem button := "//android.widget.Button[2]"
    action (inputField) enterText := type
    action (button) pressButton := click
end

Conclusion

This tutorial has introduced you to intaQt’s Apptest, where we created a test case that first enters text into the Selendroid Test App and then presses a button.

First we showed how to set up a project with a recommended directory structure. Next we demonstrated the Appium Desktop app’s features that help you locate an application’s XPaths. We then used these XPaths to construct our test cases in intaQt Studio using the UI Steps language to describe the Views and by writing a Feature File to execute the steps.

If you would like to create an Apptest using a different app, this tutorial’s Appendix explains how to download other apps and get their APK onto your computer. Additional, the intaQt manual’s UI Steps chapter contains further reference material to help construct Views.

Appendix: Find an APK and Install the App

If you would like to execute Apptests using a different app the following instructions show you how to find the APK for this app. For example, an app that you download from the Play store or one that is already on your phone. Once again, we’ll use the Selendroid Test App as an example.

Find the APK

Once you have installed the app, get its APK file (also called a “package”). To do so, use the adb tool, which comes with the Android SDK. Open a Command Line/Terminal session and enter the following:

adb shell pm list packages

The output displays a long list of packages installed on your phone. Search for io.selendroid.testapp, which is the app we will be using: selendroid is the name of the provider and testapp is the app’s name. When searching for other packages, they follow a similar provider/app name format.

Note: If the adb commands do not work, it may be because you did not Set the Environment Variables. Information on this topic can be obtained in our online Manual.

Get APK onto Your PC

Once you have the app’s name, find its location on the phone by entering the following command into the Command Line/Terminal:

adb shell pm path io.selendroid.testapp

Copy the returned path and enter the following, replacing <path-to-apk> with the copied path:

adb pull <path-to-apk>

This will create a file named “base.apk” in the directory where you have issued the command from. It is wise to rename the file to the package name and include also some version information in the name as you might test a newer version of it later in your project.