# Conditional statements

**URL:** <https://forum.katalon.com/t/conditional-statements/9742>\
**Category:** Miscellaneous\
**Created:** [March 13, 2018, 12:31pm UTC](https://forum.katalon.com/t/conditional-statements/9742 "2018-03-13T12:31:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![m\_de\_boer](https://avatars.discourse-cdn.com/v4/letter/m/8c91f0/32.png) [@m\_de\_boer](https://forum.katalon.com/u/m_de_boer)\
**Post date:** [March 13, 2018, 12:31pm UTC](https://forum.katalon.com/t/conditional-statements/9742/1 "2018-03-13T12:31:44Z")

</div>

Katalon seems to be an easy to use testtool to create aut testscripts very easy. But now and than there is something strange in appearantly simple constructions in the testcases.  
I want to make a conditional step in my case ( if this is true, then do that). It seems that it only works if the condition is indeed true. If the condition is false, then i get the message  
**statement:**

if (!WebUI.verifyElementAttributeValue(findTestObject(‘InProces/Inproces 2.12-SNAPSHOT/md-switch\_afgehandeld’), ‘aria-checked’,

```
'false', 0)) {

WebUI.click(findTestObject('InProces/Inproces 2.12-SNAPSHOT/md-switch\_afgehandeld'), FailureHandling.CONTINUE\_ON_FAILURE)

```

}

**error:**  
Test Cases/koppel CB in Squit2020 FAILED because (of) Unable to verify if object ‘Object Repository/InProces/Inproces 2.12-SNAPSHOT/md-switch\_afgehandeld’ has attribute ‘aria-checked’ with value ‘false’ (Root cause: Object ‘Object Repository/InProces/Inproces 2.12-SNAPSHOT/md-switch\_afgehandeld’ has attribute ‘aria-checked’ with actual value ‘true’ instead of expected value ‘false’)

is this a bug or am I causing this failure? Is there anybody with an idea how to solve this?

---

<div class="post-metadata">

**Author:** ![Joseph](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@Joseph](https://forum.katalon.com/u/Joseph)\
**Post date:** [March 14, 2018, 12:46am UTC](https://forum.katalon.com/t/conditional-statements/9742/2 "2018-03-14T00:46:44Z")

</div>

It’s not a bug. Katalon really will throw an error if a verify method returns false. I did a quick test on YOPmail.

\*\*Code:  
\*\*WebUI.verifyElementAttributeValue(findTestObject(‘YOPmail - Inbox/txtRecipient’), ‘name’, ‘poi’, 0)

\*\*Error:  
\*\*Test Cases/Send Mail FAILED because (of) Unable to verify if object ‘Object Repository/YOPmail - Inbox/txtRecipient’ has attribute ‘name’ with value ‘poi’ (Root cause: Object ‘Object Repository/YOPmail - Inbox/txtRecipient’ has attribute ‘name’ with actual value ‘mailto’ instead of expected value ‘poi’)

---

<div class="post-metadata">

**Author:** ![Charles\_Brown](https://avatars.discourse-cdn.com/v4/letter/c/4bbf92/32.png) [@Charles\_Brown](https://forum.katalon.com/u/Charles_Brown)\
**Post date:** [June 15, 2018, 7:17am UTC](https://forum.katalon.com/t/conditional-statements/9742/3 "2018-06-15T07:17:55Z")

</div>

I was able to solve this using the FailureHandling.OPTIONAL in my condition.  
Instead of using the “!” I used “== false” in the condition. See the example below:

if ((WebUI.verifyElementVisible(button\_Create, FailureHandling.OPTIONAL)) == false) {

```
def Text = WebUI.getText(div_ErrorMessage)

println(Text)  

return null   

```

} else {

WebUI.click(findTestObject(‘button\_Create’))

}

Hope this helps.
