# waitForImagePresent always return FALSE

**URL:** <https://forum.katalon.com/t/waitforimagepresent-always-return-false/25023>\
**Category:** Web Testing\
**Tags:** web-testing, katalon-studio\
**Created:** [May 10, 2019, 4:16am UTC](https://forum.katalon.com/t/waitforimagepresent-always-return-false/25023 "2019-05-10T04:16:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![JOE\_F](https://avatars.discourse-cdn.com/v4/letter/j/f4b2a3/32.png) [@JOE\_F](https://forum.katalon.com/u/JOE_F)\
**Post date:** [May 10, 2019, 4:16am UTC](https://forum.katalon.com/t/waitforimagepresent-always-return-false/25023/1 "2019-05-10T04:16:20Z")

</div>

It seems waitForImagePresent has a bug, it always return FALSE even the image is present. Any idea how to workaround it?

it will always print out ‘image not present’ in below code…  
if (WebUI.waitForImagePresent(findTestObject(‘Page\_Login/smartcard\_login\_button2’),1,FailureHandling.OPTIONAL))  
println ‘image present’  
else  
println ‘image not present’

---

<div class="post-metadata">

**Author:** ![Arnel](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/arnel/32/6360_2.png) [@Arnel](https://forum.katalon.com/u/Arnel)\
**Post date:** [May 10, 2019, 7:14am UTC](https://forum.katalon.com/t/waitforimagepresent-always-return-false/25023/2 "2019-05-10T07:14:31Z")

</div>

Hi Joe,

Try another work around… something like this:

```auto
//try getting the image locator, I'm sure there's an attribute representing the image you are trying to automate.

//then instead of using waitForImagePresent, try WebUI.waitForElementPresent or WebUI.waitForElementVisible
if (WebUI.waitForElementPresent(findTestObject("Your_Image_Object"), 30, FailureHandling.OPTIONAL) ||
    WebUI.waitForElementVisible(findTestObject("Your_Image_Object"), 30, FailureHandling.OPTIONAL)
{
    println ‘image present’
}
else
{
    println ‘image not present’
}

```

Hope that helps. . . 🙂

---

<div class="post-metadata">

**Author:** ![JOE\_F](https://avatars.discourse-cdn.com/v4/letter/j/f4b2a3/32.png) [@JOE\_F](https://forum.katalon.com/u/JOE_F)\
**Post date:** [May 18, 2019, 12:35am UTC](https://forum.katalon.com/t/waitforimagepresent-always-return-false/25023/3 "2019-05-18T00:35:17Z")

</div>

thanks Arnel for the tips. I just wonder why Katalon didn’t fix this obvious bug of waitForImagePresent.

but what if the image cannot be located in browser, or some dialogs from the OS.  
I can use Sikuli to do it.  
Another way is to …  
try{  
(WebUI.waitForImagePresent(findTestObject(‘Page\_Login/smartcard\_login\_button2’),1,FailureHandling. _ **STOP\_ON\_FAILURE** _))  
println ‘image present’  
} catch (Exception e) {  
println ‘image not present’  
}

---

<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:** [May 18, 2019, 8:07am UTC](https://forum.katalon.com/t/waitforimagepresent-always-return-false/25023/4 "2019-05-18T08:07:08Z")

</div>

Perhaps the definition of your TestObject `Page_Login/smartcard_login_button2` has some problem. For example, as [https://docs.katalon.com/katalon-studio/docs/webui-wait-for-image-present.html#example](https://docs.katalon.com/katalon-studio/docs/webui-wait-for-image-present.html#example) sais

> The test object needs to define a source image from the local machine for Katalon Studio to use it for verification

Have you defined the source image?

* * *

You should be aware that `waitForImagePresent()` keyword is very strict. It expects the image in the target Web page to be EXACTLY identical to the source image pixel-wise: just the same width, just the same hight, every pixel has same RGB value, no size-scaling should be applied. If a single pixel has different RGB value, then waitForImagePresent() will return FALSE.

What is worse is that waitForImage\*() does not give you any diagnostics; instead it just returns FALSE. You would be at a loss what to do next. Due to this single reason, I find waitForImage\*() keywords are hard to use. I would rather recommend you not to rely on them. You should find another path.

---

<div class="post-metadata">

**Author:** ![JOE\_F](https://avatars.discourse-cdn.com/v4/letter/j/f4b2a3/32.png) [@JOE\_F](https://forum.katalon.com/u/JOE_F)\
**Post date:** [May 18, 2019, 7:58pm UTC](https://forum.katalon.com/t/waitforimagepresent-always-return-false/25023/5 "2019-05-18T19:58:03Z")

</div>

thanks kazurayam, totally agree!

One good path is Sikuli, which relies on OpenCV. It’s a lot more reliable.  
Any better path you recommend for image comparison?

---

<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:** [May 19, 2019, 12:19am UTC](https://forum.katalon.com/t/waitforimagepresent-always-return-false/25023/6 "2019-05-19T00:19:16Z")

</div>

I have ever tried to compare images (screenshots) using [aShot](https://github.com/pazone/ashot).

See the following post of mine:

> [@Testing Slideshow in Katalon Studio](http://forum.katalon.com/t/testing-slideshow-in-katalon-studio/13752):
>
> I have made a demo project at [GitHub - kazurayam/TestingSlideshowInKatalonStudio: A Katalon Studio project, which test a slideshow on a Web Page is in mortion or not.](https://github.com/kazurayam/TestingSlideshowInKatalonStudio) ---------- Problems to solve Many web sites have slide show in the top page. For example, have a look at this beautiful site: [Mandelbrot Explorer](https://www.mandel.org.uk/). A slide show displays a fixed number of images switched circularly with a fixed interval of some seconds. I want to verify if a slide show is in motion. In other words, I want to …

In this demo project, I calculated the magnitude of difference of 2 given images (source and target) : 0.0%, 0.1%, …, 75.34%, 99.80%, 100.0%. And I put 3rd parameter : criteria-percentage. If I put 1.00% as the criteria, my test regards smaller differences (such as 0.0% and 0.1%) are ignorable; meaning 2 images are similar enough. But greater differences (such as 75.34%, 99.80%, 100.0%) will be regarded significant; meaning 2 images are different.

An now AShot plugin for Katalon Studio is available.

- [Image Comparison using aShot Keywords](https://store.katalon.com/product/56/Image-Comparison-using-aShot-Keywords)

---

<div class="post-metadata">

**Author:** ![albert.vu](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/albert.vu/32/20595_2.png) [@albert.vu](https://forum.katalon.com/u/albert.vu)\
**Post date:** [August 8, 2022, 7:48am UTC](https://forum.katalon.com/t/waitforimagepresent-always-return-false/25023/7 "2022-08-08T07:48:58Z")

</div>

Archived on August 8, 2022, 7:48am UTC


