# Managing Element Presence Checks in Katalon Without Console Errors

**URL:** <https://forum.katalon.com/t/managing-element-presence-checks-in-katalon-without-console-errors/147998>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [September 26, 2024, 9:46am UTC](https://forum.katalon.com/t/managing-element-presence-checks-in-katalon-without-console-errors/147998 "2024-09-26T09:46:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![qaecoonline](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/qaecoonline/32/23870_2.png) [@qaecoonline](https://forum.katalon.com/u/qaecoonline)\
**Post date:** [September 26, 2024, 9:46am UTC](https://forum.katalon.com/t/managing-element-presence-checks-in-katalon-without-console-errors/147998/1 "2024-09-26T09:46:45Z")

</div>

I’m working with an `if` loop that checks for the presence of an element. If the element is present, it enters the loop; if not, it should continue executing the script without throwing any console errors or exceptions for that element. I want the script to proceed seamlessly regardless of the element’s presence.

I’ve used `FailureHandling.OPTIONAL`, and it works well, but I don’t want to see any errors in the console.

Here’s the code I’m using for reference:

`WebUI.scrollToPosition(50, 50) if (WebUI.verifyElementPresent(findTestObject(permissionField), 5, FailureHandling.OPTIONAL)) { WebUI.click(findTestObject(permissionField)) } WebUI.click(findTestObject("Object Repository/IEX/table/permissionRules/addNewRule_btn"))`

How can I achieve this? Thank you!

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/katalon/original/3X/d/5/d55596ab02785a255798e87ede769734747b30c4.svg) [@system](https://forum.katalon.com/u/system)\
**Post date:** [September 26, 2024, 9:46am UTC](https://forum.katalon.com/t/managing-element-presence-checks-in-katalon-without-console-errors/147998/2 "2024-09-26T09:46:45Z")

</div>

Hi there, 👋

Thank you very much for your topic! It may take a little while before Katalon team member or others forum members respond to you.

In the meantime, you can _double-check_ your post to see if you can add any extra information i.e. error logs, HTML codes, screenshots, etc. Check out **[this posting guide](http://forum.katalon.com/t/tip-how-to-help-us-help-you/12919)** to **help us help you better!**

Thanks! 🕶  
Katalon Community team

---

<div class="post-metadata">

**Author:** ![grylion54](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/grylion54/32/16265_2.png) [@grylion54](https://forum.katalon.com/u/grylion54)\
**Post date:** [September 27, 2024, 5:39pm UTC](https://forum.katalon.com/t/managing-element-presence-checks-in-katalon-without-console-errors/147998/3 "2024-09-27T17:39:53Z")

</div>

You can put your code into a Keyword and then all you should get is a “response” that the code ran. Generally, you won’t get any error message unless your pathway to the object changes and it cannot be found anymore. If you have Katalon Studio after v9.0 then you need the Enterprise edition to use Keywords.

In your code, you could have:

```auto
WebUI.scrollToPosition(50, 50)

CustomKeywords.'com.Tools.reviewPermission'()

WebUI.click(findTestObject('Object Repository/IEX/table/permissionRules/addNewRule_btn'))

```

and in your Keyword, you would have:

```auto
@Keyword
public void reviewPermission() {
    if (WebUI.verifyElementPresent(findTestObject(permissionField), 5), FailureHandling.OPTIONAL) { 
        WebUI.click(findTestObject(permissionField))
    }
}

```

Also, just a note that I would change from using “verifyElementPresent” and instead either use: “verifyElementVisible” or “verifyElementClickable”. These two statements indicate that the object is visible or is ready to click, whereas present just means it is on the page, but may not be visible or clickable.

```auto
if (WebUI.verifyElementVisible(findTestObject(permissionField))) { 

```

```auto
if (WebUI.verifyElementClickable(findTestObject(permissionField))) { 

```

---

<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:** [September 28, 2024, 1:17am UTC](https://forum.katalon.com/t/managing-element-presence-checks-in-katalon-without-console-errors/147998/4 "2024-09-28T01:17:45Z")

</div>

@qaecoonline

You should rather use [`waitForElementPresent`](https://docs.katalon.com/katalon-studio/keywords/keyword-description-in-katalon-studio/web-ui-keywords/webui-wait-for-element-present) keyword rather than `verifyElementPresent` keyword.

What’s the difference of these 2 keywords? The `waitForElementPresent` will never throw Exception when the element is found absent. The `verifyElementPresent` will throw Exception.
