List of mobile built-in keywords

In this post, I will give several examples of Katalon mobile built-in keywords. You can also see Katalon docs for more details.

Katalon provides many libraries and built-in keywords, making it a flexible and powerful script, including group of libraries for Application operations, Device handles, Elements, Notifications, Screens, Text and so on.
The figure below depicts the names of the library groups:

List of mobile built-in keywords

Application

Start application and close are two actions indispensable in the script. Click on a test case and view in Script mode, then we add two line of code into the script as below:

Mobile.startApplication(‘path_of_apk_file’, true)

Mobile.closeApplication()

The path of apk such as: “E:\\Katalon\\Apk\\Uber.apk”, true option means to start the application and uninstall it after run.

Attributes

To get a specific attribute of a mobile element, you can use: Mobile.getAttribute() function.

  1. Double click on the object in Object Repository folder to see list of object attribute.
  2. Open a test case in Manual mode, right click >> Add >> Mobile Keyword.
  3. Select Get Attribute in Item column, select Object in Object column, specify name of attribute (eg: “text”)  as the first parameter in Input column.
  4. Run the test and view result in Console window.

Device

Provides some functions to operate in devices while running test, for example:

  • Get Current Orientation
  • Get Device Height/Width
  • Get Device OS/ OS version
  • Switch to Landscape/Portrait
  • Verify Is Landscape/Portrait
  • Unlock Screen

Notification

Katalon supports Open notification and Close notification on the current device as followings:

'Open any sudden notifications'
Mobile.openNotifications()
'Close any sudden notifications'
Mobile.closeNotifications()

Screen

You can also operate in the screen devices by Pinch to zoom out/zoom in, Swipe, Tap, Tap and Hold and so on.

Element

Provides functions to handle elements, for instance:

  • Hanle events: Drag And Drop, Tap & Hold, Check & Uncheck
  • Get Element Height/Width
  • Verify attributes
  • Wait for element present/visible

Utilities

This API allows you take the screenshots, delay, comment or verify checkpoint while running the script.

Record & Playback app on mobile

Katalon Studio is power tool for designing and execution test, it provide a very simple and way to create tests by record feature. This tool organize folders clearly by its function, for example: Test Cases folder, Test Suites folder, Object Repository folder, Data File and so on. Users can easily view project documentation and debugging.

In this post, we find out and do something cool with very simple mobile project: Sample Mobile App


Sample apk

Pure Apk is a website that stores large numbers of apk files, you can use any .apk file here for free. I will use Uber application, I think it will be fun.


Run Sample app

You can run test case on emulator or your real device, I highly recommend you use the BlueStack – a free app emulator tool and support many features. Download BlueStack at http://www.bluestacks.com/download.html. Once you have successfully installed, Katalon Studio will automatically find available emulators.

Blue Stack overview

Record & Replay the project

  1. Select File >> New Project, name it: “UberMobile”
  2. Open Test Cases >> New >> Test Case, name it: “TC01_OpenApp”
  3. Click on this test case then click on Record Mobile. In this step, make sure that the Appium server and BlueStack (or real devices) are already running.
  4. Click Start to record scripts, it takes several minutes to scan all objects. After Katalon load the hierarchical structure object, you click on the object and select available actions, the script will be generated automatically immediately, so you have completed the record and created the first script.
Start to Record Mobile app
Hierarchical Structure Object
Generated script

5. Playback: Click on above test case, select Run >> Android >> Select device to run.

6. Here is the test result

The Test Result

You can see more details in this video

Exporting the test suite report

Katalon supporting many types of report: HTML, CSV, PDF and JUnit in the new Version 4.7.

Open Report folder > Double-click on the test suite name and right-click on the result, select Export as

Export as HTML

Export as CSV

Export as PDF

Open containing folder

To user the report containing folder, right-click on the test result and select Open containing folder
It will show the report files as below.