# Stack trace error replaces the verification result

**URL:** <https://forum.katalon.com/t/stack-trace-error-replaces-the-verification-result/20138>\
**Category:** Miscellaneous\
**Tags:** katalon-studio\
**Created:** [February 27, 2019, 8:17am UTC](https://forum.katalon.com/t/stack-trace-error-replaces-the-verification-result/20138 "2019-02-27T08:17:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eric\_Hung](https://avatars.discourse-cdn.com/v4/letter/e/34f0e0/32.png) [@Eric\_Hung](https://forum.katalon.com/u/Eric_Hung)\
**Post date:** [February 27, 2019, 8:17am UTC](https://forum.katalon.com/t/stack-trace-error-replaces-the-verification-result/20138/1 "2019-02-27T08:17:37Z")

</div>

When executing verification in loop the result of last verification will be influenced by the stack trace error to be FAILED.

> def expect = 1  
> for(def actual = 0; actual \< 5; actual++){  
> if(expect \< 4)  
> expect++  
> WebUI.comment(String.format(“actual = %d expect = %d”, actual, expect))  
> WebUI.verifyEqual(actual, expect, FailureHandling.CONTINUE\_ON\_FAILURE)  
> }

In the Log Viewer even though the last verification passed, the result is marked as failed on report.

 ![Screenshot%20(14)](https://europe1.discourse-cdn.com/katalon/original/2X/9/9ddb5cecd160ebd70e1002bf1f1f8bd81799028c.png)  
 ![Screenshot%20(12)](https://europe1.discourse-cdn.com/katalon/original/2X/6/6d6dab93942eba8b0cf677eece8bb2b58a9a054e.png)

Any ways to prevent this misleading result?

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [March 5, 2019, 8:45am UTC](https://forum.katalon.com/t/stack-trace-error-replaces-the-verification-result/20138/2 "2019-03-05T08:45:51Z")

</div>

Let me add another example.

I have made a Github project:

> **[GitHub - kazurayam/StepFailedExceptionRaisedByPreviousStatementOverridesTheLastStetement](https://github.com/kazurayam/StepFailedExceptionRaisedByPreviousStatementOverridesTheLastStetement)**
>
> Contribute to kazurayam/StepFailedExceptionRaisedByPreviousStatementOverridesTheLastStetement development by creating an account on GitHub.

You can reproduce the case with this code set.

## How to reproduce the problem

1. Download the zip of the project from [Releases](https://github.com/kazurayam/StepFailedExceptionRaisedByPreviousStatementOverridesTheLastStetement/releases) page.
2. Unzip the zip, open it with your Katalon Studio.
3. Select `Test Cases/TC1` and run it.

## Problem to solve

`TC1` script has the following statement:

```auto
def verificationResult =
	WebUI.verifyElementAttributeValue(
		findTestObject('Page_CURA Healthcare Service_top/a_Make Appointment'),
		'href',
		'https://www.google.com/', // this is a wrong URL
		5,
		FailureHandling.CONTINUE_ON_FAILURE)

```

This statement will fail. This is intentional. This is not a prblem.

`TC1` script has the followin statement at the end.

```auto
WebUI.closeBrowser()

```

Nobody would expect that this statement to fail.

But, when you run the `TC1` and you watch the Log Viewer, you will find Katalon Studio reports that the `closeBrowser()` failed!

See the following screenshot. [![screenshot](https://europe1.discourse-cdn.com/katalon/original/2X/f/f037831f4ad140ec244248e722ff99c07fc5c83a.png)](https://github.com/kazurayam/StepFailedExceptionRaisedByPreviousStatementOverridesTheLastStetement/blob/master/docs/images/problem_reproduced_why_closeBroser_is_marked_failed.png)

## My thought

Of course, `WebUI.closeBrowser()` statement actually succeeds, does not fail.

The thing is, the StepFailedException raised by the previous `verifyElementAttributeValue()` statement is reported as if it was raised by the `closeBrowser()` .

Katalon Studio seems to have a problem in handling StepFailedException.

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [March 15, 2019, 12:20am UTC](https://forum.katalon.com/t/stack-trace-error-replaces-the-verification-result/20138/3 "2019-03-15T00:20:44Z")

</div>

@YoungNgo  
@devalex88  
@ThanhTo

Please have a look at this
