Skip to content

Smartphone App Testing with Botium

Testing chatbots embedded into a Smartphone App is possible with the Botium Webdriver Connector - in fact, thanks to Appium it is technically and practically pretty much the same as testing a chatbot embedded into a website.

Note

This is not an Appium tutorial. If you never used Appium before, stop reading and build knowledge in Appium first.

Prerequisites

You need a working Appium endpoint connected to a real or emulated device. You can either

  • install Appium and all required things on your local workstation or server (see for example these instructions)

  • use a virtualized Appium + Android environment like this

  • or you can connect to a device cloud provider with Appium support (like Perfectolabs or Saucelabs)

Furthermore, for the Smartphone App under test, you have to know:

  • For Android, the appPackage name and appActivity name

Note

For following the steps below, you can use this chatbot app based on Alice.

Setup Steps

For testing a Smartphone App with Botium, you will have to find out about the internals of the App and tell Botium about the Appium element locators that are required for simulating a conversation with the chatbot:

  • where to enter the text to send to the chatbot and what button to click

  • where to look for the chatbot response

There are several tools available to do this, one of them is the Appium Desktop.

The view from the Smartphone app is mirrored, and you can interact with it. The elemenet attributes are shown as well. In this case, the locator for the text input box can be written like this:

//*[@resource-id="com.hariofspades.chatbot:id/et_message"]

A working botium.json will then look like this:

{
  "botium": {
    "Capabilities": {
      "PROJECTNAME": "WebdriverIO Appium Sample",
      "CONTAINERMODE": "webdriverio",
      "WAITFORBOTTIMEOUT": 60000,
      "CLEANUPTEMPDIR": false,
      "WEBDRIVERIO_OPTIONS": {
        "capabilities": {
          "platformName": "Android"
        },
        "port": 4723,
        "path": "/wd/hub"
      },
      "WEBDRIVERIO_APP": "https://github.com/Hariofspades/ChatBot/raw/master/app/hari-bot.apk",
      "WEBDRIVERIO_APPPACKAGE": "com.hariofspades.chatbot",
      "WEBDRIVERIO_APPACTIVITY": "com.hariofspades.chatbot.MainActivity",
      "WEBDRIVERIO_USE_APPIUM_PREFIX": "appium:",
      "WEBDRIVERIO_INPUT_ELEMENT": "//*[@resource-id=\"com.hariofspades.chatbot:id/et_message\"]",
      "WEBDRIVERIO_INPUT_ELEMENT_SENDBUTTON": "//*[@resource-id=\"com.hariofspades.chatbot:id/btn_send\"]",
      "WEBDRIVERIO_OUTPUT_ELEMENT": "//*[@resource-id=\"com.hariofspades.chatbot:id/chatMessageView\" and name(./*[1])=\"android.widget.ImageView\"]",
      "WEBDRIVERIO_OUTPUT_ELEMENT_TEXT": ".//*[@resource-id=\"com.hariofspades.chatbot:id/text\"]",
      "WEBDRIVERIO_OUTPUT_ELEMENT_HASH": "INDEX",
      "WEBDRIVERIO_IGNOREUPFRONTMESSAGES": true,
      "WEBDRIVERIO_OUTPUT_ELEMENT_DEBUG_HTML": false
    }
  }
}

Note

You can find the full sample on Github

In Botium Box, the configuration looks like this:

Device Sets and Test Execution

There is no different than for running Selenium-based web tests in Botium Box. First, configure the connection to an endpoint - Appium, Selenium Grid, or one of the supported device cloud providers.

Then, configure the Device Set to tell Botium on which devices you want to run your tests on.

Finally, use this device set in the Quickstart Wizard when configuring an E2E Testing project.

When running a test session, all test cases are executed on all of the devices of the device set, and the test results show additional information and screenshots.