Working with Git in the Katalon studio

Git Overview

Git is a version control tool for tracking changes of files in working processes, which is commonly used in software development and among people in a project. Git now is integrated almost with IDE tools such as Eclipse, Android Studio, and also Katalon Studio. I prefer to use Git with command lines and in this article, I will introduce two ways of using Git, one is demo in Katalon studio and another is demo in command lines.

The basic Git workflow goes something like this:

  • You modify files in your working tree.
  • You stage the files, adding snapshots of them to your staging area.
  • You do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your Git directory.

If a particular version of a file is in the Git directory, it’s considered committed. If it has been modified and was added to the staging area, it is staged. And if it was changed since it was checked out but has not been staged, it is modified. You can see here for more detail.

To go further more, you create a repository on the stored server (Github, Bitbucket) as below:

Repository

Three states of files: committed, modified and staged

Git defines three states for your file: committed, modified and staged. Once your files has been committed, it was safely stored in your local database, so these files were not lost. Modified means you changed the file compared to the previous commit but these files was not saved in the local database, if there is a problem occurs, your code will be lost. Staged means that you have marked the current modified version of the file to be ready for the next commit.

Working tree, staging area, and Git directory

Working tree, staging area, and Git directory

The Git directory is where Git stores the metadata and object database for your project. This is the most important part of Git, and it is what is copied when you clone a repository from another computer.

Create a git directory by the command: C:\> Git init

Git init

 

The working tree stores all file in the repository

The working tree

The staging area – Git add

Git stores internal everything called index, which is a snapshot of the files in your project. After you create a repo, it is empty and the index of git is empty (even if the directory already contains some files and folders).You need stage the files from your working directory into the index by using the git add command

Not only need to add files to the index, but also work if you edit a file at the working tree then you have to add those changes to the index also using the git add command.

Git add

Note that the index is a snapshot of all the files in the project, not just a list of changed files.

Git commit

After adding the file to the index, you use git commit to get the content of the index and create a new commit. Commit is a purely local operation, it does not involve sending anything to a server on the network. It takes only the content of the index and saves a snapshot of the project as recorded in the index.

Git commit

Similar to index, a commit is a snapshot of all the files in the project. Each commit is assigned a unique identifier (this label is generated from the SHA-1 hash of the captured content).

Git – Commit name

Because of the unique identifier of the commit label, it allows us to derive exactly what we have in the project at the time of the commit.

Git push

Push the files in the latest commit to the server repository. Before do it, you need to specify the network URL then Git refer to and place the code there, using the git remote add command.

Then using git push -u origin master to push the code. Origin means above URL , master means your current branch of the working tree (we will discuss later about branch), -u parameters means we need to provide authentication in each push times.

Git push

After that, check the repository in the server to get result.

Git Integration in Katalon Studios

Katalon integrates Git into its IDE so you may not need to use the boring commands above to control the project version. Instead of the command line, you will operate on a friendly and simple GUI interface.

Enable Git

First, you need enable Git in the Katalon studio:

  • Go to Windows >> Katalon studio preferences
  • Expand Katalon >> Git
Katalon Enable Git

 

Clone the remote repository into local machine

Note: Make sure the local machine has not existed repository yet, if existed, please choose another directory.

  • Open Git on the task bar >> Select Clone project
  • Fill the URL and your bitbucket authentication
Git clone from the remote repository

 

  • Modify files, Add, Commit, and Push upto the server

As mentioned above, in order to push files to the remote server, you need to add them to the index and commit by open Git >> Commit.

Look at the interface: Unstaged Changes contains un-index files, you need to move them into Staged Changes section by drag and drop.

Unstaged > Staged

Next, you fill in the commit message, which is useful when you want to find commit via the meaning name. If you just want to commit the file in local and do not push your changed files to the remote server, select Commit button, otherwise select Commit and Push button.

 

Katalon will do something such as checking your authentication, provide branch to push the code. After complete pushing code, you can check the result at the remote server address as below:

Git branch
Pushing code done

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.

Katalon bugs

Installation Details: Spelling error at the “\\plugins” path

  • Go to Help > About
  • Click on Installation Details button
  • Check the folder path at “launcher.library” & “startup” as below

–launcher.library
D:\Katalon_Studio Windows_64-4.6\\plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.401.v20161122-1740\eclipse_1617.dll
-startup
D:\Katalon_Studio Windows_64-4.6\\plugins/org.eclipse.equinox.launcher_1.3.201.v20161025-1711.jar

Actual: The path is “D:\Katalon_Studio Windows_64-4.6\\plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.401.v20161122-1740\eclipse_1617.dll”

Expected: “D:\Katalon_Studio Windows_64-4.6\plugins\org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.401.v20161122-1740\eclipse_1617.dll”

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.

How to configure the email settings in Katalon

To configure the email settings in Katalon, we can do as the below steps:

Setup Mail Server Settings

Go to Project, click on Settings
At the “Project Settings” windows, click on Email to open the email settings – here’s the place that we can setup the outgoing mail in Katalon tool.

Host: The actual SMTP server’s specification, you can find it from the web page of your email provider, or searching it for details here

Port: SMTP port. Please check the email SMTP port here, for example with the Yahoo mail, the port should be 465

Username: The full email address

Password: The email password

Protocol: SSL

Click on OK button to finish and back to the main windows.

Setup the Mail recipients for Test suite

  • Double-click on the Test Suite
  • Click on Execution Information to expanding the options
  • Click on Add button and enter your email address (the report will send to this email)

Fixing Yahoo blocks the account access from Katalon

After we have completed to update the Email server settings and Mail recipients for the test suite, We need to allow account access from Katalon by turn on the Yahoo settings: Allow apps that use less secure sign in

  • Sign in to Yahoo Mail.
  • Go to your “Account security” settings.
  • Turn on Allow apps that use less secure sign in.

Read more about turn on this option here. Please googling and find out the way to do the same with other mail providers.

It’s done! run your test suite and check the results.

Katalon Installation & Execution

System Requirements

To go further Katalon Studio, you need to ensure the system requirements on Windows as below:

Operating System Windows 7, Windows 8, Windows 10, macOS 10.11+
CPU 1 GHz or faster 32-bit (x86) or 64-bit (x64) processor
Memory 1 GB RAM (32-bit) or 2 GB RAM (64-bit)
Hard Drive at least 1 GB available hard disk space


Setup Android on Windows

In order to fully run test on Windows OS, you need install Appnium, NodeJs and USB Debugging. Katalon support only Android on Windows OS.

Appium is an HTTP server written in Node.js which creates and handles multiple WebDriver sessions for different platforms like iOS and Android. Appium is part of the Node.js server, which allows automated testing on Android and iOS devices, including native and hybrid devices. One of the core tenets of Appium is that test codes can be written in any framework or language like Ruby on Rails, C# and Java without having to modify the apps for automation purposes. The interaction between node.js server and Selenium client libraries is what ultimately works together with the mobile application.

We need to enable USB debugging to run the .apk file on the emulator or real devices, from which we can inspect /capture the element for test script.

Install Node.js 

  • Download and install Node.js at here . Make sure you install Node.js into a location where you have full Read and Write permissions.

  • When installing Node.js, make sure that the Add to PATH option is checked. To make sure Node.js is installed correctly, open Windows command line and type the command below to see if system can find Node.js: C:\> where node


Install Appium

  • Open Command Prompt of Windows and input following command to install Appium: npm install -g  appium
  • Open Katalon Studio and go to the Windows > Katalon Studio Preferences > Katalon > Mobile settings. Set Appium Directory to the installed folder. By default, it’s usually installed at C:\Users\{your login account}\AppData\Roaming\npm\node_modules\appium.


Setup Devices

  • Install USB Driver for your phone, you can download it from the device manufacturer site. Note: If your Android phone is one of Google Nexus series, please skip this step because Android SDK already include the driver.
  • Turn on the phone developer mode (go to Settings -> Developer options).

  • Connect your Android device to the computer using USB cable. Just confirm if prompted for Accepting/Trusting the phone.

Test Execution

  • Launch Katalon Studio.
  • Open a test project.
  • Open/Create a test case or test suite.
  • Select the option to execute with the Android device from the Run button of the main toolbar. (This version of Katalon Studio for Windows OS support only supports Android devices).
  • Select your device from the Android Devices list. Click OK.

Note: If you don’t see any device in the list, check to see if the developer option of the phone is turned on (see Setup Device section above), then try to reconnect the device again until you are prompted for accepting/trusting the computer, and make sure you accept it.

You are done. Enjoy it!


References:

https://docs.katalon.com/display/KD/Mobile+on+Windows

http://toolsqa.com/mobile-automation/appium/download-and-install-nodejs/