Do you think IIT Guwahati certified course can help you in your career?
No
Introduction
Hello Ninja, as a companion on your Katalon learning journey, We welcome you to another article from Katalon Studio. This article will help you understand the types of Variables and global variables in Katalon Studio.
We will discuss how to use different types of variables in Katalan Studio. Katalon Studio offers its users the facility to use different types of variables, like a global variable, to direct the execution flow.
Seems familiar, right? They work the same way as the variables in all programming languages. These statements can be added as test steps to test cases in the Manual view and Script view. Let's explore this in detail.
Let’s get started with Katalon first.
Katalon
Katalon Studio is an automated testing tool. Katalon Studio is used in Testing desktop, mobile, web, andAPIapplications. It also provides many tools and features that we can use.
It offers test data and execution results displayed through charts, graphs, and reports. Groovy, a Java-based language used by Katalon Studio, requires loading numerous libraries to parse test data, test objects, and logging.
It is an all-in-one testing automation solution for desktop, web, mobile, or API built for all kinds of testers.
Variables
A variable in programming are named memory locations which can store data that can change depending on the conditions or information passed to the program. A program is typically made up of instructions that tell the computer what to do.
Values that are obtained, also known as fixed values, are constant. Variables store values with a certain level of flexibility, even though they are frequently set to "0" or another default value because the app user will supply the actual values.
Constants and variables are standard components of several data types. Each data type restricts and defines its value.
Example
The string contains only words and sentences.
Int contains only integer values.
Types of Variables
The three types of variables that Katalon Studio supports are:
Test Case Variable.
Global Variable (Execution Profiles).
Groovy Variable.
Groovy Variables
It is one of the types of variables. Variables in Groovy can be defined in two ways: using the data type's native syntax or by using the def keyword.
String x
def y
var z
Here, the variable work usually works as in other programming languages. Groovy variables can be defined with Katalon Studio.
Example
/* var1 is defined as string type. */
String var1 = "This is a String variable in Groovy. ";
/* var2 is defined as an integer type. */
int var2 = 10;
/* The variables' values are displayed on the output. */
println(var1);
println(var2);
You can insert dynamic data into a test case using test case variables. Test case variables can be created and called in manual and scripted modes. Variables for test cases can also be used in a test suite.
Instead of running a test case with hard-coded values, you can use Katalon Studio's Test Case Variables to parameterize your test case or call that test case with different inputs.
Global Variables
A variable used across the project is referred to as a global variable in Katalon Studio. For instance, if you create a variable as a global, you can use it in any project test case.
A global variable is defined in the execution profile that can be used in a project's test case, test object, web service object, and email configuration.
Execution Profile
Execution Profile makes running your automation test scripts in various contexts simple. You can alter the testing environment's data and behavior through global variables.
Create a Profile
⚽You may perform CRUD operations (Create, Read, Update and Delete) in the Execution Profile in the Tests Explorer.
The content of a profile must be defined by adding Global variables. Do the following:
1️⃣ Select a profile > click Add.
2️⃣ Enter the variable's information in the New Variable window and then > click OK.
3️⃣ The variable is added > to the profile accordingly.
Now, let's focus on how we can view a profile.
View a Profile
The execution profile supports both the Manual view and the Script view. The Script view allows an XML editor to add variables through the script. You can create as many profiles as possible based on the project's needs.
⚽Profiles in the Script view are in sync once a similar group of global variables is required for testing multiple environment types.
⚽The variables list should be copied and pasted from one profile to another.
Set the Default Profile at the Project Level
A default profile is an area that includes commonly used global variables. Other profiles can either inherit or override the default profile's global variables.
👉Set as default Execution Profile by right-clicking on the desired execution profile.
👉This profile is the default execution profile for Test Case, Test Suite, and Test Suite Collection.
👉 If you use the Katalon Runtime Engine, it also applies to the Command Generator's Executive Platform.
Use a Profile
Using the default profile, Katalon Studio runs tests. The drop-down menu contains all available operation profiles.
The pictures below provides a usage example. The three profiles based on testing settings are local, staging, and production.
1️⃣Regarding test plans or test cases: All global variables within your current project instantly use these values when you choose your desired profile in the right corner.
2️⃣For the test suite library: On the Profile column, choose the desired profile to run together with your test suite.
3️⃣Select the desired profile: from the Profile field to run in Console Mode.
Credit: www.katalon.com
You can manually adjust the execution profile parameter on the generated command.
The three profiles based on testing settings are local, staging, and production. This is how we can use the profile for manual and script views.
Frequently Asked Questions
What are the applications of global variables?
It is possible to access global variables irrespective of their scope. Usually, variables not supplied as parameters have limited access to functions since they work within a local range.
What language does Katalon use?
Groovy, a Java-based language used by Katalon Studio, requires loading numerous libraries to parse test data, test objects, and logging.
Is Katalon studio free?
Katalon Studio has a free version with limited features. You can also try a 30-day free trial for the premium plan. If you want to download the Katalon studio, visit the official website of Katalon.
What is automated testing?
It is a process of double-checking software to ensure they meet strict requirements. Before software is put into production, automated testing is the process that verifies that it is working correctly and that the criteria are being met.
Does the user need to be very good at coding to use Katalon?
Katalon Studio provides a dual scripting interface where you can choose the interface according to the technical knowledge of the tester. It has a simple interface with no coding requirements.
Conclusion
In this article, we learned about the Types of Variables and global variables in Katalon Studio. Also, we have covered the Execution Profile.
Check Out these articles for a better understanding.