Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to keep a command running in loop in browser console

I have a web element that only appears while the page (or a part of the page) is still loading and disappears when the page has been completely loaded. I would like to see precisely when this element disappears and I can do that by repeatedly running something like that in the browser console:

$("div.v-app-loading")

or alternatively:

document.getElementsByClassName('v-app-loading')

But in most cases everything happens too fast and I am unable to catch the exact moment. There must be a way to create a loop that will just run in the console and execute one of the commands I mentioned say every 0.5sec or even more frequently.

Could anyone point me to the right direction?

like image 785
Eugene S Avatar asked Oct 16 '25 14:10

Eugene S


1 Answers

You can use Javascript's setInterval() as following:

function yourFunction(){
    //do something here...
}
setInterval(yourFunction, 500); //Will run the function every half a second(500ms = 0.5s)
like image 163
Bubble Hacker Avatar answered Oct 18 '25 08:10

Bubble Hacker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!