Katalon supports three methods to create automated tests: Record and Playback, using keywords in the Manual Mode, and scripting in the Script Mode.
Record and Playback is a great solution to start for beginners and non-programmers. But to improve the test quality as time goes on, they should learn how to use the built-in keywords in the Manual Mode and ultimately get down to scripting to have more control over the test design.
This course will help you get started with the built-in keywords in Katalon.
In three chapters, you will learn about:
Hi and welcome to Katalon Academy! In this first chapter, we'll introduce the concept of keyword-driven testing and how you can implement it with Katalon. Let's start with the methodology! More businesses are applying test automation solutions to ensure software quality, especially when they have frequent releases. This isn't a trend anymore; it's the best practice.
To automate tests, writing and maintaining test scripts are among the most important and challenging tasks. These are normally taken care of by automation experts with sufficient programming experience. The pressure is always on creating new scripts to build up the automation system and increase the automated test coverage. So, the experts would always be busy writing scripts. On the other hand, manual testers, even though they have deeper product knowledge, are being left behind because they cannot write scripts efficiently. So, where can we find the balance in this situation?
That's when the method of keyword-driven testing, sometimes called action word-based testing, becomes extremely helpful since it separates the coding from the test design. A keyword-driven test comprises a sequence of keywords representing a user flow on an AUT. These keywords are mapped with corresponding functions written by the engineers with programming skills. The testers with better product understanding can then use the keywords to create automated test cases or test scripts.
Keywords and test data can be stored and maintained in a separate source like a spreadsheet. When a test is triggered to run, the test scripts will refer to this resource to read all the keywords, data, and run the corresponding functions. And since the keyword functions can be implemented separately, the two groups of programmers and testers can work more independently, boosting the whole team's productivity.
Keyword-driven testing is a great solution for automated testing implementation for teams with few programmers. But, building a keyword-based testing framework from scratch is not easy and time-consuming. Teams need to have an expert who has enough knowledge to plan the framework setup, implementation, management, and maintenance. Writing the keyword functions is another major concern since programming skills are required. The reality is that not every team has enough resources for this.
A common solution is to use a ready-made automation tool that includes pre-written keywords which the functions have already been built as a part of the tool. Testers can start using these keywords immediately to create automated test cases. This removes the requirement for an expert to build everything from scratch, saving time and resources.
With Katalon, users are equipped with a significant list of built-in keywords and other components (like the Page-object-model Repository and Web Spy for capturing test objects) to help you easily design tests and minimize maintenance. You can download Katalon Studio for free and start using it immediately. No heavy setup is required. For the benefits, the keyword implementation and complexity have already been handled by Katalon. Tests can be created and modified earlier, easy to read and understand even by non-programming people. Keywords can be reused consistently across many test cases. The maintenance becomes lighter. All the developed keywords are stored in one place. When you maintain or update a new keyword, all the tests using it will be automatically updated.
Using pre-built keywords is a great low-code solution to create automated tests. But what about Record and Playback? Should beginners keep using it, or should they switch to using keywords? As you know, Katalon also supports Record and Playback. It is probably the easiest way to automate tests, requiring no coding experience. It captures manual actions on an AUT and then converts them to a list of keywords in the Manual mode and test scripts in the Script Mode.
Frankly speaking, recorded tests are ideal to start with simple tests. But in the long-term, they are fragile, easy to break, when dealing with frequently-changing UI, dynamic elements, or complex test scenarios. If you have no clue how to use keywords to at least modify tests, they can easily break, or you can end up with a lot of duplicated codes by, for example, recording a bunch of tests for the same scenarios with different data inputs.
Record and playback is great for you to start and learn. But as time goes on, you should know how to use keywords and ultimately get down to scripting to have more control over test design. As you use keywords in the Manual mode, you can switch back and forth to the Script mode to get more familiar with the code. That's it for the first chapter. You've learned about the keyword-driven testing method and got an idea of how you can apply it with Katalon.
Welcome to chapter 2, where we'll show you how to use the built-in keywords in Katalon to verify a user flow of booking an appointment on our Healthcare website. Go to Katalon.com/download, register if required, download Katalon Studio for free, install, and follow along with this tutorial.
We'll create a new test case. Right-click on the Test case folder > New > Test case or simply click on the ''+'' button on the toolbar. Give it a name and click OK. When testing manually, we humans identify web elements with our naked eyes. We scroll, look for the elements, and then take action. Test automation, on the other hand, interacts with test objects programmatically. So, the first step we're gonna do is ''capturing'' the test objects.
In this course, we'll show you how to use the Spy Web utility. It's probably the easiest way for beginners to capture test objects since the locators will be generated automatically. Click on the Spy Web button on the toolbar. Input the URL. We'll use Katalon's healthcare service website. Pick the browser. I'll leave it as Chrome. Then, hit Start.
It will open the web page on a Chrome browser. As I point to an element, it will be highlighted with a red border. To capture an object, right-click on it, choose Capture Object, or you can use the keyboard shortcut shown in the upper left corner. I'm using a Mac so this combination doesn't apply for me. But I can create a new one. Click on Katalon Studio on the menu bar > Preferences > Katalon > Object Spy. Input the new shortcut (I will change it to Option + Q for demonstration).
Back to our web page, point to an element and press the keyboard shortcut. The Captured Objects section on the right shows that the object has been captured. Since Katalon's built-in repository follows the Page Object Model, the object will be automatically put under a folder of the web page where it belongs.
In the Object Properties section below, you can change the Object name. It's a best practice for you to use a consistent naming convention for all test objects so that you can find and maintain them more easily later. Some basic rules can be: A web element has a prefix that describes the type (a button, textbox, dropdown, etc.), the name should be identical to the content shown on the UI and written with Camel-case principles. For example, I rename this to ''btnMakeAppointment''.
Below is a list of locators that are automatically generated. The best option will be used as the default locator for the test object. In this case, it's the ID, as seen in the Selected Locator section. You can then click on Verify and Highlight to see whether the locator identifies the correct web element. All good!
Currently, Katalon supports 4 selection methods: Xpath, Attributes, CSS, and Image. Click on the Question mark to read more about them in the documentation. You can change the default locators (right now, it's Xpath) by going to Project > Settings > Test Design > WebUI. Here, you can also change the priority of the Xpath locators to be generated or add new attributes. To choose the best-fit method for your tests, you'll need to know the basics of web elements, which we'll discuss in detail in another course about working with test objects in Katalon.
In this course, we'll verify the user flow of booking an appointment. Let's continue capturing all the test objects needed for the test. After getting all the objects, click Save to store them. The Add element to Object Repository window appears. On the left are the objects to add, shown under the Page-Object structure. On the right is our existing repository. Since this is the first time we save test objects, it's all blank. Click on Save!
And that's how we capture test objects using Spy Web. Very easy and convenient, right? On the left, you can see all the objects saved and stored in the built-in Object Repository. For each object, there are a default locator and other alternatives. In case you wonder why the alternatives are also saved, it's for the Self-healing feature. When the default locator is broken, self-healing looks at these alternatives and uses a working one to identify the object. For more information on Self-healing, what it can do, and how it works, you can enroll in our Self-healing course later after this course.
In the next chapter, we will use the built-in keywords and the captured test objects to create a test for verifying the booking-an-appointment workflow. See you.
Welcome back! In the previous lesson, we learn how to use the Spy Web utility to capture all the necessary objects. Now, let's continue to use the built-in keywords to create an automated test to verify the workflow of booking an appointment on our healthcare website. On the left of the Test Explorer section, the second icon is the Keywords Browser. Here, it stores all the types of keywords, including built-in, custom, and utility. We'll focus on the first one in this lesson. I'll explain the others as we go on in this tutorial.
Double-click on a test case. It will open the Editor where we'll create the test steps in the Manual Mode. Following the web logic, I will break down our test into 2 parts: logging in and booking an appointment. In the first one, we'll need to open a browser, navigate to the website, fill in the username and password, and log in.
There are two ways to use the built-in keywords. You can open the Keywords Browser and navigate to the one you want to use. If you want to know more about a keyword (what it does and how to use it, for example), hover over it, the description will pop up. Click on the ''i'' icon to view more details and examples on the documentation. Simply drag the keyword into the Editor to use it.
Or you can press the Add button and type in the keyword. At step 2, we want to navigate to the healthcare website. As I'm typing ''navigate'', it automatically searches for related options and finally shows the Navigate to URL keyword I want. Press enter to use it. For this keyword, we need to provide the URL input. Double-click on the Input column. Keep the value type as String and paste the URL to our website.
According to the workflow, we'll need to click the Make Appointment button on the homepage to move on to the Login section. So, at step 3, we'll use the Click keyword and specify the object for such action. Double-click on the Object column. And choose the Make Appointment button we've captured in the previous lesson. Or, navigate to such button in the Object Repository on the left, and then drag it into the Object column at Step 3.
Next, to fill in the username, we'll use the Set Text keyword. Then, specify the object and the value input, just like what we did seconds ago. Do the same for the password as well. However, it's a common practice that we don't leave the password exposed like this. So, what we can do is encrypt it by using the keyword Set Encrypted Text instead of the normal Set Text. In the Input column, type in the sensitive data, and it will be automatically converted into a coded value.
Finally, we'll click the Login button. Everything looks good for the first part of the test. Let's run it to make sure everything works as expected. You can specify the browser to run by clicking on the dropdown icon next to the Run button. I'll go with the default Chrome option. Alright, logged in successfully! We can now move on to the second part, where we'll fill in all the information to book an appointment.
At step 7, we'll need to select an option of Healthcare center from a dropdown. We can use the keyword Select Option By Index or Select Option by Value. I will go with the former to keep things simple. Specify the dropdown... and then specify the option to select in the Input column. If you choose 0, it will choose the first option of Tokyo center. But I want to choose the second option of Hong Kong center for the facility. So, I input ''1''. The remaining steps are quite similar. We can create them in no time with the Click and Set Text keywords.
After hitting the Make an Appointment button, we need an element to verify the booking is successful. I will use the Verify Element Present keyword and the heading text ''Appointment Confirmation'' for verification. I can further configure the timeout for this step in the Input column. Finally, close the browser. We have successfully created a test using the built-in keywords. I'll configure the delay between actions in the Project Settings so we can see each step more clearly. Let's run the test to see if it works as expected.
One thing to note is that you can also configure the failure handling. By default, all test steps are set to stop the test if they fail. But you can change the settings following this path and choose the option of Continue on Failure for your test project. You can also override the settings for each step by right-clicking on it, going to Change failure handling, and choosing the Continue on failure option. If this step fails, Katalon will still go on and run the next step if possible.
Our test execution is done and passed. That's how we use the built-in keywords to create an automated test in Manual Mode. You can switch to the Script Mode to learn how the code is written behind the keywords and get more familiar with the scripting. The next lesson will show you how to add statements as test steps to handle a more complex scenario. See you.
Welcome to the last lesson of chapter 2. In the previous lesson, you've learned how to use the built-in keywords to create a basic automated test to verify the user flow of booking an appointment. But what if I want to verify this user flow with 3 different inputs of Healthcare Program: Medicare, Medicaid, and None?
One easy way is to record 3 separate tests following the same flow, but each time we will choose a different healthcare program. Or you can just record one time, clone it and modify the step of choosing the healthcare program. This method can do the trick, but it is time-consuming and results in duplicated codes. There are many much better ways. But in this course, I will use the statements in the Keywords Browser to demonstrate how you can use the Manual Mode to create more complex tests.
I will use the For Loop and If statements to make the test automatically book 3 times, each time with a different healthcare program. According to the web logic, you need to click on the Go to Homepage button if you want to book another appointment after finishing booking one. So, let's add another step before closing the browser.
Next, I will use the statement For Loop to re-run the registering steps after logging in. Click on the dropdown icon next to the Add button and choose For Loop statement. Again, you can read more about the usage and how-to by going to the documentation. Then, click on the Input column to set the number of loops, the variable is ''Index,'' I will change it to ''n''. I want to loop 2 times, so let's change the range to 0 and 2.
Now, all the steps below are currently not in the loop. Click the Script Mode, you can see they are not in the brackets. Simply select all the steps and drag them into the For Loop statement. I will continue to use the If - Else if - Else statements to specify choosing the Medicare option for the first run, Medicaid for the second run, and None for the last. Click on the dropdown icon next to the Add button. Go to Decision-making statements > If statement. Next, add a condition in the Input column. Choose Binary as the value type. Click on the Value column, change the first expression to Variable and change the value to ''n''. Then, change the second expression to 0. Click OK.
Add the step to run if the condition is met. Switch to the Script Mode so we can have a better view. If n=0, the first run, then it will click on the option of Medicare program. We can continue to do the same for the two loops in the Manual Mode. Or just do it in the Script Mode, which is easier for me. Copy and paste the statement and modify the conditions and the following actions to pick the Medicaid and None options for the first and second loops, respectively.
If you go back to the Manual Mode, the steps have been added accordingly to our new codes. I will add the Delay commands to help us see the new test steps better. All good! Let's run this test. It runs for the first time and chooses Medicare. Now, it re-runs the registering steps due to the For Loop statement and chooses Medicaid. Lastly, it re-run the steps for the last time, chooses the None option, and then closes the browser.
Our test is finished. Looking at the Log Viewer, you will see step 7 is the Loop statement. At steps 7.3, 7.4, and 7.5, it took action according to the conditions we provided. Using built-in keywords in the Manual Mode gives you more control over your test design. And it's easy to use since all keywords and commands have already been developed by the Katalon team. In the last chapter, we will walk you through the custom keywords, why and how you should create them. See you.
Well done! Just a few more minutes until you finish this course. In this last chapter, we'll explain the custom keywords and how you can create and use them. The Keyword Browser covers most of the basic actions for your team's needs. But sometimes, you need to perform custom actions that are not included here. In such cases, you can create custom keywords so they can be reused by all the team members.
In other cases, you would want to gather multiple actions into one custom keyword. Let's have an example of the application login. To create a custom keyword, right-click on the Keywords folder. You can also have an option to import the keywords from your local files or Git. But we want to create a new one, so let's choose New > Keyword. You can browse a package or create a new one to store your custom keywords. Type in the Class name. Below are the 3 options to generate the samples and templates for different types of tests. We'll skip them for now. Click OK.
Inside the Public class bracket, we'll write the function for our custom keyword. Start with ''def'' and follow by the function name. I name it ''App Login.'' In the round brackets, you can add the arguments. But we don't need that for now. In the curly brackets, we will write the codes for all the steps needed to log in to the web application. Fortunately, they have already been written in the previous lessons. I will simply copy and paste it here. And we are done with the functions.
But this is yet a custom keyword. If you open the Keyword Browser, you won't see any newly added keywords. We'll need to do one more step, adding ''@katalon'' above the ''def'' line. Then, click Save! You can go to the Katalon documentation > Katalon Studio > Extend Katalon Studio > Custom Keywords. You can see some keyword samples (the generate-sample options we saw earlier) and how the codes are written. Here we also write some keywords based on user requests. For example, to execute a test with the Internet Explorer mode in Microsoft Edge, or to set text in Flutter-based applications. You can follow the configuration instructions and copy the pre-written codes to create these keywords.
Alright, let's create another simple keyword, as an example, to print a message in the Console Log. Start with ''@keyword'', then ''def'' and the function name. I will provide an argument for this function by adding ''String User'' to the round brackets. Then write the print command and the message. Click Save!
Now, if we open the Keyword Browser again, we'll see the new keywords have been added to the Custom folder. Let's test them out. In our test case, I'll delete all the steps for logging in and use the new custom keyword App Login instead. Then, put the other one at the end. Let's run this test to see what will happen.
And it's done! The AppLogin keyword works fine. And at the end of the Console Log, you can see the message printed here. Congratulations! You've finished this course! To recap, you've learned the concept of Keyword-driven Testing and how Katalon supports this method, how to capture test objects and use the built-in keywords to create basic and more complex automated tests, why and how to create and use custom keywords. So, what's next? Go to Katalon.com/download, install Katalon Studio and try out the built-in keywords; if you have been using Record and Playback, itâs time to start using the keywords to design more complex tests.
The course was efficient and well structured.
the narrator voice is muffled by the background music in the videos.
NEXT COURSES TO LEARN