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.
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
-
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
-
- 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"]
- 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 } } }
- 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
-
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. -
Configure Device Set: Then, configure the Device Set to tell Botium on which devices you want to run your tests on.
- Go to
Botium Tools & Settings > Settings > Browser & Device Cloud > Device Sets
, click the NEW button to configure your device set.
- 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
- 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.
- Go to