Tutorial On Web Testing with Katalon Studio
Katalon Studio is an integrated development environment (IDE) for automated test generation, where we can create, execute and view reports for our automated test. With both manual view and scripted view, Katalon Studio is suitable even when we have little programming experience.
With Katalon Studio, We can do the following:
- Web testing
- Mobile testing for Android and iOS
- API testing
- Desktop app testing
- Data-driven testing
- BDD testing
Web Testing with Katalon Studio
Step 1: Set up a project
In Katalon Studio, We can create a new project from scratch or from one of the sample projects we provided. Click on File > New > Project and select your preference. Then, enter the name of the new project and the location to store the project data.
Step 2: Create the first test case
Right-click on Test Cases > New > Test Case, Test cases in Katalon Studio can be written in pure Selenium format:
WebDriver driver = new ChromeDriver();String baseUrl = "https://www.katalon.com/";driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);driver.get("https://katalon-demo-curas.herokuapp.com");driver.findElement(By.id("btn-appointment")).click();driver.findElement(By.id("txt-username")).clear();driver.findElement(By.id("txt-username")).sendKeys("Diksha");driver.findElement(By.id("txt-password")).clear();driver.findElement(By.id("txt-password")).sendKeys("NotAPassword");driver.findElement(By.id("btn-login")).click();driver.quit();
Click Run to see how it works.
To simplify and speed up the process of writing test cases, especially in high volume, we can use Katalon Studio standard format. For example:
WebUI.openBrowser('https://katalon-demo.com/')WebUI.click(findTestObject('PageCURA Bodycare Service/a_Make Appointment'))WebUI.setText(findTestObject('PageCURA Bodycare Service/input_Username_username'), 'John Doe'WebUI.setEncryptedText(findTestObject('Page_CURA Bodycare Service/input_Password_password'), 'g3/DOGG74jC3Flrr3yH+3D/yKbOqqUNM')WebUI.click(findTestObject('Page_CURA Bodycare Services/button_Login'))
Click Run to see how it works. Next, we will go through the “ChromeDriver,” “click” and “findTestObject” methods, and how to use the “Page_CURA Bodycare Service/a_Make Appointment” argument to begin testing with Katalon Studio.
Browser drivers: The browser driver, i.e., ChromeDriver is abstracted away from the code and set up at the execution time so that the code is enabled for cross-browser testing.
Click and setText: This is an example of Katalon’s Studio’s open-source built-in keywords library to wrap and enhance the limited set of Selenium keywords. We can also create our own set of custom keywords or import the shared custom keywords made by other users.
Page_CURA BodyCare Service/ a_Make Appointment: Are the test objects designed to follow the Page Object Model pattern. Katalon Studio supports our test objects with the “auto-healing” feature to make them sustainable, despite the continuously changing nature of the AUT. The script and objects above can quickly be generated by the Recording and Spying
Katalon Studio can be used for both manual and automation testing. It provides a dual-script interface for both manual and automated tests
In practice, a team of testers and developers can apply these steps for their complete workflow:
Firstly, the automation experts will prepare scripts needed to build test cases such as the custom keywords, test listeners, calling test cases, etc.
Then, these prepared scripts will be transferred to the manual QAto utilize without handling a script.
As a result, the manual QAs can gradually learn how to script and become automation Tester.
Step 3. Verification in the test case
To get the result of the login process, we need to add the verification script to the test case.
As the fundamental of scripting in Katalon Studio for the first test case has explained, we can move on to another test case: “Make Appointment” header verification.
We can leverage Katalon Studio’s rich set of verification keywords to work on that requirement. this kind of script can be done in both Manual and Scripted mode.
WebUI.verifyElementText(findTestObject('Object Repository/Page_CURA Bodycare Service/h2_Make Appointment'),
'Make Appointment', FailureHandling.STOP_ON_FAILURE)
Step4. Debugging the test case
Try changing the verification text to “Make another Body Care Appointment.” to make the test case fail. Here are a few options of how you can check the reasons for failure in Katalon Studio:
Option 1: Investigate error logs
Option 2: Debug mode
For the complex case, Katalon Studio offers a debug mechanism that works similarly to the code debug mechanism in the advanced developer IDE.
Option 3: Manual debug
It is possible to use the recording feature of Katalon Studio for debugging. The Katalon Studio supports recording the failed test case, running the error test step for us to analyze and fix the issue directly in the recording mode.
Here’s an example:
When your test case failed, click “Yes, I do” in the window that will show up to continue recording the failed test cases.
Choose to Run all steps to run the error test steps. After that, we can investigate and fix that issue directly in the recording mode.
Read Also — Handling Shadow DOM in Selenium
Step 5: Plan the test cases in the test suite
Right-click Test Suite > New > Test Suite
To create test cases with multiple configurations (e.g., retrying on failure, email sending, or data-driven binding), use the test suite capability. The added configuration of a test suite execution can be managed by expanding the Execution Information section.
Step 6: Execute test suites and view the result
Select Test Suite > Run
The final step is to execute a test case in the designed test suites:
After being successfully planned, the test suites or test suite collections can be executed directly in Katalon Studio.
Originally published at https://www.devstringx.com on June 21, 2022