I am currently developing an automation tool for a website using Selenium in Java. To enhance the real automation process, I heavily rely on JavaScript with JavascriptExecutor. While things usually run smoothly, there are occasional crashes (around 1 out of 10 times). It seems like the code is executing too quickly during those instances. Despite utilizing implicit and explicit waits from the WebDriverWait class, I believe these waits only apply to the DOM or elements within it, rather than waiting for all scripts to finish executing. This led me to search for a function or snippet that can address this issue. It's worth mentioning that the website utilizes both Vue and Angular frameworks.
Appreciate any help in advance!