Best practice to wait webpage loading?

I'm doing some automation using KM for some webpages. Since the webpage load speed various from time to time, my automation is not working reliably by just wait for say 0.5 second. Now I switched to use "Wait for Google Chrome to Finish Loading" for at least 1 second. It seems working fine now, however the performance suffers since in one of the automation it loads 10+ pages. And what's more, inside these pages, need to click a button and then again wait for loading and then next step...

My question is what is the best practice to handle such case?

I knew in javascript there is something called waitForKeyElements (, which will execute something only a certain element appears in the webpage, not sure if something similar available?


See this macro:

MACRO: Pause Until Web Page Element Exists [Example]

I have used this technique with great success.

1 Like

That macro should work. Thanks!

Quick question: since this will be a common utility, I plan to put it in a standalone macro and call it from other macros when needed. To pass the css selector I can just set an instance variable so the sub-macro can see it. This should work, right? So it will need two actions (one to set the variable, then second execute a sub-macro). Is there a way to call a sub-macro with a parameter (like a function/method call with parameter)?

Yes. See Execute a Macro action.

1 Like