# Cant verify if element is not present on site

**URL:** <https://forum.katalon.com/t/cant-verify-if-element-is-not-present-on-site/31841>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [August 20, 2019, 1:25pm UTC](https://forum.katalon.com/t/cant-verify-if-element-is-not-present-on-site/31841 "2019-08-20T13:25:44Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![wolczoskar](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/wolczoskar/32/16812_2.png) [@wolczoskar](https://forum.katalon.com/u/wolczoskar)\
**Post date:** [August 20, 2019, 1:25pm UTC](https://forum.katalon.com/t/cant-verify-if-element-is-not-present-on-site/31841/1 "2019-08-20T13:25:44Z")

</div>

Hello again,

Can someone tell me why those test fail?  
I want to verify if element is not present on site. They are not, im using global variable for that,  
See screenshots.

 ![Screenshot_79](https://europe1.discourse-cdn.com/katalon/original/2X/f/f91b0123c6c68582d6bdd9d539f31749473160ee.png) ![Screenshot_80](https://europe1.discourse-cdn.com/katalon/original/2X/d/de8b8e69dc947ee97259f8c4cb533a3754b17cd6.png) ![Screenshot_78](https://europe1.discourse-cdn.com/katalon/original/2X/a/a9146be8b6592f7fa5750ec26239b21182583b23.png)

---

<div class="post-metadata">

**Author:** ![Nilau](https://avatars.discourse-cdn.com/v4/letter/n/bb73d2/32.png) [@Nilau](https://forum.katalon.com/u/Nilau)\
**Post date:** [August 20, 2019, 2:02pm UTC](https://forum.katalon.com/t/cant-verify-if-element-is-not-present-on-site/31841/2 "2019-08-20T14:02:55Z")

</div>

I am not sure your global variable (Barrier\_page) is correct. Can you show us that you have assigned to it ?

---

<div class="post-metadata">

**Author:** ![Sudheer\_D\_J](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/sudheer_d_j/32/16104_2.png) [@Sudheer\_D\_J](https://forum.katalon.com/u/Sudheer_D_J)\
**Post date:** [August 20, 2019, 2:17pm UTC](https://forum.katalon.com/t/cant-verify-if-element-is-not-present-on-site/31841/3 "2019-08-20T14:17:28Z")

</div>

Add a Failure condition to it like  
boolean elemPresent = WebUI.verifyElementNotPresent(GlobalVariable.Barrier\_page,0, FailureHandling.OPTIONAL)  
println elemPresent

---

<div class="post-metadata">

**Author:** ![Nilau](https://avatars.discourse-cdn.com/v4/letter/n/bb73d2/32.png) [@Nilau](https://forum.katalon.com/u/Nilau)\
**Post date:** [August 20, 2019, 2:19pm UTC](https://forum.katalon.com/t/cant-verify-if-element-is-not-present-on-site/31841/4 "2019-08-20T14:19:56Z")

</div>

If I remember correctly, WebUI.verifyelementNotPresent always throw an exception when it fails. If you want assign the result for a boolean, you have to use **WebUI.WaitForElementNotPresent()**

---

<div class="post-metadata">

**Author:** ![Sudheer\_D\_J](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/sudheer_d_j/32/16104_2.png) [@Sudheer\_D\_J](https://forum.katalon.com/u/Sudheer_D_J)\
**Post date:** [August 20, 2019, 2:21pm UTC](https://forum.katalon.com/t/cant-verify-if-element-is-not-present-on-site/31841/5 "2019-08-20T14:21:07Z")

</div>

Verify statement can also be assigned to boolean

---

<div class="post-metadata">

**Author:** ![wolczoskar](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/wolczoskar/32/16812_2.png) [@wolczoskar](https://forum.katalon.com/u/wolczoskar)\
**Post date:** [August 20, 2019, 2:25pm UTC](https://forum.katalon.com/t/cant-verify-if-element-is-not-present-on-site/31841/6 "2019-08-20T14:25:46Z")

</div>

What do you mean? What have i assigned to it?

If i change it to **WebUI.WaitForElementNotPresent()** im getting this

 ![Screenshot_83](https://europe1.discourse-cdn.com/katalon/original/2X/c/c3080953f79e4ebf93c186a059597b88c38ff2fd.png)

of course element is not present on site

---

<div class="post-metadata">

**Author:** ![Nilau](https://avatars.discourse-cdn.com/v4/letter/n/bb73d2/32.png) [@Nilau](https://forum.katalon.com/u/Nilau)\
**Post date:** [August 20, 2019, 2:29pm UTC](https://forum.katalon.com/t/cant-verify-if-element-is-not-present-on-site/31841/7 "2019-08-20T14:29:58Z")

</div>

Your global variable “Barier\_page” is probably a type String.  
When you are using WebUI.verifyElementNotPresent(GlobalVariable.Barrier\_page,0), it replace GlobalVariable.Barrier\_page with the String you have setup.  
The first parameter of this function must be a test object, not a string.

> **[\[WebUI\] Verify Element Not Present](https://docs.katalon.com/katalon-studio/docs/webui-verify-element-not-present.html)**
>
> Description Verify if the given web element does NOT present on the DOM. Parameters Param Param Type Mandatory Description to TestObject Required Represent a web element. timeout int Required System...

Or is your variable a test object ?

---

<div class="post-metadata">

**Author:** ![wolczoskar](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/wolczoskar/32/16812_2.png) [@wolczoskar](https://forum.katalon.com/u/wolczoskar)\
**Post date:** [August 20, 2019, 2:41pm UTC](https://forum.katalon.com/t/cant-verify-if-element-is-not-present-on-site/31841/8 "2019-08-20T14:41:50Z")

</div>

My variable is test object

 ![Screenshot_84](https://europe1.discourse-cdn.com/katalon/original/2X/b/b93bcd2fbea06da808752844e8147eee4db11180.png)

---

<div class="post-metadata">

**Author:** ![Nilau](https://avatars.discourse-cdn.com/v4/letter/n/bb73d2/32.png) [@Nilau](https://forum.katalon.com/u/Nilau)\
**Post date:** [August 20, 2019, 2:44pm UTC](https://forum.katalon.com/t/cant-verify-if-element-is-not-present-on-site/31841/9 "2019-08-20T14:44:46Z")

</div>

Sorry, I missed your other message where you changed for “WaitForElementPresent”. Also, this show us the element is present, so it’s normal that when you try to “VerifyElementNotPresent” it always fail because the element is present.

---

<div class="post-metadata">

**Author:** ![wolczoskar](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/wolczoskar/32/16812_2.png) [@wolczoskar](https://forum.katalon.com/u/wolczoskar)\
**Post date:** [August 20, 2019, 4:00pm UTC](https://forum.katalon.com/t/cant-verify-if-element-is-not-present-on-site/31841/10 "2019-08-20T16:00:36Z")

</div>

Yea but the point is that element is not present xd

---

<div class="post-metadata">

**Author:** ![Nilau](https://avatars.discourse-cdn.com/v4/letter/n/bb73d2/32.png) [@Nilau](https://forum.katalon.com/u/Nilau)\
**Post date:** [August 20, 2019, 4:36pm UTC](https://forum.katalon.com/t/cant-verify-if-element-is-not-present-on-site/31841/11 "2019-08-20T16:36:14Z")

</div>

The element is not present or the element is not visible ? It can be present on the DOM but not visible to your eyes. It’s two different things.

---

<div class="post-metadata">

**Author:** ![wolczoskar](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/wolczoskar/32/16812_2.png) [@wolczoskar](https://forum.katalon.com/u/wolczoskar)\
**Post date:** [August 20, 2019, 4:46pm UTC](https://forum.katalon.com/t/cant-verify-if-element-is-not-present-on-site/31841/12 "2019-08-20T16:46:50Z")

</div>

I know but its not present at all on site.
