Wait until page loaded or found a class on the page

It's very simple that I need to run KM very quick.

I tried "Wait for Google Chrome to finish Loading".
But it's too long to wait.

Therefore I used "querySelectorAll" to find a class on the page.
As soon as it finds the class, then it runs other KM.

So I am trying to use "Excut actions until ..." and keep checking the class or ID..
If it finds the class, then save it to a KM variable...

And run other KM actions.

FYI, I am rung "loop" for click and this action.
That's why I reset the variable to empty at the end for the next loop.

But I think I got confused for "Excute Actions Unitl" and it doesn't seems be working well.

If you have time, plz help :slight_smile:

I assume when you say " it doesn't seems be working well." , it means the whole macro get cancel due to some error.

You can try put a "Display Text" action after "The real actions" action to find out if that action actually cause the macro to stop working. I suspect the "the real actions" probably cause the macro to stop working.

Try disable "Failure Aborts Macro" in those actions in "the real actions" and "Execute Text Script" action

You can rewrite the script this way.

(function () { // load
const items = document.querySelectorAll(".itm-num-txt");
return String(items && items.length > 0);

1 Like

Take a look at this:

Macro: Pause Until Web Page Element Exists [Example]

1 Like

Thank you all the time. :slight_smile:

1 Like

@ccstone is there any way to run these actions for certain minutes?

My process is like…

1.Refresh the page ( browser)
2. Find the class name. Ready to start the next action.
3. Run the next JS script until the result gets true.
If not, keep refreshing the browser( page ).
But the refresh should be only 5 minutes.
So I need to add some action which should not be unlimited loop refreshing.

You've looked at the Pause Until action?