I am trying to put together a hacky script to click some buttons on a website
I have a setTimeout function to click a button after sometime. After the button is clicked I have more DOM elements available which I have to click again. At no point does the whole page reload.
I tried the following
$("#id1").click();
setTimeout((){
var button2 = $("#id2");
button2.click();
}, 3000);
}, 3000)
id2 is not available initially and is available only after id1 is clicked. The above script therefore cannot click button 2, since it was not able to access it. How can I make my above condition work.