which automation tool are you using?
in mordern web, pages are loading everytime, the better approach is to tell it that "do this after this (a specific element) loads or reloads, or loads for a first time", a tip, give it a time interval like wait for every 1 second, up to 3 seconds etc
and if you are using Playwright, Puppeteer, Selenium etc, use their own waiting or clicking features like page.get_by_role("button", name="Submit").click()