const sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay)) async function repeatGreetingsLoop() { for (let i = 0; i <= 5; i++) { await sleep(1000) document.getElementsByClassName("el-switch")[0].click(); await sleep(1000) document.getElementsByClassName("el-switch")[0].click(); await sleep(1000) document.getElementsByClassName("el-button el-button--default el-button--small el-button--primary")[0].click(); } } repeatGreetingsLoop()