I have the following code, which tries to click a button after 60 seconds, and if it has not loaded, try again after 60 seconds.
while(true) {
var timeout = setTimeout(function() {
try{
document.querySelector('.department-info').click()
} catch(e) {
console.log('Retrying in 60 seconds...') //error handling
}
}, 60000)
};
The problem is that it is not entering catch()
and is, after a few lag runs, causing the page to lock and close. Can you help me? What is being done wrong?