[WebUI] Analyze Test Case Execution Logs and Resolve Errors
After executing a Test Case, Katalon Studio provides users with comprehensive execution logs in the Log Viewer. Users can investigate the logs to troubleshoot and pinpoint the root causes of any issue quickly.
This tutorial shows you how to analyze execution logs of a failed Test Case in the Log Viewer and resolve the error.
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, and correct the step.
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 users 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.
Resolve the error in the Test Case
After finding the root cause, we navigate the Test Object with incorrect XPath and update the Object Locator.
Follow these steps:
Navigate to the Test Object. In the log message of the failed step, click on the displayed Object ID.
Here Katalon Studio navigates to the Test Object with the deprecated Object Locator.
Update the Object Locator.
Because a change in the AUT causes the error, we can update the Object Locator by re-recording the Test Case with the Web Recorder.
After re-recording the Test Case, verify that the Test Object is updated.
Here the Object Locator is updated with new properties and XPath.
Run the Test Case and verify the successful Test execution in the Log Viewer.