Skip to main content

[WebUI] Analyze Test Execution Logs and Debug the Test Case

After executing a Test Case, Katalon Studio provides users with comprehensive execution logs in the Log Viewer. Users 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.

Note:

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.

Note:

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:

Test Execution overview

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:

  1. Switch to the Tree View. Toggle on the Tree View button on the top-right corner of the Log Viewer.

    Tree View button

    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.

    Tree View Structure

    On the right pane, the view displays detailed log messages of each step.

    Log Message Pane

  2. 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.

    Log Message Pane

  3. To view the detailed log message, click on the step. The log message is displayed on the right pane.

    Tree View Click on step

    In the root cause section, the message shows an exception: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id ... not found.

    Root cause section

    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.

    Error 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'].

Note:
  • 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:

  1. 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.

    Error Script

  2. 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.

    Error Script

  3. 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.

    Error Script

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:

  1. 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.

    Error Script

  2. After the Test execution is completed, verify the results in the Log Viewer.

    Error Script

See also: View and Customize Execution Log.