Problem using wait for element clickable instead of WebUI.Delay

Unfortunately the katalon script i made is not working as I wished. Basically, I can not click a button even with the wait for element clickable function before click. However when putting a delay in the script it runs successfully. Why does it happen? I really don´t understand. Because the test passed on wait for element clickable but failed when i perfom the click. It only works with delay and i don’t want to use it because i want to have a dynamic time and not a static one. This really compromise performance of my test scripts.

1 Like


try some another wait method
e.g. waitForElementPresent

I agree and it’s a well-known problem. While I don’t have a specific answer, I can explain how you can work toward a better solution.

First, the problem in general terms:

  1. Your test runs like lightning.
  2. The browser takes a long time to “build” the webpage – all the controls, buttons, and other elements take time to create, position and lay them out, etc.
  3. You need to introduce a means to synchronize your fast test script with a slow browser.

In terms of delays, fixed or otherwise, every line of test code slows your test a little. <- That’s your clue, right there.

If you adopt a philosophy of waiting for lots of things (even things that don’t seem to matter much) you will be adding to the overall time it takes to hit your real test case statements.

So start writing more “waits”. Perhaps you can wait for a menu to be visible and wait for a copyright message (usually at the end of a page, which is good). And Like Timo suggested, use all the waits on each of the “don’t really care about these” elements:

  1. Wait for element present.
  2. Wait for element visible

Do that for each element before you get to the element you’re trying to test. Then, just for insurance purposes,

  1. WebUI.delay(1) or whatever delay you think necessary.

Now you’re ready to target the elements you really care about.

“But wait – isn’t that adding a lot of code to each test?"

Depends how you do it. You can write custom keywords to minimize the amount of code:

void waitForElementReallyReallyReallyReady(TestObject to, int delay) {
  WebUI.waitForElementPresent(to, delay)
  WebUI.waitForElementVisible(to, delay)

Hope that helps you. Works for me all day every day.

1 Like

What’s likely happening is that the button IS clickable based on what katalon (and to the underlying webdriver) define as “clickable”. I believe that webdriver considers element visibility, as well as the state of the disabled attribute when checking for clickability. My guess as to what’s happening is that there’s some other attribute that you will need to check for outside of these two things to know when the button is truly ready to receive a click.

To start, can you share the HTML for the button and maybe some if it’s parent elements?