Thanks Morpheus.
I will add the "wait for page load" on the most critical failures and see how it behaves.
Will also migrate the script to a better VM.
@Fox Yes, but I couldn't find it, we can only choose what to do when a certain line gives an error, but the error can occur on any line. I want to run a command when the complete script gives an error?