Skip to main content

Smartphone App Testing

Testing chatbots embedded into a Smartphone App is possible with the Botium Webdriver Connector.

In fact, thanks to Appium, testing a chatbot within a smartphone app is nearly identical to testing a chatbot embedded into a website.

For more information about the connector, see Botium Webdriver Connector.

Note: This is not an Appium tutorial. If you've 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

Setup Steps

Note: For following the steps here, you can use this chatbot app based on Alice.
  1. 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:
    1. where to enter the text to send to the chatbot and what button to click

    2. where to look for the chatbot response

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

  2. The view from the Smartphone app is mirrored, and you can interact with it. The element attributes are shown here 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"]

  3. A working botium.json will then look like this. You can find the full sample on Github:
    {
      "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
        }
      }
    }
  4. In Botium, the configuration looks like the following: Navigate to Botium Tools & Settings > Chatbot Connections > Your Chatbot Connection > Configuration > Connector Settings

Device Sets and Test Execution

The process for running smartphone app tests is the same process as running Selenium-based web tests in Botium.
  1. Configure Device Provider: Start by configuring the connection to an endpoint—whether it's Appium, Selenium Grid, or a supported device cloud provider. Go to Botium Tools & Settings > Settings > Browser & Device Cloud > Device Cloud Providers, click the NEW button to configure the connection.

  2. Configure Device Set: Then, configure the Device Set to tell Botium on which devices you want to run your tests on.
    1. Go to Botium Tools & Settings > Settings > Browser & Device Cloud > Device Sets, click the NEW button to configure your device set.

    2. After choosing your device provider during the configuration, use the Select or Add options in the lower left of the screen to fill out your Device Sets:

      Note: A Device Set in Botium is a group of web browser configurations for running test cases. The supported browsers depend on the chosen device provider and can vary by:
      • Operating systems (Windows, Linux, macOS, etc.)
      • Browser vendors (IE, Edge, Chrome, Safari, Firefox, etc.)
      • Device types (Desktop, Tablets, Smartphones)
      • Browser versions
    3. Finally, you can now use this device set in the Test Suite when configuring an E2E Testing project.
      Note: 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.

Was this article helpful?

0 out of 0 found this helpful