[WebUI] Analyze test execution logs and debug the test case in Katalon Studio
After executing a test case, Katalon Studio provides you with comprehensive execution logs in the Log Viewer. You can quickly investigate the logs to pinpoint the root causes of any issue and correct the test execution with Debug utilities.
This tutorial shows you how to analyze execution logs of a failed test case in the Log Viewer and debug the test case.
Here we reuse the test case ("Sign in the shopping page to purchase a tank top") from the tutorial [WebUI] Create and Run Web UI Test Case using Record and Playback.
- You can download the sample project here: Shopping Cart Tests.
In our example, the test case fails to find a Web element due to an unexpected change in the application under test (AUT). We look for the failed steps in the execution logs, find the root cause, correct the step, and resume execution using the Run from here Debug utility.
- To use the Debug utility, you need to configure Katalon Studio to not terminate browser session when execution finishes. For detailed instructions, refer to this guide: Execute and Debug a Test Case.
Analyze test execution logs in Log Viewer
After executing the test case, Katalon Studio displays the results in the Log Viewer as follows:
Here we use the Tree View mode of the Log Viewer to analyze the logs. This mode displays execution logs in a structural way that helps you trace the Test execution and locate failed steps quickly.
Follow these steps to analyze the logs:
-
Switch to the Tree View. Toggle on the Tree View button on the top-right corner of the Log Viewer.
The Tree View displays the execution logs in a tree-like structure on the left pane. Each node in the tree corresponds to a step in the test case, and failed steps are marked in red.
On the right pane, the view displays detailed log messages of each step.
-
To view warning messages of the failed step, click on the expand icon on the left of the step.
Here the warnings indicate that Katalon Studio fails to find a test object with a specific XPath.
-
To view the detailed log message, click on the step. The log message is displayed on the right pane.
In the root cause section, the message shows an exception:
com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id ... not found.
To learn how to troubleshoot common exceptions in Web tests, you can refer to this document: Troubleshoot common exceptions when executing web tests.
Below the root cause section, the message displays the failed step in the form of test script.
From the details provided, we know that Katalon Studio cannot locate the sign-in button with the id
'Object Repository/Page_Zack Market/input_Password_button_btn__2lzmo'
and the Object Locator//*[@value = 'Signing_in']
.
- Execution logs of test cases are preserved only in the running session of Katalon Studio. Once you reload Katalon Studio, the logs will disappear.
Debug the test case
After finding the root cause, we update the test object with a new XPath, and use the Run from here Debug utility to resume the test execution.
Update the Object Locator
Because a deprecated Object Locator causes the error, we can find the new Object Locator using the browser's Inspector tool.
In our example, we use the Inspector tool to get the XPath of the corresponding Web element.
Follow these steps:
-
To get the new XPath, in the running browser instance, right-click on the target web element, and select Inspect.
Here we right-click on the Sign-in button that causes the error.
-
In the inspector window, the selected element is highlighted, indicating the target element's location in the HTML DOM. Right-click on the highlighted line and select Copy > Copy XPath.
-
Add the new XPath to the test object. Open the test object, in the test object view, specify XPath as the Selection Method and paste the copied XPath from step 2 in the Selected Locator editor.
Resume the test execution
After adding the new XPath to the test object, we use the Run from here Debug utility to resume test execution without re-executing the entire test case.
Follow these steps to resume the test execution:
-
Resume executing from the failed step. Open the test case, right-click on the failed step, and select Run from here > The running browser session.
-
After the test execution is completed, verify the results in the Log Viewer.
See also: View and Customize Execution Log.