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

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/